Simple Batch File Help

Mike_A

Solid State Member
Messages
9
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. I posted on another forum and their solutions were not working.

Many Thanks

Mike Allen
 
wow what a can of worms that is...

there are a few methods that you can use...
each get steaditly more compilcated than the last...

the first (easiest), is t ave four batch files...

start.bat
Code:
@echo off
REM this is the choices menu
echo 1, print Net name.
echo 2, Print c:\
echo 3, finish.

1.bat
Code:
REM do function
net name
REM call menu
start.bat

2.bat
Code:
dir c:
start.bat
3.bat
Code:
echo press any key to exit...
pause > null
 
the second is folowing advice from microsoft

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q77457&ID=KB;EN-US;Q77457&

you have to write your own key trapping program using assenbally language...

this is easier than it sounds...
go to the comand prompt and change to the windows directory (so it'll be in the system path)...

now type the following exactly...#
[enter] means press the return key...

debug reply.com [enter]
a 100 [enter]
mov ah,08 [enter]
int 21 [return]
cmp al,0 [return]
jnz 010a [return]
int 21[return]
mov ah,4c [return]
int 21 [return]
[return]
rcx [return]
e [return]
n reply.com [return]
w [return]

(at this point the program informs you that the program is written and akes E bytes (14 bytes)

q [return] and that quits...

now you are ready to write the batch file...

Code:
@Echo off

:Ask
Echo press 1 to view net name,
Echo press 2 to view contents of C:
Echo press 3 to exit.

Reply

If errorlevel 49 if not errorlevel 50 goto one
If errorlevel 50 if not errorlevel 51 goto two
If errorlevel 51 if not errorlevel 52 goto three

Echo Error wrong Key pressed.
goto ask

:one
NET view
pause > null
goto ask

:two
dir c:
pause > nul
goto ask

:three
   cls
   ver
 
I tried the first method and only number 2 and three load when I double click on them.

I created all four files in WordPad and typed the code as you did but the start one loads and then disappears as does number 1. Wheres 2 and 3 load but when I try to enter a number or Y or N it says invalid.

Sorry for being such a dumbass but I've never done them before so I have no idea what is going wrong.
 
have all four batch file in a single folder.

now run them from the command prompt rather than double clicking the batch file.
the first file start.bat loads and disapears when you double click because it has no real functions, it only displays text. if you run it from the command prompt obviously the text stays around to be seen.

3 only stays around because of the pause function used,

run it all from a command prompt and it'll make sense.
 
I've go to run and selected the start.bat and as you said it loads then disappears then, number three when selected loads then when I click three it ends but the other two don't work still.
 
ok...
now follow the instructions...
opn the command prompt...
navigate to the folder containing the batch files and run the folder called start.bat...

as I said in the previous post, the reason the file start.bat disapears is because it finishes. there is no reason for it to hang about taking up screen space, so it doesn't.

you need to run it from the command prompt (using this method) because you need the text to stay on the screen so you can see what the choices are...
 
I think for this work we need to click on just one file and then the options all appear and in the same screen then once you type 1 or 2 the c directory is listed and so forth.
 
What exactly are you wantning to do with this script? If you are truing to setup a network i recommend getting your self a server and installing "Kixtart" or Kix32, (login scripts)
 
Back
Top Bottom