Batch, Can I open a url from a batch script?

我是研究僧i 提交于 2020-01-06 16:01:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!