'Powershell launch window on second screen

I need to launch two Google pages in full screen on a PC with 2 screens, one page for each screen.

Actually this is my code:

$pathToChrome = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
$tempFolder = '--user-data-dir=c:\temp' # pick a temp folder for user data
$startmode = '--start-fullscreen' # '--kiosk' is another option
$startPage1 = 'https://google.com'
$startPage2 = 'https://google.com'

Start-Process -FilePath $pathToChrome ('--new-window',  '--start-fullscreen', $startPage1) -ErrorVariable Test
Start-Process -FilePath $pathToChrome ('--new-window',  '--start-fullscreen', $startPage2) -ErrorVariable Test 

It works but it open one page over the other one. How can I do for open the second page on my second screen?



Solution 1:[1]

This is application-specific in Windows, unfortunately. Windows processes (like explorer.exe) all use startup info stored in the registry, but that is not a standard and many applications ignore it entirely.

The only real global way around it is to emulate moving the window manually using some user32.dll methods like CherryDT's comment suggests.


To answer your example, Chromium browsers can use start flags to specify position, but it requires running each window with separate profiles:

How to open two instances of Chrome kiosk mode in different displays (Windows)

Launch Google Chrome from the command line with specific window coordinates

# open chrome on two monitors (all chrome windows must be closed first)
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --app="http://www.domain1.com" --window-position=0,0 --kiosk --user-data-dir=c:/monitor1

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --app="http://www.domain2.com" --window-position=1680,0 --kiosk --user-data-dir=c:/monitor2

I have found many other applications use a simple .ini file in appdata to store window size/location settings.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cpt.Whale