why doesnt this one work?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

why doesnt this one work?

#1 Post by paul.darsey » 30 May 2011 19:53

@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

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: why doesnt this one work?

#2 Post by nitt » 30 May 2011 19:57

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

paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Re: why doesnt this one work?

#3 Post by paul.darsey » 30 May 2011 19:58

would you say set %browser% = iexplore.exe

or set browser = iexplore.exe

?

paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Re: why doesnt this one work?

#4 Post by paul.darsey » 30 May 2011 20:06

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

paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Re: why doesnt this one work?

#5 Post by paul.darsey » 30 May 2011 20:11

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

Post Reply