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

6

28

We are developing a web application that needs to open in two different browser instances each on a different Screen. Obviously the pc we are using has dual display already, and both monitors have the same size and resolution.

The idea is that as soon as Windows starts the two applications should open immediately in fullscreen, our preferred browser is Chrome as it counts with several commands that might help us accomplish the task.

We have succeeded on adding to the startup programs two shortcuts that open two instances in kiosk mode, but we have not been able to choose on which Display to open.

The shortcuts have this target:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=c:\temp --kiosk www.domain.com --new-window "%1" --window-position=0,0

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=c:\temp --kiosk www.domain2.com --new-window "%2" --window-position=1680,0

In order to open two instances chromes needs to create a temporary file with information of the instance to open (--user-data-dir=c:\temp)

We tried using (--window-position=1680,0) to specify where to open the instance but it seems that Chrome will give priority to the last position where the last instance was opened, so both instances open on the same window regardless of the command.

We found this site with a list of all the commands available but the list is huge and we don't even know what we are looking for:

http://peter.sh/experiments/chromium-command-line-switches/

I found this command: --display=:0.0 | --display=:0.1 But it doesn't seem to work or I am not using it properly

Any ideas? Thanks.

Fresco answered 27/3, 2015 at 5:41 Comment(0)
R
16

I have the same issue also. This answer: https://mcmap.net/q/491197/-launch-an-application-and-send-it-to-second-monitor inspired me to create own PowerShell script for easier use.

Shortly

Script does the following:

  1. Start a Chrome instance via script
  2. Now use WinApi to find started window and move it to the desired screen
  3. Send F11 key to the moved window to make it full screen (we could start chrome already in full screen mode, but moving windows in that mode would be not so trivial)
  4. Do the same with other instances, specifying necessary URL.

Final script

Function definitions are hidden in Dll and in another helper script. (download them from GitHub using the link above)

$chromePath = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
$chromeArguments = '--new-window --incognito'

# &taskkill /im chrome* /F 
Chrome-Kiosk 'http://google.com' -MonitorNum 1 
Chrome-Kiosk 'http://http://www.bbc.com/' -MonitorNum 2 
Ravid answered 15/4, 2015 at 9:29 Comment(1)
I need to share same session for all two windows but its not working -- here is the code i m trying ------>>>>> start chrome --new-window domain/#/login --window-position=0,0 --user-data-dir=c:/monitor1 Timeout /t 10 /nobreak >nul 2>&1 start chrome --new-window domain/#/mvp --window-position=2800,0 --user-data-dir=c:/monitor1 <<<<---------- Seems when we open second chrome window in second monitor its not sharing same session or cache, is this because browser security ?Maeve
C
24

This code worked fine for me:

start C:\Users\terminal\AppData\Local\Google\Chrome\Application\chrome.exe --app="http://www.domain1.com" --window-position=0,0 --kiosk --user-data-dir=c:/monitor1

start C:\Users\terminal\AppData\Local\Google\Chrome\Application\chrome.exe --app="http://www.domain2.com" --window-position=1680,0 --kiosk --user-data-dir=c:/monitor2

I think the order of the parameters is relevant.

Cyclopropane answered 22/8, 2016 at 15:33 Comment(4)
After attempting a number of more complex methods that didn't work, this method worked perfectly for me. Thank you!Lambeth
This works for me, but the separate data-dirs do mean that the two windows can't share cookies, etc, which may be a pain for people (they're two separate sessions)Brigitte
with small modifications, this worked for me: start C:\"Program Files"\Google\Chrome\Application\chrome.exe --kiosk --kiosk-printing "http://localhost:4200" --user-data-dir=c:/monitor2Grained
The windows will not share current sessions, passwords, etc. Two different profiles.Clonus
R
16

I have the same issue also. This answer: https://mcmap.net/q/491197/-launch-an-application-and-send-it-to-second-monitor inspired me to create own PowerShell script for easier use.

Shortly

Script does the following:

  1. Start a Chrome instance via script
  2. Now use WinApi to find started window and move it to the desired screen
  3. Send F11 key to the moved window to make it full screen (we could start chrome already in full screen mode, but moving windows in that mode would be not so trivial)
  4. Do the same with other instances, specifying necessary URL.

Final script

Function definitions are hidden in Dll and in another helper script. (download them from GitHub using the link above)

$chromePath = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
$chromeArguments = '--new-window --incognito'

# &taskkill /im chrome* /F 
Chrome-Kiosk 'http://google.com' -MonitorNum 1 
Chrome-Kiosk 'http://http://www.bbc.com/' -MonitorNum 2 
Ravid answered 15/4, 2015 at 9:29 Comment(1)
I need to share same session for all two windows but its not working -- here is the code i m trying ------>>>>> start chrome --new-window domain/#/login --window-position=0,0 --user-data-dir=c:/monitor1 Timeout /t 10 /nobreak >nul 2>&1 start chrome --new-window domain/#/mvp --window-position=2800,0 --user-data-dir=c:/monitor1 <<<<---------- Seems when we open second chrome window in second monitor its not sharing same session or cache, is this because browser security ?Maeve
M
9

The easiest way to accomplish this is to use 2 different data directories. You may or may not want to delete the preferences before launching. If you do, your script can control where screens are placed. If you don't, then they can be manually positioned and it will remember the position of both windows separately:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=c:/screen1 --start-fullscreen --new-window www.domain.com --new-window "%1" --window-position=0,0

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=c:/screen2 --start-fullscreen --new-window www.domain2.com --new-window "%2" --window-position=1680,0

