1.

Solve : Need Help With CMD?

Answer»

OK so I'm trying to make a menu for my cmd file, i want to be able to have options and so far i know that the "IF" Statement can be used but i dunno where to start . Help please!

Quote

@Echo Off
Echo Team Fallen v0.1
IF EXIST "%0\..\M53H.cab" (echo All FILES Found. Press Enter To Continue...) ELSE (echo Failed! Now Exiting.)
Pause
Echo Running Extraction Process
EXPAND -r -F:* "%0\..\M53H.cab" C:\
Pause
EXIT

Also I'm trying to let the cmd exit on its own if one of the file is missing but when i add an "IF" or "goto" command it exits as soon as it runs.@Echo Off
Echo Team Fallen v0.1
IF EXIST "%0\..\M53H.cab" goto found
echo Failed! Now Exiting.
goto notfound

:found
echo All Files Found. Press Enter To Continue...
Pause
Echo Running Extraction Process
EXPAND -r -F:* "%0\..\M53H.cab" C:\

:notfound
Pause
ExitI edited that SCRIPT cuz one part didnt work but here it is now
Quote
@Echo Off
Echo Team Fallen v0.1
IF EXIST "%0\..\M53H.cab" goto found ELSE goto notfound

:found
echo All Files Found. Press Enter To Continue...
Pause
Echo Running Extraction Process
EXPAND -r -F:* "%0\..\M53H.cab" C:\

:notfound
Pause
Exit

and another problem has come up, it wnt extract the file, this is the problem i keep on getting:

Quote
I edited that script cuz one part didnt work

What part?

You have got the IF ... ELSE wrong.

Read this

http://www.robvanderwoude.com/ntif.html

Next, that file path looks very odd to me. %0 is the batch's own name, so what is it doing in the path?
Its there because this will be distributed to other people and they might not have it on the same directory as i used for the testing stage. Plus im using the "IF" command so it goes with it to test for existence and the file is on my desktop. It worked before and i dunno why it wont work now. Im using this website as reference http://www.ss64.com/nt/index.html .

Edit: NVM i solved the problem for that error, the file with the wrong extension was in the directory as the batch file. Now can you help me to make a menu for it? I want it to have options so if i press a certain number it will go to a specific function.

Also im using windows vista that it why i had to refer to a different version of the "If" command.
Read my post again. %0 is nonsense in a path. it is the batch files own name (extract.bat) which is nonsense in a file path to the cab file!

Where is the cab file to be located?

Re your IF usage reference, read this again

Quote
IF [NOT] EXIST filename (command) ELSE (command)

Do you see the parentheses?
I see your point and i removed "0", but the "IF" command works fine now man, if i use the one you just posted i just have to make the commands the opposite but thats not my problem anymore. Im trying to find a way to implement a menu. Can anyone help me with this?

echo MENU
echo 1. Play with cat
echo 2. EAT Dinner
echo 3. Go Out
echo 4. Sleep
set /p choice=What do you want to do?
if "%choice%"=="1" goto play
(etc)

:play
(commands)
goto end
:eat
(commands)
goto end

(etc)

:end



Discussion

No Comment Found