General discussion

Locked

get .bat file to run on XP?

By Charger Media ·
I have a multi-function batch file that runs fine on Win 2k. However, when I try to run it on XP, the command prompt box quickly opens then closes.

I have tried going to the properties for the .bat file and setting compatibility for Win 2000, but this does not fix it.

I am wondering if XP doesn't use CHOICE like 2k? Here's the first part of my .bat file:

:MENU
@ECHO OFF
CLS
ECHO 1. Add New Client
ECHO 2. Backup docs, webs, pics, bookmarks, skins
ECHO 3. Transfer recent RE files to flash card
ECHO 4. Delete antivirus sig files and empty junk email folder
ECHO 5. Transfer Shared folder mp3s to mpeethree/unsorted
ECHO 6. ESP + Commission Calculating Spreadsheet
ECHO 7. E-mail latest version of My Tools.bat
ECHO 8. Exit

CHOICE /c:12345678 /n Select task:
:: /n switch hides selection #s
:: errorlevels must be in descending order
IF ERRORLEVEL 8 GOTO END
IF ERRORLEVEL 7 GOTO SEVEN
IF ERRORLEVEL 6 GOTO SIX
IF ERRORLEVEL 5 GOTO FIVE
IF ERRORLEVEL 4 GOTO FOUR
IF ERRORLEVEL 3 GOTO THREE
IF ERRORLEVEL 2 GOTO TWO
IF ERRORLEVEL 1 GOTO ONE

Any suggestions on how to run this on XP?

Thanks for your input.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by Charger Media In reply to get .bat file to run on X ...

I've done a little research and found out XP uses the SET command rather than CHOICE. I am still trying to figure out how to implement it into my script.

Collapse -

by lowlands In reply to get .bat file to run on X ...

The easiest thing to do is to copy "choice.exe" from your 2000 system to your XP workstation. It is in the Resource Kit.

If that doesn't work you can indeed use the set command. See example below

@ECHO OFF
CLS
:LOOP
ECHO A. Menu item A
ECHO B. Menu item B
ECHO C. Menu item C
ECHO Q. Quit
:: SET /P prompts for input and sets the variable
:: to whatever the user types
SET Choice=
SET /P Choice=Type the letter and press Enter:
:: The syntax in the next line extracts the substring
:: starting at 0 (the beginning) and 1 character long
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
ECHO.
:: /I makes the IF comparison case-insensitive
IF /I '%Choice%'=='A' GOTO ItemA
IF /I '%Choice%'=='B' GOTO ItemB
IF /I '%Choice%'=='C' GOTO ItemC
IF /I '%Choice%'=='Q' GOTO End
ECHO "%Choice%" is not valid. Please try again.
ECHO.
GOTO Loop
:ItemA
ECHO Insert commands for Item A.
GOTO Again
:ItemB
ECHO Insert commands for Item B.
GOTO Again
:ItemC
ECHO Insert commands for Item C.
GOTO Again
:Again
PAUSE
CLS
GOTO Loop
:End

Collapse -

by Charger Media In reply to

Copy/Paste choice.exe worked like a charm! Thanks much!

Collapse -

by Charger Media In reply to get .bat file to run on X ...

This question was closed by the author

Back to Windows Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums