Batch file closes after a goto command - batch-file

Here's the code
#echo off
color 0a
:user_login
set /p username=What is your username?
if %username% == admin (
cls
goto admin_request_password
)
echo Incorrect username please try again.
cls
goto user_login
:admin_request_password
set /p Password=What is your Encryption Key?:
if %Password% == ecca1924889236 (
pause
cls
goto admin_menu
pause
)
echo Incorrect password
pause
cls
goto user_login
:admin_menu
echo Type acct_info for account info.
echo Type site_key for website file manager.
echo type ip_info for your ip info.
echo Type close to close the Net-Sec portal
goto admin_menu_process
:admin_menu_process
set /a choice=Waiting for Request:
if %choice% == acct_info (
cls
goto acct_info ) echo Incorrect term cls goto admin_menu
if %choice% == site_key (
goto site_key )echo Incorrect term
cls
goto admin_menu
if %choice% == ip_info (
goto ip_info ) echo Incorrect term
cls
goto admin_menu
if %choice% == close (
goto close ) echo Incorrect term
cls
goto admin_menu
:ip_info
ipconfig
pause
cls
goto admin_menu
:acct_info
echo Your username is: admin
echo your password is: ecca1924889236
pause
cls
goto admin_menu
:site_info
The username is: net-sec
The password is: netsec127
pause
cls
goto admin_menu
:close
cls

Suggestions:
Do not set a variable to %username% as that is already an existing system variable.
Enclose both strings with double quotes in a string comparison.
Use the choice command when you have a known set of choices.
Try not to include unnecessary labels.
Here is a rewrite of your code to hopefully help you in your scripting exploits:
#Echo Off
Color 0A
:getName
ClS
Set/P "uname=What is your username? "
If /I Not "%uname%"=="admin" (Echo Incorrect username please try again.
>Nul Timeout 3
GoTo getName)
:getPass
ClS
Set/P "password=What is your encryption key? "
If Not "%password%"=="ecca1924889236" (Echo Incorrect password please try again.
>Nul Timeout 3
GoTo getPass)
:menu
ClS
Echo [1] Account information.
Echo [2] Website File Manager.
Echo [3] IP information.
Echo [4] Close the Net-Sec portal.
Choice /C 1234 /M "Enter your request"
If ErrorLevel 4 GoTo close
If ErrorLevel 3 GoTo ip_info
If ErrorLevel 2 GoTo site_info
If ErrorLevel 1 GoTo acct_info
GoTo :EOF
:acct_info
Echo Your username is: admin
Echo your password is: ecca1924889236
Timeout 3
GoTo menu
:site_info
Echo The username is: net-sec
Echo The password is: netsec127
Timeout 3
GoTo menu
:ip_info
IPConfig
Timeout -1
GoTo menu
:close
ClS
Echo Closing...
Timeout 3

Related

I'm trying to create an admin "login" on batch and it just closes the cmd

