How can I open Google Chrome via command-line with a URL, in incognito mode?
When launching Chrome from the Windows command line I can pass arguments like so:
...>chrome.exe -incognito
I can also pass a URL to open:
...>chrome.exe google.com
Each work fine on their own, but I can't get them to work together.
What I want is to launch it with a URL, and open in its own tab, and hide the URL, buttons, etc., like a utility window, but I do want it resizable.
You might want to try and give it another try. I just tried it with the following command
chrome.exe google.com -incognito
This gave me the following window, notice that it is in incognito mode (little icon on top left) and it is also at google.com (or whatever url you pass). It works, maybe you were just typing it in wrong.
If you have a window open Chrome will default to the currently running application and add a new tab to that, it saves time (of app startup) and memory. In this case, try
chrome.exe -incognito --app=google.com
I had the same issues trying to open an incognito browser to a specific page. Here's how I got it working:
chrome.exe -incognito --new-window mytargetpage.com
Note: This answer doesn't address wanting to open a URL in incognito mode.
FWIW, here is the Mac version, you can put this in your .bash_profile file:
# Launch Chrome with given URL from command line
alias url='open -a "Google Chrome.app"'
Run the following command for it to take effect:
. ~/.bash_profile
Usage:
url http://www.twitter.com
Note: Yes, you have to put "http://" in front of it. Otherwise, it thinks you're passing in a file.
Here's a shell function that defaults to http:
in the absence of a protocol specifier:
url() {
url=$([[ $1 =~ ^[a-zA-Z]{1,}: ]] && printf '%s\n' "$1" || printf '%s\n' "http://$1")
open -a 'Google Chrome' "$url"
}
In Windows command prompt, try the following commands:
start chrome --incognito "http://www.iot.qa/2018/02/narrowband-iot.html"
or
start chrome --new-window --incognito "http://www.iot.qa/2018/02/narrowband-iot.html"
If you want to google search rather than a url save this into a batch file called google.bat:
start "google" "c:\program files (x86)\Google\Chrome\Application\chrome.exe" "https://www.google.co.uk/?q=%*#safe=off&q=%*&*"
Then you can call it by typing google search for some text
on the command line (or Run window in Windows)
Other switches that are useful are
-
--incognito
starts the window as an incognito one -
--profile-directory="Default"
will make the window open as the default chrome user*
Using both of these options gives us this batch file:
start "google" "c:\program files (x86)\Google\Chrome\Application\chrome.exe" --incognito --profile-directory="Default" --new-window "https://www.google.co.uk/?q=%str%#safe=off&q=%str%&*"
*(for other user directories use the directory, e.g. --profile-directory="Profile 2"
, check the "C:\Users\\AppData\Local\Google\Chrome\User Data" directory (Windows only solution))