从批处理文件中打开 URL 而不使用浏览器 [英] Open a URL without using a browser from a batch file

查看:54
本文介绍了从批处理文件中打开 URL 而不使用浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开一个特定的 URL,而不直接使用批处理文件直接打开浏览器.我知道我可以使用类似的东西:

I want to open a particular URL without directly opening the browser using only a batch file. I know I can use something like:

START www.google.com

但是我想在不使用浏览器的情况下打开一个 URL.这可能吗?

But I want to open a URL without using a browser. Is this possible?

原因是我必须打开大约 30 个 URL,而且我不希望用户在他/她的电脑上打开大约 30 个标签.

The reason is that I have to open like 30 URLs, and I don't want the user to have like 30 tabs opened on his/her pc.

推荐答案

如果您只想请求 URL 并且需要从批处理文件中完成,而无需操作系统之外的任何东西,这可以帮助您:

If all you want is to request the URL and if it needs to be done from batch file, without anything outside of the OS, this can help you:

@if (@This==@IsBatch) @then
@echo off
rem **** batch zone *********************************************************

    setlocal enableextensions disabledelayedexpansion

    rem The batch file will delegate all the work to the script engine
    if not "%~1"=="" (
        wscript //E:JScript "%~dpnx0" %1
    )

    rem End of batch file area. Ensure the batch file ends execution
    rem before reaching the JavaScript zone
    exit /b

@end


// **** JavaScript zone *****************************************************
// Instantiate the needed component to make URL queries
var http = WScript.CreateObject('Msxml2.XMLHTTP.6.0');

// Retrieve the URL parameter
var url = WScript.Arguments.Item(0)

// Make the request

http.open("GET", url, false);
http.send();

// All done. Exit
WScript.Quit(0);

它只是一个混合批处理/JavaScript 文件,保存为 callurl.cmd 并称为 callurl "http://www.google.es".它会做你所要求的.没有错误检查,没有帖子,只是一个骨架.

It is just a hybrid batch/JavaScript file and is saved as callurl.cmd and called as callurl "http://www.google.es". It will do what you ask for. No error check, no post, just a skeleton.

如果可以使用操作系统之外的东西,wgetcurl 可用作 Windows 可执行文件,并且是可用的最佳选择.

If it is possible to use something outside of the OS, wget or curl are available as Windows executables and are the best options available.

如果您受到某种安全策略的限制,您可以获取 Internet 信息服务 (IIS) 6.0 资源工具包工具.它包括 tinygetwfetch 工具,可以满足您的需求.

If you are limited by some kind of security policy, you can get the Internet Information Services (IIS) 6.0 Resource Kit Tools. It includes tinyget and wfetch tools that can do what you need.

这篇关于从批处理文件中打开 URL 而不使用浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