I am trying to make an "admin" login and it isn't working.
#echo off
title RPG BETA
color 0b
set /p player=Welcome to Xero, what's your name?:
if %player% == Admin goto admin
:intro
echo Hello %player%!
pause
goto start
:admin
set /p password:What is the admin password?:
if %password% == Insertanypassword goto true
if %password not insertanypassword goto false
:true
cls
echo Welcome, Admin!
set /p af=Would you like to enable admin features?[y/n]:
if %af% == y goto true1
if %af% == n goto start
:true1
cls
set CPU=20
set CPUN=Scorpion
set CPUD=3
set gun=9999999
set gund=9999999
set playerh=9999999
goto fight
:start
cls
echo In the distant future, the world was on the brink of destrucion.
timeout 3 >nul
echo In the midst of the wasteland, a single man, named %player%, will overcome the odds
pause
goto BFight
:BFight
cls
set CPU=20
set CPUN=Scorpion
set CPUD=3
set gun=1
set gund=10
set playerh=20
:Fight
cls
if %CPU% leq 0 goto win
if %playerh% == 0 goto lose
cls
echo You encounter a %CPUN%!
echo %CPUN% Health: %CPU%
echo.
echo Your Health: %playerh%
echo [1]Shoot (%gund% damage) (%gun%)
echo [2]Punch (3 damage)
echo [3]Flee
set /p fp=What do you do?
if %fp% == 1 goto gun
if %fp% == 2 goto punch
if %fp% == 3 goto flee
:gun
cls
if '%gun%'=='0' goto egun
set /a gun = gun - 1
echo You fire at the %CPUN%
timeout 4 >nul
echo It hits!
set /a CPU = CPU - gund
pause
goto cpufightp
:punch
cls
echo You punch the %CPUN%
timeout 4 >nul
echo It hits!
set /a CPU = CPU - 3
pause
goto cpufightp
:egun
echo You have no bullets!
pause
goto Fight
:cpufightp
if %CPU% leq 0 goto win
cls
echo %CPUN% Health: %CPU%
echo.
echo Your Health: %playerh%
pause
cls
goto cpufight
:cpufight
cls
echo The %CPUN% Attacks!
timeout 4 >nul
echo It hits!
set /a playerh = playerh - CPUD
pause
goto fight
:flee
goto losef
:losef
cls echo you have fled
pause
goto suggestion
:lose
cls
echo You died
pause
cls
:win
cls
echo Congradulations, %player%! You win!
pause
cls
:suggestion
set /p suggest=What should I add to Xero?:
echo %player%: %suggest% >> xerosuggest.word
Whenever I type in "Admin" instead of going to the password screen, it just closes cmd, can anyone tell me why? i have experimented with ''s and other commands but I just can't figure it out.
The problem with respect to your specific issue is a typo.
You have:
set /p password:What is the admin password?:
Instead of:
Set /P "password=What is the admin password?: "
The doublequotes are simply good practice, your error was quite clearly that you used a : instead of a =.

CMD - Input from another cmd

