The first is the cmd command:
#Start Baidu website with default browser #
start www.baidu.com #Start
Google Chrome to visit Baidu #
start chrome www.baidu.com #Start
Firefox to visit Baidu #
start Firefox www.baidu.com
Now, I want to create a new bat file to execute this command.
First create a basic TXT file and copy the following text into it:
if "%1"=="" (
start Firefox https://www.huya.com
) else (
if "%2"=="" (
start Firefox https://www.huya.com/%1
) else (
start Firefox https://www.huya.com/%1/%2
)
)
Save, modify the file suffix to .bat, and then execute the command in the cmd command window (first switch to the directory where the cmd command is located (shortcut: shift + right key, open the command window here)):
Then run the cmd command:
search.bat g lol
A window will open:
Run the command:
search.bat xiaozhan
At this time, a window will open:
Now to explain the format of the bat file:
% 1 and% 2 are placeholders for storing variables,
if "% 1" == "" (
) else (
)
is a conditional statement, note Space problem, you must add spaces before and after else, otherwise it will not be recognized