|
|
|
Simple Batch Script help
|
Original Message
|
Name: MAllen
Date: May 15, 2005 at 03:11:40 Pacific
Subject: Simple Batch Script helpOS: Windows XPCPU/Ram: - |
Comment: Hello. I've just registered and wondered if you fine people could help me out on a simple batch script programme. I've never done any before and I have to write one that uses the below ideas: Create a new batch file that will use one of the following commands: 1. net name 2. dir c:\ 3. echo finished The programme supplied will prompt the user to select one of the options from the above list. Once the selection is made the programme will run the selected command. This will be repeated until the user selects the “finish” (3rd) option. Can any of you help me write this programme, I haven't got much time to work on it so any help would be much appreciated. Many Thanks Mike Allen
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Mechanix2Go
Date: May 15, 2005 at 04:08:00 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hio Mike, Try this: ::== @echo off cls echo 1. net name echo 2. dir c:\ echo 3. echo finished choice /c123 Pleasease choose goto %errorlevel% :1 echo here's 1 :: take out the line above and put in your command goto :eof :2 echo here's 2 :: take out the line above and put in your command :3 :eof ::== M2 If at first you don't succeed, you're about average.
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Mechanix2Go
Date: May 15, 2005 at 04:15:25 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Well... On second thought, this is probably what you want: ::== @echo off cls echo 1. net name echo 2. dir c:\ echo 3. finished echo. choice /c123 Pleasease choose goto %errorlevel% :1 net name goto :eof :2 dir c:\ goto :eof :3 echo finished :eof ::== M2 If at first you don't succeed, you're about average.
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: MAllen
Date: May 15, 2005 at 05:16:00 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Thanks for these, I will have a go at it now and I'll get back to you. Many Thanks again
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: MAllen
Date: May 18, 2005 at 02:34:18 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi I've tried both of those and nothing happens - I'm sorry but can you please run through it step by step of what to do and what to include. Many Thanks Mike
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: MAllen
Date: May 18, 2005 at 08:05:08 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi No Error Message or Output at all I just double click the program and it just ends.
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: MAllen
Date: May 19, 2005 at 08:33:30 Pacific
Subject: Simple Batch Script help |
Reply: (edit)When I wrote the script out in Notepad and then saved it, should I leave the default as .txt or add exe at the end as others have done that. And then they just double click on the exe file and it runs.
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: Mechanix2Go
Date: May 19, 2005 at 21:56:54 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi Mike, In order for a batch file to work, it needs to be named blabla.BAT, like: Mikes.BAT 123.BAT etc M2 If at first you don't succeed, you're about average.
Report Offensive Follow Up For Removal
|
|
Response Number 10
|
Name: MAllen
Date: May 20, 2005 at 06:32:34 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi I've done that and copied your code from the second example and again it runs and then straight away ends.
Report Offensive Follow Up For Removal
|
|
Response Number 12
|
Name: MAllen
Date: May 20, 2005 at 08:35:57 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi Nothing - it appears then disappears in a second so I can't see what is on the screen :-( Mike
Report Offensive Follow Up For Removal
|
|
Response Number 14
|
Name: MAllen
Date: May 20, 2005 at 09:41:52 Pacific
Subject: Simple Batch Script help |
Reply: (edit)In the folder it's saved it just the name of the file and reads ms dos batch file and when I click on it it appears and within a second disappears and I don't have time to read what is on it.
Report Offensive Follow Up For Removal
|
|
Response Number 17
|
Name: The Assistant
Date: May 21, 2005 at 13:05:49 Pacific
Subject: Simple Batch Script help |
Reply: (edit)To get it to work on my system I had to include the path to the Choice command. I also inserted a couple of Pauses to allow you to verify the successdful completion. @echo off cls echo 1. net name echo 2. dir c:\ echo 3. finished echo. c:\windows\command\choice /c123 Please choose goto %errorlevel% :1 net name goto :eof :2 dir c:\ Pause goto :eof :3 echo finished Pause :eof
Report Offensive Follow Up For Removal
|
|
Response Number 18
|
Name: MAllen
Date: May 22, 2005 at 06:04:10 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi So if I copy and paste this into notepad and save it as a batch file it should work succesfully? Thanks for this again and for being very patient with me. Mike
Report Offensive Follow Up For Removal
|
|
Response Number 19
|
Name: Mechanix2Go
Date: May 22, 2005 at 06:54:42 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi Mike, #7 refers you to reply 7 where I said you need to go to a command prompt. That's the only way to get it working right. M2 If at first you don't succeed, you're about average.
Report Offensive Follow Up For Removal
|
|
Response Number 20
|
Name: The Assistant
Date: May 22, 2005 at 11:21:08 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Copy it into Word Pad and not Note Pad. Then select "Save As". Make the File Name any name you want but the extenstion must be ".bat" Change the Save AS Type to "Text Document-MS DOS Format" Save the file and then go to the location you saved it and double click on it to execute.
Report Offensive Follow Up For Removal
|
|
Response Number 21
|
Name: Mechanix2Go
Date: May 22, 2005 at 11:33:25 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi The, He's been clicking on it for a few days. That's the problem. Not the solution. Difficult to figure what advantage wordpad might bring to this saga. 21 and counting. M2 If at first you don't succeed, you're about average.
Report Offensive Follow Up For Removal
|
|
Response Number 22
|
Name: The Assistant
Date: May 22, 2005 at 20:40:02 Pacific
Subject: Simple Batch Script help |
Reply: (edit)The copy and paste option eliminates typos. Without the path to the choice command the batch file just flashes on the screen for a split second and aborts without any error or indication why. Using NotePad won't work because it doesn't offer the option of saving the file in a "Document Text-MS DOS Format" whereas Word Pad does.
Report Offensive Follow Up For Removal
|
|
Response Number 23
|
Name: Mechanix2Go
Date: May 22, 2005 at 23:35:13 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Hi The, Interesting point about WP / NP. Seems many, many folks have used NPt for the "text editor" of choice for a long time. Windows also has "EDIT", FWIW; I never use it. I use a real DOS text editor. You're correct in guessing that CHOICE may not be in the path. Hard tellin' where it might be. But if CHOICE is not in the path, you'll get an error. That's why I'm trying to get Mike to run it from a prompt. M2 If at first you don't succeed, you're about average.
Report Offensive Follow Up For Removal
|
|
Response Number 24
|
Name: MAllen
Date: May 23, 2005 at 00:24:38 Pacific
Subject: Simple Batch Script help |
Reply: (edit)I typed it out in wordpad and saved it as a text document-MS Dos format. I double click on the file and it opens but under the options it reads: "The System cannot find the path specified finished press any key to continue.." When I type in 1 or 2 or 3 it just ends! :-( Thanks for the help again on this batch file - I have two weeks to make sure it runs succesfully :-)
Report Offensive Follow Up For Removal
|
|
Response Number 25
|
Name: The Assistant
Date: May 23, 2005 at 08:01:05 Pacific
Subject: Simple Batch Script help |
Reply: (edit)Do a search for "choice" on your system and note the path to it when found. Modify the instructions in the Bat file with the path you found.
Report Offensive Follow Up For Removal
|
|
Response Number 26
|
Name: michaliv
Date: June 1, 2005 at 05:56:21 Pacific
Subject: Simple Batch Script help |
Reply: (edit)If you have Win 2k or XP you may have to use the set command: @ECHO off cls :start ECHO. ECHO 1. net name ECHO 2. dir c:\ ECHO 3. Finish set choice= set /p choice=Type the number to print text. if not '%choice%'=='' set choice=%choice:~0,1% if '%choice%'=='1' goto 1 if '%choice%'=='2' goto 2 if '%choice%'=='3' goto 3 ECHO "%choice%" is not valid please try again ECHO. goto start :1 net name goto start :2 dir c: goto start :3 goto end :end ECHO Program Closed.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|