I have one cmd where you do a choice (1 for login, 2 for register, ...) and then you enter the user, and password (set /p user="User: " , set /p password="Password: ") and what I want to do is enter the choice, username and password with another batch file that I make...
What I tried:
#echo off
title Wizzard-Cracker
color a
cd C:\Users\Wolfy\Documents\Wolfy\Subory .BAT\Wizzard
:A
start wizzard.cmd /K set choice=1 & set user=wolfy & set password=sombest
Login Batch:
#echo off
title Login and Register
color F
setlocal enableDelayedExpansion
:A
echo [Login and Register]
echo [1.][Login]
echo [2.][Register]
echo [3.][Exit]
set /p input="Choose: "
if "%input%"=="1" (
cls
goto login
)
if "%input%"=="2" (
cls
goto register
)
if "%input%"=="3" (
cls
exit
)
:login
echo [Login]
set /p user=User:
echo.
set /p password=Password:
echo.
if NOT EXIST data/%user%.userfile (
echo User %user% isn't registered.
ping localhost -n 2 >nul
cls
goto login
)
set /p correct=<data/%user%.userfile
set chars=0123456789abcdefghijklmnopqrstuvwxyz
for /L %%N in (10 1 36) do (
for /F %%C in ("!chars:~%%N,1!") do (
set "correct=!correct:-%%N=%%C!"
)
)
if "%password% "=="!correct!" (
echo Login successful.
ping localhost -n 2 >nul
cls
goto console
) else (
echo Incorrect password entered.
ping localhost -n 2 >nul
cls
goto login
)
:register
echo [Register]
set /p rUser=Register User:
echo.
set /p rPassword=Register Password:
echo.
if EXIST data/%rUser%.userfile (
echo User is already registered.
goto register.choice
)
set chars=0123456789abcdefghijklmnopqrstuvwxyz
for /L %%N in (10 1 36) do (
for /F %%C in ("!chars:~%%N,1!") do (
set "rPassword=!rPassword:%%C=-%%N!"
)
)
echo !rPassword! > data/%rUser%.userfile
echo Registration was successful!
ping localhost -n 2 >nul
cls
goto A
:register.choice
set /p choice="Go to Login [Y/N]: "
if %choice%==y (
cls
goto login
)
if %choice%==Y (
cls
goto login
)
if %choice%==n (
cls
goto register
)
if %choice%==N (
cls
goto register
)
How do I do that?
Here's a quick rewrite, there may be errors or things you would prefer not to change but it should show you a way of doing it.
#ECHO OFF
TITLE Login and Register
COLOR F
SETLOCAL ENABLEDELAYEDEXPANSION
IF "%~1" NEQ "1" (GOTO :A) ELSE (IF "%2" EQU "" (GOTO :A) ELSE (SET "user=%~2"
IF "%~3" EQU "" (SET password=)
GOTO :vlog))
:A
CLS
ECHO [Login and Register]
ECHO [1.][Login]
ECHO [2.][Register]
ECHO [3.][Exit]
CHOICE /C 123 /N
IF ERRORLEVEL 3 EXIT/B
IF ERRORLEVEL 2 GOTO :register
:login
CLS
ECHO [Login]
SET /P user=User:
IF NOT DEFINED user GOTO :login
:vlog
IF "%user:*=%" NEQ "%user%" GOTO :login
IF NOT EXIST data/%user%.userfile (
ECHO User %user% isn't registered.
TIMEOUT 2 >NUL
GOTO :login
)
:pass
SET /P correct=<data/%user%.userfile
ECHO.
IF NOT DEFINED password (
SET /P password=Password:
)
IF NOT DEFINED password GOTO :pass
SET chars=0123456789abcdefghijklmnopqrstuvwxyz
FOR /L %%N IN (10 1 36) DO (
FOR %%C IN (!chars:~%%N,1!) DO (
SET "correct=!correct:-%%N=%%C!"
)
)
IF "%password%"=="%correct%" (
ECHO.
ECHO Login successful.
TIMEOUT 2 >NUL
GOTO :console
)
ECHO Incorrect password entered.
TIMEOUT 2 >NUL
GOTO :pass
:register
CLS
ECHO [Register]
SET /P rUser=Register User:
IF NOT DEFINED rUser GOTO :register
IF "%rUser:*=%" NEQ "%rUser%" GOTO :register
IF EXIST data/%rUser%.userfile (
ECHO.
ECHO User is already registered.
GOTO :register.choice
)
:rpass
SET /P rPassword=Register Password:
IF NOT DEFINED rPassword GOTO :rpass
SET chars=0123456789abcdefghijklmnopqrstuvwxyz
FOR /L %%N IN (10 1 36) DO (
FOR %%C IN (!chars:~%%N,1!) DO (
SET "rPassword=!rPassword:%%C=-%%N=!"
)
)
>data/%rUser%.userfile ECHO %rPassword%
ECHO.
ECHO Registration was successful!
TIMEOUT 2 >NUL
GOTO :A
:register.choice
ECHO.
CHOICE /C YN /M "Go to Login"
IF ERRORLEVEL 2 GOTO :register
GOTO :login
:console
REM Section is Missing
You should be able to run it in one of these ways, depending upon your requirements:
"X:\SomePathTo\wizzard.cmd" 1 wolfy sombest
start "" "X:\SomePathTo\wizzard.cmd" 1 wolfy sombest
call "X:\SomePathTo\wizzard.cmd" 1 wolfy sombest
Of course if you cannot change the actual wizzard.cmd script then I'm afraid that you have no way of bypassing the prompts' which should, after all, only waste a couple of seconds of your precious time.
instead of set /p correct = <C:\file , get rid of the p and type set correct =<C:\file
Why would you use a different batch file? But however, if you want to parse data between to batch instances, make use of command line arguments. A simple google to that gives you a clear explanation. But be carefull. Batch files are not safe to use passwords. You have to learn programming for that. VB.net is an example language which is easy to learn

