问题
I'll show you what I have then try to explain the question,
@echo off
Echo put search in front of a question to search for the answer on the internet
Set /p question=
That's it so far, if the user puts search I front of a question it searches the Internet, I would like it so it is in one batch file as well. Thanks
回答1:
If you just want to open the default web browser, it's as simple as using start
.
This snippet will check to see if your question variable contains "search:" by replacing "search:" and comparing against the original. If they match, search wasn't entered.
@setlocal enableextensions enabledelayedexpansion
set /p question=
set questionWOspaces=%question: =+%
IF NOT "%question:search:=%"=="%question%" (START http://www.google.com/search?q="%questionWOspaces:search:=%")
回答2:
Try this
cd C:\Program Files\Internet Explorer
iexplore http://www.google.pt/search?q=%search%+site:https://stackoverflow.com/
or simple
START "" "http://www.google.com/search?q=%*"
Also look at this POST & this POST
help full links
Batch File Commands
Start a program, command or batch script (opens in a new window.)
来源:https://stackoverflow.com/questions/30142502/batch-can-i-open-a-url-from-a-batch-script