Forum Home
Press F1
 
Thread ID: 41683 2004-01-19 05:13:00 Basic DOS .bat file commands? Scripting help... Chilling_Silently (228) Press F1
Post ID Timestamp Content User
208441 2004-01-19 05:13:00 Greetings,

Im trying to create a basic .bat file that will:
echo Press 1 for Install app 1
echo Press 2 to run this bat file

Then I want it to prompt the user to press 1 or 2.

Upon pressing 1, Im wanting the file to:
CALL appname.exe
If the user presses 2, I want it to:
CALL batname.bat

How do I do this?

Another quick question, how do I append a string of text, say to the autoexec.bat file but keep the origional text??

Many thanks


Chill.
Chilling_Silently (228)
208442 2004-01-19 05:21:00 Just one other thing...
How would I add say option 3, and have it open a .doc file with their default editor?
Chilling_Silently (228)
208443 2004-01-19 05:27:00 Chill,

Have a look Here (www.computerhope.com)

Cheers, Babe.
Babe Ruth (416)
208444 2004-01-19 05:59:00 how about using the choice.com command (don't think it comes with xp) along with "if errorlevel=... goto label..."
I think N produces an errorlevel of 3 and Y an errorlevel of 1

-Jacob
Jacob4165 (199)
208445 2004-01-19 10:39:00 @echo off
echo Press 1 for Install app 1
echo Press 2 to run this bat file
echo.
choice /C:12

if errorlevel 1 appname.exe
if not errorlevel 1 call batname.bat

I haven't tested it so the actions for the errorlevel lines might need to be swapped.

> Another quick question, how do I append a string of
> text, say to the autoexec.bat file but keep the
> origional text??

The same as in unixland, use a double ">>", eg:

echo Hello World >> autoexec.bat
bmason (508)
208446 2004-01-19 11:09:00 Thats great guys, thanks for all the great feedback :-)

I'll give it a try tomorrow when Im at work and will post my final .bat final in case you want to see what I come up with :-)

Many thanks


Chill.
Chilling_Silently (228)
208447 2004-01-20 00:48:00 Hey guys, ive run into a wee bit of trouble.
Heres what Ive got so far:
@echo off
echo Press 1 for Server or Single User Installation
echo Press 2 for Workstation Installation
echo.
choice /N /C:12 Please select an Install or Ctrl + C to Cancel:
IF ERRORLEVEL ==1 GOTO SERVER
IF NOT ERRORLEVEL ==1 GOTO WS
:SERVER
echo You have chosen Server or Single User installation
call setup.exe
GOTO END
:WS
echo You have chosen a Workstation install for Multi-User Environment
call config~1.bat
GOTO END
:END

Only its not calling the Configure_Workstation.bat file I have in the same folder? choice.com is in the root folder...

Any ideas? It just always runs the setup.exe?

Cheers


Chill.
Chilling_Silently (228)
208448 2004-01-20 01:00:00 instead of call, try start ilikelinux (1418)
208449 2004-01-20 01:07:00 Is that a problem? :D

That's exactly what you are telling it to do.

If you enter 2, it plugs the value into ERRORLEVEL, then does the test, like this :if 2>= 1 then goto setup
If you enter 1, it does if 1 >=1 then goto setup.

(The secret is to start testing with the highest ERRORLEVEL and workdown.)

This page (www.carleton.ca) might help.(If I misspelt the url,"choice dos batch"to Google will get it). ;-)
Graham L (2)
208450 2004-01-20 01:24:00 Chill, Further to Graham L's comments

If you wanted to run the command under Win2k or WinXP then CHOICE is not available however see User Input in Windows 2000 Batch Files (www.pcmag.com) or copy the CHOICE.COM utility from Windows 98 {usually located in C:\windows\command} and locate where you want in W2K/WXP {usually within the PATH} or in the same location as your batch script(s). This of course may not be an issue for you.

Cheers, Babe.
Babe Ruth (416)
1 2