To begin with, do not use Set /P
for known user input, the Choice
command was designed just for that scenario:
Example:
@Echo Off
Echo ====================
Echo Website:
Echo ====================
%__AppDir__%choice.exe /C YG /N /M "YouTube [Y], or Google [G]?"
If ErrorLevel 2 (
Start "" "%LocalAppData%\Google\Chrome\Application\chrome.exe" "https://www.google.com"
) Else Start "" "%LocalAppData%\Google\Chrome\Application\chrome.exe" "https://www.youtube.com"
Pause
You'll note, I have used an absolute path for the Chrome executable. If you're certain that the appropriate registry setting is in place for it, you can change each instance of the command to, Start chrome.exe
, otherwise change the path to the actual location of your installed executable.
If you choose the full path route, then it may be simpler to use a variable to hold it:
@Echo Off
Set "chrome=%LocalAppData%\Google\Chrome\Application\chrome.exe"
Echo ====================
Echo Website:
Echo ====================
%__AppDir__%choice.exe /C YG /N /M "YouTube [Y], or Google [G]?"
If ErrorLevel 2 (
Start "" "%chrome%" "https://www.google.com"
) Else Start "" "%chrome%" "https://www.youtube.com"
Pause