A slightly late Happy New Year to everyone, hope you had a good one.
I'm trying to create a batch file that will take keyboard input and then either launch a program based on that input or display an error message if the option entered isn't valid. But it's not working. Here's what I've got so far:
ECHO OFF
set /p %environment%=Connect to Live or Dev?:
IF %environment% = "Live"
(
C:\Windows\System32\runas.exe /user:live\someuser /netonly "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"
)
ELSE IF %environment% = "Dev"
(
C:\Windows\System32\runas.exe /user:dev\someuser /netonly "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"
)
ELSE
(
ECHO "Invalid Option"
)
I've tried it with and without the % round the variable but it didn't work. Can anyone point me in the right direction?
Hope you can help.
Cheers
Alex
@echo offto see what happens: 1) look, how yourif-line is translated. 2) the(has to be on the same line than theif3)) else (has to be on one line