goto unexpected at this time error for game test

When I run this, it keeps saying "goto" unexpected at this time. I have tried to solve the issue, but it won't work.
Here is the code:
#echo off
color 0a
title TEST FOR HACK SIM
:menu
ECHO what do you want to test?
echo.
echo -open disk
echo -save save
echo -open save
echo.
echo.
set /p choice= choose one:
if %choice% == "open disk" goto disk
if %choice% == "open save" goto saveo
if %choice% == "save save" goto saves
:disk
call D:\
echo did it work!?
goto menu
:saveo
cls
pause
(
set /p save=
)<C:\Users\%username%\Searches\savefiles.txt
echo %save%
pause
goto menu
:saves
set /p fun= what number do you want?>
(
echo %fun%
)>C:\Users\%username%\Searches\savefiles.txt

Batch File path vairiable %PATH%

I have been creating a chat room for my school, but I have to bring home the file to make changes as they become needed but my problem is the file path has to be changed each time I move the files from one system to another. so I would like to know how to create a %PATH% that will work for me
This is my full code for the main file:
As you may notice I'm new to this
NOTE: Everything here works fine with a set file path but I want it to work easier for when I change computers.
Anything could probably help
#echo off
:Tittle
cls
color 74
title Terms of Service
echo _________________________-Terms-______________________________
echo If you are using this ChatRoom then you agree to the following.
echo *you will not use Horrid Language
echo *you will make your account with either your real name or
echo Student id
echo.
echo This is monitored everyday so if anything is out of line it will be removed.
echo.
echo If you agree to follow these terms then type "yes" otherwise exit.
set /p c=Do you Agree to follow the terms?:
if %c% EQU yes goto Menu
if %c% EQU ADMIN1423 goto Admin
if %c% EQU dad goto Menu
if %c% EQU carrie goto Menu
if %c% EQU dad SET PATH=%PATH%;c:\Users\Dan W Frye\Desktop\(-_-)
:Admin
color 02
cls
Echo
Echo.
Echo 1.) Check User list
Echo.
Echo 2.) Create File Path
Echo.
Echo 3.) Admin Help
Echo.
echo 4.) N/A
echo.
Echo
set /p c=Selection Number:
if %c% EQU 1 goto UserList
if %c% EQU 2 goto CreatePath
if %c% EQU 3 goto AdminHelp
if %c% EQU 4 goto Admin
if %c% EQU back goto Tittle
:UserList
color 0b
cls
title User Listing
cls
start cmd
CALL "%PATH%\Data\Chat Settings\Users\BuAsTeCrHs.bat"
pause
goto Admin
:CreatePath
cls
color 01
echo
echo.
echo The File Path Must look like this(No " "): "Driver (C:)"\Containing folder" thats it the echo rest is automatically "\Data\Chat Settings\Users\....."
echo.
echo
echo.
echo The File Path you want to create.
set /p PATH=File Path:
echo.
echo The Location/Device you are using.
set /p LOC=Location:
echo.
echo %PATH% >>"%PATH%\Data\Chat Settings\File Paths\%LOC%.txt"
echo The file path has been created!
pause
goto Admin
:AdminHelp
pause
goto Tittle
:Menu
color 0b
cls
Echo -[ChatBox]-
Echo
Echo.
Echo 1.) Login
Echo.
Echo 2.) Register
Echo.
Echo 3.) Exit
Echo.
echo 4.) Help
echo.
Echo
Echo.
set /p c=Selection Number:
if %c% EQU 1 goto Login
if %c% EQU 2 goto Register
if %c% EQU 3 exit
if %c% EQU 4 goto help
if %c% EQU 5 goto Terms
:help
cls
echo if you are not able to see the chat log then you must not have
echo the file "Chatroom_reader.bat" open without this you cannot see
echo messages sent by other users.
echo.
echo if you have suggestions or comments then please type "comment"
echo.
echo if you need assistance with any other problem you may have
echo encountered then please type "other" to let the developer know
echo what the problem is. otherwise type "back" to go back to the menu.
set /p c=Option:
if %c% EQU comment goto comments
if %c% EQU other goto other
if %c% EQU back goto menu
:comments
cls
title Comments
echo Enter your Username, and Password to Place a Comment
echo.
set /p UN=Username:
echo.
set /p PW=Password:
echo.
if NOT Exist "%PATH%\Data\Chat Settings\Users\%UN%.txt" Goto Failed
echo %PW% >"%tmp%\chat.tmp"
fc "%tmp%\chat.tmp" "%PATH%\Data\Chat Settings\Users\%UN%.txt" >nul
if errorlevel==1 goto Failed
if errorlevel==0 goto Comment
:Comment
cls
echo.
set /p SUBJECT=Subject:
echo.
set /p COMMENT=Comment:
echo.
echo %SUBJECT% : %COMMENT% >"%PATH%\Data\Chat Settings\Comments\%UN%.txt"
goto User
:other
cls
title Other
echo Enter your Username, and Password to Place a Comment
echo.
set /p UN=Username:
echo.
set /p PW=Password:
echo.
if NOT Exist "C:\Users\Dan W Frye\Desktop\(-_-)\Data\Chat Settings\Users\%UN%.txt" Goto Failed
echo %PW% >"%tmp%\chat.tmp"
fc "%tmp%\chat.tmp" "C:\Users\Dan W Frye\Desktop\(-_-)\Data\Chat Settings\Users\%UN%.txt" >nul
if errorlevel==1 goto Failed
if errorlevel==0 goto OtherA
:OtherA
cls
set /p OTHERC=Other Concern:
echo.
echo %OTHERC% >"%PATH%\Data\Chat Settings\Other\%UN%.txt"
goto User
:Login
cls
echo Enter your Username, and Password to login to the Chat Server
echo.
set /p UN=Username:
echo.
set /p PW=Password:
echo.
if NOT Exist "%PATH%\Data\Chat Settings\Users\%UN%.txt" Goto Failed
echo %PW% >"%tmp%\chat.tmp"
fc "%tmp%\chat.tmp" "%PATH%\Data\Chat Settings\Users\%UN%.txt" >nul
if errorlevel==1 goto Failed
if errorlevel==0 goto User
:User
cls
Echo Welcome %UN% The Current date is %date%
echo
echo.
echo 1.) Chat
echo.
echo 2.) Logout
echo.
echo 3.) Change Password
echo.
echo 4.) Private Chat
echo.
echo 5.) Enter a Private Chat room
echo.
echo
set /p c=Selection Number:
if %c% EQU 1 goto chat
if %c% EQU 2 goto Menu
if %c% EQU 3 goto CHP
if %c% EQU 4 goto PRIVATE
if %c% EQU 5 goto PRIVATENTER
:PRIVATENTER
echo Please enter the name of the Private chat room if you do not know the name you may not enter.
set /p Chat=
if %Chat% EQU scooter goto scooter
if %Chat% EQU Cre-Br goto Cre-Br
:Cre-Br
cls
set name=[%time%]%UN%
cls
color 02
echo Last Message sent by %UN% \/
echo [%time%]%UN%:%text%
set /p text=Say:
echo %name% : %text% >>"%PATH%\Data\Chat Settings\Program_Files\Cre-Br.txt"
goto Cre-Br
:scooter
cls
echo %Chat%
set name=[%time%]%UN%
color 02
echo Last Message sent by %UN% \/
echo [%time%]%UN%:%text%
set /p text=Say:
echo %name% : %text% >>"%PATH%\Data\Chat Settings\Program_Files\scooter.txt"
goto scooter
:PRIVATE
cls
set /p Chat=Chat Name:
echo this is %UN%s Private chat room >>"%PATH%\Data\Chat Settings\Program_Files\%Chat%.txt"
echo.
echo #echo off >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat"
echo color 0b >>"%PATH%H:\(-_-)\Data\Chat Settings\Private Chats\%Chat%.bat"
echo cls >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat"
echo title Message Box >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat"
echo :home >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat"
echo cls >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat"
echo findstr /v "g91dhjt637hsuexv27niw9" "%PATH%\Data\Chat Settings\Program_Files\%Chat%.txt" >>"C:\Users\Dan W Frye\Desktop\Batch\Chat Settings\Private Chats\%Chat%.bat"
echo goto home >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat"
goto User
:CHP
cls
set /p PW=Old Password:
echo.
set /p NP=New Password:
echo %NP% >"%PATH%\Data\Chat Settings\Users\%UN%.txt
goto User
:Register
cls
color 07
echo Register (Note the username is your screen name Please use your real name or School ID EX, CaBu56789)
echo.
set /p NU=Username:
echo.
set /p NP=Password:
echo.
echo %NP% >"%PATH%\Data\Chat Settings\Users\%NU%.txt"
echo.
cls
goto login
:Failed
color 0c
cls
echo You have entered am invalid Username and or Password
echo Please try again or Register for free
pause
goto menu
:chat
set name=[%time%]%UN%
cls
color 02
echo Everything said here is on recored please mind your
echo language!
echo Last Message sent by %UN% \/
echo [%time%]%UN%:%text%
set /p text=Say:
echo %name% : %text% >>"%PATH%\Data\Chat Settings\Program_Files\ChatRoom.txt"
goto chat
%PATH% is reserved environment variable, documented here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/path.mspx?mfr=true
For diagnostics purposes you could echo that variable to analyze if that has such value you intended to have:
echo %path%
As mentioned by #Jermu Virtanen the %PATH% variable is a windows system set path...you should not use/change it unless you really know what you are doing.
So instead of using %PATH% use something like %PROGPATH%.
Also as mentioned by #foxdrive, if the user enters "dad" it will go to "menu" before setting the path variable. And again if you instead chose 'Admin' then to 'List users' it will again be calling the path without first setting it.
You could automate some of the login or path settings by grabbing the computer's domain name %userdomain% and current user %username%.
Ie;
SET "progpath=c:\Users\%username%\Desktop\(-_-)"
In your code the path was being set after it had already branched to the menu. This may work for you:
if %c% EQU carrie goto Menu
if %c% EQU dad SET PATH=%PATH%;c:\Users\Dan W Frye\Desktop\(-_-)& goto menu
To put the batch file on the path for every user, use this:
set path=%path%;%PUBLIC%
and copy the batch file to C:\Users\Public and run it from there.
Unless it needs extra permissions it should run from there for every user.

