简体   繁体   中英

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

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 --display=:0.0 | --display=:0.1 But it doesn't seem to work or I am not using it properly

Any ideas? Thanks.

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.

I have the same issue also. This answer: https://stackoverflow.com/a/3750187/1305565 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 

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.

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,

I run in the same problem and got setup a good solution with the command line flags. The solution from https://stackoverflow.com/a/29646543/3634274 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, eg 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM