Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell Open URL in New Window - [system.Diagnostics.process]::Start("","")

Tags:

powershell

So I'm using PowerShell (specifically version 5.1) in order to write a script for my work that essentially opens some websites depending on what the user selects from available options.

In order to open the website (for this example, let's just say I'm going to Google), I'm using [system.Diagnostics.Process]::Start("chrome","https://www.google.com"). This does open the website, but I'm attempting to open it into a new window entirely. In current state, I can only accomplish this by opening a new window manually and then running the script.

Any suggestions on any switches or anything that might work? I've seen a few on other sites talking about --new-window or -new = 1, but those were for other commands and don't seem to work on this one.

I'm also specifically using Chrome because the sites I am attempting to open require a sign-in, so I already have a Chrome Window open, and it defaults to opening all of my new tabs on the same window, which is what I'm attempting to avoid.

Any help would be greatly appreciated!

like image 635
Greyhurst Avatar asked Sep 04 '26 17:09

Greyhurst


1 Answers

  • The Chrome CLI parameter that requests opening a given URL in a new window is
    --new-window

  • It's simpler to use PowerShell's Start-Process cmdlet rather than the underlying .NET API directly.

Therefore:

Start-Process chrome.exe '--new-window https://www.google.com'

See also:

  • A list of most of Chrome's CLI options (switches), as pointed to from Run Chromium with command-line switches
like image 80
mklement0 Avatar answered Sep 06 '26 07:09

mklement0