batch command input menu

i have a question . It is possible to make a batch menu to accept multiple commands at the same time?
Example : ( my code )
#ECHO OFF
set tries=6
:top
cls
set /a tries=%tries% -1
if %tries%==0 (
goto penalty
)
Echo You have %tries% attempts left.
Echo Please enter your password to proceed
set /p password=
if %password%==Parola ta (
echo Welcome Your Name
ping localhost -n 5 >nul
cls
Echo CONNECTED!
C:
CD\
CLS
:MENU
CLS
ECHO ============= MENU NAME =============
ECHO -------------------------------------
ECHO 1. System Information TXT file
ECHO 2. Selection 2
ECHO 3. Selection 3
ECHO 4. Selection 4
ECHO 5. Selection 5
ECHO 6. Selection 6
ECHO 7. Selection 7
ECHO -------------------------------------
ECHO 8. Selection 8
ECHO -------------------------------------
ECHO 9. Selection 9
ECHO -------------------------------------
ECHO ==========PRESS 'Q' TO QUIT==========
ECHO.
SET INPUT=
SET /P INPUT=Please select a number:
IF /I '%INPUT%'=='1' GOTO Selection1
IF /I '%INPUT%'=='2' GOTO Selection2
IF /I '%INPUT%'=='3' GOTO Selection3
IF /I '%INPUT%'=='4' GOTO Selection4
IF /I '%INPUT%'=='5' GOTO Selection5
IF /I '%INPUT%'=='6' GOTO Selection6
IF /I '%INPUT%'=='7' GOTO Selection7
IF /I '%INPUT%'=='8' GOTO Selection8
IF /I '%INPUT%'=='9' GOTO Selection9
IF /I '%INPUT%'=='Q' GOTO Quit
CLS
ECHO ============INVALID INPUT============
ECHO -------------------------------------
ECHO Please select a number from the Main
echo Menu [1-9] or select 'Q' to quit.
ECHO -------------------------------------
ECHO ======PRESS ANY KEY TO CONTINUE======
PAUSE > NUL
GOTO MENU
:Selection1
systeminfo.exe>systeminfo.txt
ECHO ============INVALID INPUT============
ECHO -------------------------------------
ECHO Please select a number from the Main
echo Menu [1-9] or select 'Q' to quit.
ECHO -------------------------------------
ECHO ======PRESS ANY KEY TO CONTINUE======
PAUSE > NUL
GOTO MENU
:Selection2
Call cleanup.bat
:Selection3
and in here too...
:Selection4
and so on
:Selection5
and so on
:Selection6
and so on
:Selection7
and so on
:Selection8
and so on
:Selection9
and so on
:Quit
CLS
ECHO ==============THANKYOU===============
ECHO -------------------------------------
ECHO ======PRESS ANY KEY TO CONTINUE======
PAUSE>NUL
EXIT
pause
cls
) else (
goto top
)
goto top
How to make the program accept more than 1 command?
For example 1,3,5 to execute in the same time?
or another question, how its possible to undo .exe back to .bat?
there such a program?
Suggestion: make call from goto and concatenate the commands with &:
IF /I '%INPUT%'=='1' GOTO:Selection1
IF /I '%INPUT%'=='2' CALL:Selection2&CALL:Selection2&CALL:Selection4
IF /I '%INPUT%'=='3' CALL:Selection3&CALL:Selection3
IF /I '%INPUT%'=='4' CALL:Selection4&CALL:Selection4
IF /I '%INPUT%'=='5' CALL:Selection5
IF /I '%INPUT%'=='6' CALL:Selection6
IF /I '%INPUT%'=='7' CALL:Selection7
IF /I '%INPUT%'=='8' CALL:Selection8
IF /I '%INPUT%'=='9' CALL:Selection9
IF /I '%INPUT%'=='Q' GOTO:Quit
To get this work you must alse add goto:eof (eof=end of file) after the jump labels, eg.:
:Selection2
Call cleanup.bat
goto:eof
:Selection3
and in here too...
goto:eof
:Selection4
and so on
goto:eof
:Selection5
and so on
goto:eof
...
..
.
goto:eof returns control to the main program.
Is this what you were looking for?
File Menu.cmd
#echo off
setlocal
set quit=false
set /p InputChoices=Enter Choice(s) (A,B,C)
echo %InputChoices%
call :executeChoices %InputChoices%
endlocal
goto :eof
:executeChoices
if [%1]==[] goto :eof
call :Step%1
shift
goto :executeChoices
goto :eof
:StepA
echo Step A
goto :eof
:StepB
echo Step B
goto :eof
:StepC
echo Step C
goto :eof
Works like this:
c:\>Menu.cmd
Enter Choice(s) (A,B,C) b c a
b c a
Step B
Step C
Step A
You can use the start "" command keyword and each command will run in it's own window, but initiated by your menu batch file.

Resources