Yes, with the start command. Example:
start http://www.google.com
That will use the user's default browser.
As stated by Joey, you should use a different format for URLs with special chars:
start "" "http://www.google.com"
Answer from Botz3000 on Stack ExchangeYes, with the start command. Example:
start http://www.google.com
That will use the user's default browser.
As stated by Joey, you should use a different format for URLs with special chars:
start "" "http://www.google.com"
you can use
start http://www.google.com
Interestingly only following combination are working for above url :
start www.google.com
start http://google.com
start http://blog.google.com
But following is not working :
start google.com
start asp.net
start blog.google.com
I think it is because in the later example google.com and asp.net are treated as files and it tries to find google.com file and gives error on not finding it.
I think it is hardcoded for www. Any better guesses ?
& is a special character in bash, so if the URL contains a special character you just have to do it like this:
start "" "your url"
You have to escape the Ampersand (&) character with the ^ character in every occurrence of it.
start https://www.google.dz/?gws_rd=cr,ssl^&ei=rXc_WYq3Msy2abGXpugH#safe=off^&q=hello+world
open url using command line | Opera forums
command line - Launching a website via the Windows commandline - Stack Overflow
KeePass / Discussion / Open Discussion: trigger CMD:// or URL:// from external command
python - How can I open url by clicking on hyperlink in CMD? - Stack Overflow
Videos
Windows
explorer "https://google.com"
Which will launch your default browser and navigate to that site.
As @RiverHeart pointed out if your URL has special characters like ? you can escape the URL like so in Windows 10+
explorer "`"https://www.google.com/search?q=hello+there"`"
MacOS
open "https://google.com"
To open a URL with the default browser, you can execute:
rundll32 url.dll,FileProtocolHandler https://www.google.com
I had issues with URL parameters with the other solutions. However, this one seemed to work correctly.
You can do it like:
firefox -new-tab "https://www.useotools.com"
OR with full path
"C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab "https://www.useotools.com"
Well at least one possible method is to modify your about:config files. See http://www.ghacks.net/2009/07/03/force-firefox-to-open-links-in-same-tab/ for details as to how to do this.
You know how sometimes the answer to the question you ask is not necessarily the answer you need? I have a vague suspicion this might be one of those times.
If this is a Windows machine you're trying to reboot, you can reboot it remotely without needing to use a CGI script served by the remote host. If the account you're logged in with on the triggering PC also has privileges on the remote PC, you can trigger the reboot with the shutdown command.
shutdown /m \\remotePC /r /t 0
Do shutdown /? in a cmd console for more info. Or if you must authenticate, you can use wmic instead.
wmic /node:remotePC /user:remotePCadmin /password:remotePCpass process call create "shutdown -r -t 0"
In case I was mistaken, here's the answer to the question you asked. The fastest way to execute a remote CGI script would be to use an XMLHTTPRequest with Windows Script Host (VBScript or JScript). Here's an example.
@if (@CodeSection == @Batch) @then
@echo off & setlocal
set "URL=http://192.168.1.100/cgi-bin/reboot"
cscript /nologo /e:jscript "%~f0" "%URL%"
goto :EOF
@end // end batch / begin JScript chimera
var x = WSH.CreateObject("Microsoft.XMLHTTP");
x.open("GET",WSH.Arguments(0),true);
x.setRequestHeader('User-Agent','XMLHTTP/1.0');
x.send('');
while (x.readyState != 4) WSH.Sleep(50);
For what it's worth, you can also parse x.responseText as needed. You can scrape it as flat text, or even evaluate it as a hierarchical DOM object. This answer demonstrates such parsing. And if you just can't get enough, here are more examples.
If you'd rather have something simpler at the expense of efficiency, you can invoke a PowerShell command.
@echo off & setlocal
set "URL=http://192.168.1.100/cgi-bin/reboot"
powershell "ipmo BitsTransfer; Start-BitsTransfer \"%URL%\" \"%temp%\a\""
del /q "%temp%\a"
goto :EOF
You could probably alternatively use Invoke-WebRequest to avoid the temporary file, but Invoke-WebRequest requires PowerShell version 3 or newer. Start-BitsTransfer works with PowerShell version 2, so it should work on more computers. One might also use the [System.Net]::WebRequest .NET class, but it gets a little complicated constructing all the objects needed to proceed beyond fetching the HTTP headers to having the web server serve the web page. If you're curious, it looks something like this:
powershell "void.GetResponse().GetResponseStream())).ReadToEnd()"
Not exactly what I'd call simple. In hybrid format for easier readability:
<# : batch portion
@echo off & setlocal
set "URL=http://192.168.1.100/cgi-bin/reboot"
powershell -noprofile "iex (${%~f0} | out-string)"
goto :EOF
: end batch / begin PowerShell hybrid chimera #>
$request = [Net.WebRequest]::Create($env:URL)
$response = $request.GetResponse()
$stream = $response.GetResponseStream()
$reader = new-object IO.StreamReader($stream)
[void]$reader.ReadToEnd()
In any case, any PowerShell solution will be a second or two slower than the JScript solution near the top of this answer. powershell.exe takes a second or two to load (indeed, several seconds if it's not been loaded since Windows was last rebooted); whereas cscript.exe fires nearly instantly.
If you cannot download anything, then Windows PowerShell is the best option. You can call it from a PS script file, or directly from the command line in a batch file:
powershell.exe -noprofile -command "Invoke-WebRequest -Uri http://192.168.1.100/cgi-bin/reboot"
You can also consider Curl for that type of process. There is no equivalent in Windows, so it will require a download.
curl http://192.168.1.100/cgi-bin/reboot
Curl will not open a browser window, and has great command line options (See curl -help), and will return error codes for batch file error handling.