param( [string]$GameArgs = "assets\terrain\vercora_zone_1m.vchm" ) $code = @" using System; using System.Runtime.InteropServices; public class DesktopLauncher { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct STARTUPINFO { public int cb; public string lpReserved; public string lpDesktop; public string lpTitle; public int dwX; public int dwY; public int dwXSize; public int dwYSize; public int dwXCountChars; public int dwYCountChars; public int dwFillAttribute; public int dwFlags; public short wShowWindow; public short cbReserved2; public IntPtr lpReserved2; public IntPtr hStdInput; public IntPtr hStdOutput; public IntPtr hStdError; } [StructLayout(LayoutKind.Sequential)] public struct PROCESS_INFORMATION { public IntPtr hProcess; public IntPtr hThread; public int dwProcessId; public int dwThreadId; } [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] public static extern bool CreateProcess( string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation ); public const uint CREATE_NEW_CONSOLE = 0x00000010; public static int Launch(string appPath, string cmdLine, string workDir, string desktop) { STARTUPINFO si = new STARTUPINFO(); si.cb = Marshal.SizeOf(si); si.lpDesktop = desktop; PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); bool ok = CreateProcess( appPath, cmdLine, IntPtr.Zero, IntPtr.Zero, false, CREATE_NEW_CONSOLE, IntPtr.Zero, workDir, ref si, out pi ); if (!ok) { int err = Marshal.GetLastWin32Error(); Console.WriteLine("CreateProcess failed with error: " + err); return -1; } Console.WriteLine("Process launched successfully! PID: " + pi.dwProcessId); return pi.dwProcessId; } } "@ Add-Type -TypeDefinition $code $root = "C:\Users\theog\Documents\_CODE\4-vercors\vercora" $exe = Join-Path $root "build\vercora.exe" $cmd = "`"$exe`" $GameArgs" Write-Host "Lancement avec console sur le bureau interactif utilisateur (WinSta0\default)..." $pidResult = [DesktopLauncher]::Launch($exe, $cmd, $root, "WinSta0\default") if ($pidResult -gt 0) { Write-Host "Vercora est demarre sur l'ecran utilisateur avec le PID $pidResult." }