Suppose you are in the command line, or PowerShell, or terminal, or you have created a script where you have to open Google Chrome in privacy mode where no search history is saved and no user-protected sensitive information is captured, then you have to use Google Chrome Incognito mode or InPrivate mode features. Let's have a peek at the process for using google chrome incognito mode in the command line or Powershell.
Table of Contents
- What is Incognito Mode?
- Open Google Chrome Incognito Mode via Command Line in Windows OS
- Open Google Chrome Incognito Mode using Windows File path in Windows OS
- Open Google Chrome Incognito Mode using Powershell in Windows OS
- Open Google Chrome Incognito Mode using Bat file in Windows OS
- Open Google Chrome Incognito Mode in Ubuntu OS
- Open Google Chrome Incognito Mode in Mac OS
First, let's go over some of the terms associated with the Incognito mode of Google Chrome, and then we'll go over how to launch Google Chrome in Incognito mode or in private mode using cmd or Powershell.
What is Incognito Mode?
The Chrome browser has a very helpful feature and settings called Incognito Mode, which prevents the browser from keeping a record of the websites that you visit. As an example, it does not maintain a record of previous search terms or other browsing data, cookies, or temporary files.
Cookies and temporary files, as well as search history and passwords, are deleted together with the session data from each anonymous browsing session. This ensures the protection of all potentially sensitive information.
You can force the browser to open in incognito mode by using a special argument called -incognito, which is found in the command line of the Windows operating system, Mac as well as Linux.
Open Google Chrome Incognito Mode via Command Line in Windows OS
We may accomplish this by using the -incognito parameter in the command line, as seen below.
Open Command Prompt and type below:
start chrome -incognito
This will open chrome incognito in a new browser window with a default search engine.
If you have a default search engine is bing, then the incognito mode will open with bing.
If you have a default search engine is google search, then the incognito mode will open with a google search.
If you want to open a particular website in incognito mode then you can do as follows.
start chrome URL -incognito
start chrome https://stackoverflow.com -incognito
This will open the StackOverflow website in chrome incognito mode.
Open Google Chrome Incognito Mode using Windows File path in Windows OS
The steps are as follows:
For this you have to go to the location where you have installed chrome.
Goto URL and type: cmd and press Enter.
This will open the command prompt where the Chrome installation location is.
If you want to open a particular website then the syntax is:
chrome.exe url -incognito
Open Google Chrome Incognito Mode using Powershell in Windows OS
Powershell is a command line shell, a scripting language, and a configuration management framework. It is a cross-platform solution for task automation and configuration management.
If you want to use it in Powershell then you can use the below command.
Method 1: Using Start Command
This method is similar to what we did in the command line and also works in Powershell.
start chrome --incognito
Method 2: Using System.Diagnostics.Process
System.Diagnostics.Process gives you access to both local and remote processes and gives you the ability to start and terminate processes that are local to your system. And Start in above command starts a process called chrome.exe in the private browsing mode ie. incognito mode.
Run the below script in Powershell
Open Google Chrome Incognito Mode using Bat file in Windows OS
A bat file is a specific kind of text file that is used by operating systems based on Windows. Within a bat file, you can write many commands that run in sequence, line by line.
Lets look how to do it.
First create a text file and then paste below command.
start "" /max chrome --incognito %url%
then save it with the.bat file extension like incognitomode.bat .When you double-click the bat file, ourtechroom.com will open in Chrome incognito mode.
or you can use below code as well.
start chrome --start-maximized --incognito %url%
Open Google Chrome Incognito Mode in Ubuntu OS
Open Google Chrome Incognito Mode in Mac OS
If you are using MacOS with the Chrome browser, and want to open it through terminal, enter the following command in terminal.
open -a "Google Chrome" --args --incognito "https://ourtechroom.com"
This will launch Google Chrome in incognito mode with ourtechroom.com.
If you want to learn more, the last option is man open.