I would like to start an application remotely. I am using the following PsExec command:
PsExec \\computerOne -u Domain\User1 -p 123456 -x "C:\Windows\System32\calc.exe"
I tried to use -i so that the program interacts with the desktop:
PsExec \\computerOne -u Domain\User1 -i 123456 -x "C:\Windows\System32\calc.exe"
but that does not work. The error from the second example is:
calc.exe exited on computerOne with error code -1073741502"
If I omit the specification and just write the path of the exe, the process is listed in the taskmanager but I can not see any UI. Do I have to change any settings on my Desktop on which I want to start the program?
What you are seeing is likely to be an effect of Session 0 isolation - psexec installs and starts a new service on the remote machine, but the default session it is starting your process in is 0, and thus unavailable to the currently logged on user (at least on from Windows Vista / Server 2008). You need to specify the session number after the
-i
parameter. You can query the currently logged on users (and their session numbers) using thequser /SERVER:computerOne
command beforehand.For quick&dirty testing you can assume that the session ID of the first interactively logged-on user is "1".
You can also just take out the -x and replace with -I, it should open up PsExec \computerOne -u Domain\User1 -p 123456 -i "C:\Windows\System32\calc.exe"
The root-cause appears to be leaky handles made by the
Console.Write
method inMicrosoft.powershell.consolehost.dll
. The -1073741502 exit code in hex is 0xC0000142 (status_dll_init_failed).This appears to be isolated to Windows 7 & 2008 (as per Microsoft's KB2701373).
Side-Note: Several "Fixes" elsewhere on the Internet are attributed to doing some sort of magical incantation, then closing PowerShell & opening a new instance. However, 'restarting' PowerShell is what actually temporarily solves the problem.