JSteenberge
Members
-
Joined
-
Last visited
Reputation Activity
-
JSteenberge got a reaction from Jamie Taylor in How to start an application via a script using powershellYou can do this, but need psexec and Windows is not designed to really do this. It's a security flaw since each user session is supposed to be a controlled session. That said, the below works for me (with a copy of psexec somewhere on the machine .... can copy to anywhere on machine via script).
#Add command to copy psexec to computer
Copy-Item -Path \\server\share\psexec.exe -Destination C:\scripts\psexec.exe
#Get the console user session ID
$session = tasklist /fo CSV | findstr Console ; $session = $session.Split(",")[3] ; $session.split('"')[1]
#Launch notepad via session variable
& .\psexec.exe -s -i $session notepad.exe
Again, this is a security flaw and some apps may not work as well as notepad does but it does work.