tags:

views:

22

answers:

1

I've created a script that will offer the user a choice in which action to run from the same program. The problem is, the person who created the program I'm calling set parameters that do not have switches like / or -. Whenever I run the batch and try to call the correct action, only the executable runs without the parameters and I've tried multiple ways of quoting and unquoting. Here's the batch as it stands with some NDA directory and application names taken out so I dont lose my job.

    @echo off
cls
:start
echo.

echo 1. EXPORT 
echo 2. EXPORT AP
echo 3. EXPORT CLASS ALL
echo 4. EXPORT CLASS STORE
echo 5. EXPORT PLUBATCH ALL
echo 6. EXPORT PLUBATCH STORE
echo 7. EXPORT STORE
echo 8. EXPORT TOUCH
echo 9. I'm Done
echo.
echo.
set /p x=Choose your fate:
IF '%x%' == '%x%' GOTO Item_%x%

:Item_1
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT

:Item_2
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT AP

:Item_3
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT CLASS ALL

:Item_4
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT CLASS STORE

:Item_5
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT PLUBATCH ALL

:Item_6
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT PLUBATCH STORE

:Item_7
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT STORE

:Item_8
start "APP" /MIN /D"C:\Program Files\xxx\APP\W2" xxx.exe EXPORT TOUCH

:Item_9
pause
exit

Whenever I run, say Choice 2, it only does the generic actions of the application as if I'm running no parameters at all. Export is obviously a command and the second parameter lists what you'd like the program to export. Any suggestions?

A: 
IF '%x%' == '%x%' GOTO Item_%x% 

Should be:

IF '%x%' == '%x%' GOTO :Item_%x% 

Let's try a simpler example:

@echo off 
cls 
:start 
echo. 

echo 1. Do something.
echo 2. Do something else.
echo 3. Quit
echo. 

set /p x=Choose your fate: 
goto :Item_%x

goto :eof

:Item_1 
echo Doing something.
goto :start

:Item_2 
echo Doing something else.
goto :start

:Item_3 
echo Quitting.
goto :eof
cdiggins
Thanks for your answer. I see where you're going with this and I like the cleaner approach, but it still doesn't handle the parameters like I need it to. When I run the command from a DOS prompt in that directory, the parameters are accepted with no switches, I just cant get the switchless parameters to pass in a batch.
Davedough