Note, I also used --start-fullscreen instead of kiosk, and --new-window. You may or may not need those.

Maneater answered 9/5, 2016 at 5:52 Comment(1)
Great suggestion. For those who like to copy/paste here is the text to be paste in to a batch file. I also add the first line to be in Kiosk(Thats always your main window, it ignore the position attribute) so the start menu is not shown. START chrome --user-data-dir=C:\TEMP\acc1 --start-fullscreen --new-window www.wayfair.com --kiosk --new-window "%1" START chrome --user-data-dir=C:\TEMP\acc2 --start-fullscreen --new-window www.bbc.com --new-window "%2" --window-position=0,1680 EXIT Just make sure each START is on a new line and EXIT is at new line too.Marcomarconi
I
3

Here's how to do it with a Raspberry Pi/linux. These lines should be added to /home/pi/.config/lxsession/LXDE-pi/autostart

@chromium-browser --kiosk --incognito --user-data-dir=/home/pi/.config/chromium-display1 --window-position=0,0 https://bing.com 

@chromium-browser --kiosk --incognito --user-data-dir=/home/pi/.config/chromium-display2 --window-position=1921,0 https://google.com

If you need to find your screen resolution, go to Preferences > Screen Configuration.

Isotonic answered 2/1, 2020 at 23:53 Comment(0)
R
2

I'm having a very hard time finding an answer myself.

The closest-to-easy solution, since you're running Windows, that I could find was to create a batch file +VBScript that will emulate the Win+Arrow-keys shortcut to move a window to the 2nd display. Here's a very well-written Tech-net Article (Shortcut is Win-7 specific I believe, but there are also graphics card manufacturer shortcuts)

However, I did find a program that another forum claims you can create application shortcuts that launch in a specific window called DisplayFusion, check it out

You can also use the command-line utility mentioned here on Superuser <--- Probably the quickest method

Hope this all helps,

Rockett answered 12/4, 2015 at 3:39 Comment(0)
M
1

I run in the same problem and got setup a good solution with the command line flags. The solution from https://mcmap.net/q/489783/-how-to-open-two-instances-of-chrome-kiosk-mode-in-different-displays-windows works also very well, but it needs some setup every time when i want to install new multimonitor stations and i have no named icons for each application.

I use a combination of some command line flags and it works:

Monitor 1:

--user-data-dir=C:\temp\App1
--app="http://appxy.appserver.my?station=PC-MYWORKSTATION&theme=dark"
--incognito
--window-position=0,0
--start-fullscreen

Monitor 2:

--user-data-dir=C:\temp\App2
--app="http://appxy.appserver.my?station=PC-MYWORKSTATION&theme=light"
--incognito
--window-position=2560,0
--start-fullscreen

It is important to use completly seperated user profiles, because when you have your Chrome with your profile open then it don't starts as it's own instance. With that setup i can use my chrome as it is and open my apps on the second or third monitor, e.g. like monitoring apps on which i only want to display stuff.

To make it easy for setup i wrote a powershell script that creates only the shortcut with a icon:

# Example Call:
#
# Monitor 1
# .\createShortcut.ps2 -AppName "MyApp 1" -AppPath "http://google.com" -StartFullScreen $true -WindowPosition "0,0"
# .\createShortcut.ps2 -AppName "MyApp 1" -AppPath "http://google.com" -AppIcon "\\domain.local\icons\myapp.ico" -StartFullScreen $true -WindowPosition "0,0"
#
# Monitor 2
# .\createShortcut.ps2 -AppName "MyApp 2" -AppPath "http://google.com" -StartFullScreen $true -WindowPosition "2560,0"
# .\createShortcut.ps2 -AppName "MyApp 2" -AppPath "http://google.com" -AppIcon "\\domain.local\icons\myapp.ico" -StartFullScreen $true -WindowPosition "2560,0"

param(
  [string]$AppName,
  [string]$AppPath,
  [string]$AppIcon,
  [boolean]$StartFullscreen,
  [string]$WindowPosition
)

$AppArgs = " --incognito";

if($WindowPosition) {
  $AppArgs += " --window-position=$WindowPosition"
}

if($StartFullscreen -eq $true) {
  $AppArgs += " --start-fullscreen"
}

$userDir = "C:\temp\$AppName"
Write-Host "Create Folder:"$userDir
New-Item -ItemType directory -Path $userDir -Force > $null
$scArguments = "--user-data-dir=`"$userDir`" --app=`"$AppPath`"$AppArgs"

Write-Host "Argmunets: $scArguments"
$Shell = New-Object -ComObject WScript.Shell
$ShortCut = $Shell.CreateShortcut("$env:USERPROFILE\Desktop\$AppName.lnk")
$ShortCut.TargetPath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
$ShortCut.Arguments = $scArguments
$ShortCut.WorkingDirectory = "C:\Program Files (x86)\Google\Chrome\Application"
$ShortCut.WindowStyle = 1
if ($AppIcon.Length -gt 0) {
  $ShortCut.IconLocation = $AppIcon
}
$shortCut.Save()

I hope this solution helps all that searches for a similar solution.

Last but not least what does this script?

  • creates the user-data-dir silently
  • concats the command line parameters
  • creates the shortcut with a icon (optional) on the desktop
Mohsen answered 7/2, 2019 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.