@echo Off
color FC
:chooseBrowswer
echo Firefox = f
echo Internet Explorer = i
echo Googel Chrome = g
set /p browser ="Hey, %username% choose a browser."
if "%browser%"=="f" goto firefox
if "%browser%"=="i" goto internetexplorer
if "%browser%"=="g" goto googlechrome
:firefox
%browser% = "firefox.exe"
goto choice
:internetexplorer
%browser% = "iexplore.exe"
goto choice
:googlechrome
%broswer% = "chrome.exe"
goto choice
:choice
cls
echo Google = g
echo Facebook = f
echo Gmail = m
echo Statebank = s
echo.
set /p choice="Hello, %username%, what would you like to do?"
if "%choice%"=="g" goto google
if "%choice%"=="f" goto Facebook
if "%choice%"=="m" goto Gmail
if "%choice%"== "s" goto StateBank
if "%choice%"=="G" goto Google
if "%choice%"=="F" goto Facebook
if "%choice%"=="M" goto Gmail
if "%choice%"=="S" goto StateBank
goto errorchoice
:google
cls
start %browser% http://www.google.com
goto exit
:Facebook
cls
start %browser% url
goto exit
:Gmail
cls
start %browser% url
goto exit
:StateBank
cls
start %browser% http://www.statebt.com
goto exit
:errorchoice
cls
echo %choice% is not a valid option!
ping -n 5 127.0.0.1 >nul
goto choice
:exit
cls
exit
why doesnt this one work?
Moderator: DosItHelp
Re: why doesnt this one work?
Code: Select all
%browser% = "iexplore.exe"
%variable% just gets the value of the variable. And if the variable isn't defined, that value is nothing. So that line is equavillant to this line:
Code: Select all
= "iexplore.exe"
And you also don't want to use quotes. You define a variable with SET. So you want to use:
Code: Select all
set browser=iexplore.exe
-
- Posts: 20
- Joined: 30 May 2011 18:44
Re: why doesnt this one work?
would you say set %browser% = iexplore.exe
or set browser = iexplore.exe
?
or set browser = iexplore.exe
?
-
- Posts: 20
- Joined: 30 May 2011 18:44
Re: why doesnt this one work?
still doesnt work
Code: Select all
@echo Off
color FC
:chooseBrowswer
echo Firefox = f
echo Internet Explorer = i
echo Google Chrome = g
echo.
set /p browser="Hey, %username% choose a browser."
if "%browser%"=="f" goto firefox
if "%browser%"=="i" goto internetexplorer
if "%browser%"=="g" goto googlechrome
:firefox
set browser=firefox.exe
goto choice
:internetexplorer
set browser=iexplore.exe
goto choice
:googlechrome
set browser=chrome.exe
goto choice
:choice
cls
echo Google = g
echo Facebook = f
echo Gmail = m
echo Statebank = s
echo.
set /p choice="Hello, %username%, what would you like to do?"
if "%choice%"=="g" goto google
if "%choice%"=="f" goto Facebook
if "%choice%"=="m" goto Gmail
if "%choice%"== "s" goto StateBank
if "%choice%"=="G" goto Google
if "%choice%"=="F" goto Facebook
if "%choice%"=="M" goto Gmail
if "%choice%"=="S" goto StateBank
goto errorchoice
:google
cls
start %browser% http://www.google.com
goto exit
:Facebook
cls
start %browser% http://www.facebook.com
goto exit
:Gmail
cls
start %browser% http://www.gmail.com
goto exit
:StateBank
cls
start %browser% http://www.statebt.com
goto exit
:errorchoice
cls
echo %choice% is not a valid option!
ping -n 5 127.0.0.1 >nul
goto choice
:exit
cls
exit
-
- Posts: 20
- Joined: 30 May 2011 18:44
Re: why doesnt this one work?
nevermind i got it
Code: Select all
@echo Off
color FC
:chooseBrowswer
echo Firefox = f
echo Internet Explorer = i
echo Google Chrome = g
echo.
set /p browser="Hey, %username% choose a browser."
if "%browser%"=="f" goto firefox
if "%browser%"=="i" goto internetexplorer
if "%browser%"=="g" goto googlechrome
:firefox
set browser=firefox.exe
goto choice
:internetexplorer
set browser=iexplore.exe
goto choice
:googlechrome
set browser=C:\Users\Paul\AppData\Local\Google\Chrome\Application\chrome.exe
goto choice
:choice
cls
echo Google = g
echo Facebook = f
echo Gmail = m
echo Statebank = s
echo.
set /p choice="Hello, %username%, what would you like to do?"
if "%choice%"=="g" goto google
if "%choice%"=="f" goto Facebook
if "%choice%"=="m" goto Gmail
if "%choice%"== "s" goto StateBank
if "%choice%"=="G" goto Google
if "%choice%"=="F" goto Facebook
if "%choice%"=="M" goto Gmail
if "%choice%"=="S" goto StateBank
goto errorchoice
:google
cls
start %browser% http://www.google.com
goto exit
:Facebook
cls
start %browser% http://www.facebook.com
goto exit
:Gmail
cls
start %browser% http://www.gmail.com
goto exit
:StateBank
cls
start %browser% http://www.statebt.com
goto exit
:errorchoice
cls
echo %choice% is not a valid option!
ping -n 5 127.0.0.1 >nul
goto choice
:exit
cls
exit