comb
comb

Reputation: 473

Open a URL without using a browser from a batch file

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

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

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.

Upvotes: 36

Views: 180928

Answers (8)

Hack1
Hack1

Reputation: 3

The perfect solution with curl

curl www.google.com

Upvotes: -1

Fengzmg
Fengzmg

Reputation: 768

Not sure whether you have already gotten your owner solution. I have been using the following powshell command to achieve it:

powershell.exe -noprofile -command "Invoke-WebRequest -Uri http://your_url"

Upvotes: 15

Bhoopesh Agrawal
Bhoopesh Agrawal

Reputation: 31

You can use this command:

start /min iexplore http://www.google.com

With the use of /min, it will hit on the URL without opening in the browser.

Upvotes: 2

Morgan
Morgan

Reputation: 25

You can try put in a shortcut to the site and tell the .bat file to open that.

start Google.HTML
exit

Upvotes: -4

Shuvankar Sarkar
Shuvankar Sarkar

Reputation: 409

You can use the HH command to open any website.

hh <http://url>

For example,

hh http://shuvankar.com

Though it will not open the website in the browser, but this will open the website in an HTML help window.

Upvotes: 17

npocmaka
npocmaka

Reputation: 57252

Try winhttpjs.bat. It uses a winhttp request object that should be faster than
Msxml2.XMLHTTP as there isn't any DOM parsing of the response. It is capable to do requests with body and all HTTP methods.

call winhttpjs.bat  http://somelink.com/something.html -saveTo c:\something.html

Upvotes: 5

Jakub Kotowski
Jakub Kotowski

Reputation: 7571

You can use Wget or cURL, see How to download files from command line in Windows like wget or curl.

You will then do e.g.:

wget www.google.com

Upvotes: 17

MC ND
MC ND

Reputation: 70923

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);

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.

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.

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.

Upvotes: 42

Related Questions