问题
I would like to create a batch file that once you type something in and click enter you go to an search page on the Internet. The thing is, you type in a keyword before what you want to search. So say I wanted to search the mass of a whale or something, into my program I would type "search what is the mass of a whale" so to tell if I want to go on the Internet or not the script reads to see if the word search is in front of the question. If it is, it searches the Internet, if it isn't my program displays "Retype the command" or something. Any help would be great thanks
回答1:
You can do this with a one-liner. Save this as search.bat:
@start "" "http://www.google.com/search?q=%*"
Then in a console window, run the command:
search What is the airspeed velocity of an unladen swallow?
来源:https://stackoverflow.com/questions/30135897/how-do-you-search-the-internet-with-a-batch-script-and-a-keyword