6

This command line opens an incognito tab and connects to the URL in environment variable %url%:

start chrome --incognito %url%

This maximizes the tab and connects to the %url%.

start chrome %url% /MAX

But as soon as I try to combine them, like this,

start chrome --incognito %url% /MAX

The /MAX option does not work.

How can I properly combine their functions?

7

How can I properly combine their functions?

You may be using /max in the wrong position. /max is an option to start, not chrome. You also appear to be leaving off the (in most cases) necessary leading set of double-quotes ("") for start. So your start command should look like:

ex. incognito_chrome.bat

set url=plus.net

start "" /max chrome --incognito %url%

Also be aware that if chrome isn't really chrome.exe (e.g. it's chrome.bat), this could be eating your /max option (in this example, /max would be used on the command window spawned by chrome.bat, not Chrome [chrome.exe] itself). If this is the case, you should use the full path to chrome.exe rather than just chrome.

References

  • start (ss64 documentation)
| improve this answer | |
4

The /MAX is in the wrong position, but it's not strictly necessary because Chrome has a command line option to start maximized.

You can use the command line argument directly:

set url=superuser.com
start chrome --start-maximized --incognito %url%
| improve this answer | |
1

You can achieve what you want by involving PowerShell in your script. PowerShell provides more control over the process start parameters.

Here is a working example of a batch file you can use.

StartChrome.bat

SET URL=plus.net

powershell -c "start-process chrome.exe -WindowStyle Maximized -ArgumentList ""%URL% --incognito"""
| improve this answer | |
  • SET URL=plus.net powershell -c "start-process chrome.exe -WindowStyle Maximized -ArgumentList ""%URL% --incognito""" I executed this code, but the tap wasn't maximized. – shiftdel Aug 9 at 0:34
  • @shiftdel sorry to hear that, but did you put it in a batch file as I showed? Seems you have it all in one line, but maybe that's just the comment formatting. I tested it and it definitely works! – Reg Edit Aug 9 at 20:19
0

Try this PowerShell code using the Windows API:

$url = "URL"
chrome.exe --incognito "$url"
$max = 3
$winapi_code = @'
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
'@
Add-Type -MemberDefinition $winapi_code -Name NativeMethods -Namespace Win32
$hWnd = (Get-Process -Name chrome).MainWindowHandle | Where-Object {$_ -ne 0}
[Win32.NativeMethods]::ShowWindow($hWnd, $max) | Out-Null
| improve this answer | |
  • 1
    Downvoter, please explain the downvote, as this code is tested and worked without flaws. – Wasif Hasan Aug 9 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.