Choose screen with Command line arguments

I am planning to run two or more instances of a “game” at a single PC and I need to start this automatically using command line scripts.

I start in windowed border-less mode using a FullHD resolution. According to Unity - Manual: Command line arguments this command should work, but it shows up at my first monitor no matter what. Maybe this just works in fullscreen?

game.exe -popupwindow -screen-width 1920 -screen-height 1080 -adapter 2

Is there any other way to force the “game” to show on other monitors in windowed mode?

The -adapter switch does not work in windowed mode. I have made a workaround using user32.dll to position the window at a deifined position

game.exe -popupwindow -screen-width 1920 -screen-height 1080 -screen-position-x 1920 -screen-position-y 0

the C# code needed is:

using UnityEngine;
using System;
using System.Collections;
using System.Runtime.InteropServices;

private static string[] startupArgs;

public class PlaceWindow : MonoBehaviour 
{
  #if UNITY_STANDALONE_WIN || UNITY_EDITOR
  [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
  private static extern bool SetWindowPos(IntPtr hwnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
  [DllImport("user32.dll")]
  static extern IntPtr GetForegroundWindow();
  
  public static void SetPosition(int x, int y, int resX = 0, int resY = 0) 
  {
    IntPtr hWnd = GetForegroundWindow();
    SetWindowPos(hWnd, 0, x, y, resX, resY, resX * resY == 0 ? 1 : 0);
  }
  #endif

  public static string getStartupParameter(String parameter)
  {
    if(startupArgs == null)
      startupArgs = Environment.GetCommandLineArgs();
    string s = null;
    for(int i = 0; i < startupArgs.Length; i++)
    {
      if(startupArgs*.Equals(parameter) && startupArgs.Length >= i+2)*

s = startupArgs[i+1];
}
return s;
}

// Use this for initialization
void Awake ()
{
int x = int.Parse(getStartupParameter(“-screen-position-x”));
int y = int.Parse(getStartupParameter(“-screen-position-y”));
SetPosition(x,y);
}
}

This is amazing, thank you so much for this solution!