问题
I've been trying to to run calculator using powershell remoting. I entered a powershell session (with Enter-PSSession
), and entered the following command:
Start-Process calc.exe
I looked at the remote computer and nothing showed up. When I try other commands like Get-Process
or Stop-Process
they work fine. I looked online and saw womewhere that I should try using -PassThrough
to see if it's doing anything and I got this result:
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
7 4 1228 2388 35 0.02 528 calc
So I decided to look in task manager on the computer I was connecting to to see if the process is running, but it wasn't there. Only when I clicked "Show processes from all users" it showed up, even though the user listed on the process was the one I was logged in to. I tried using some other windows programs like mspaint and notepad and got the same results.
Does anyone know why this is happening? The processes seem to run without opening the gui.
EDIT: I just noticed that the process is stopped once the session is closed. Is there a way to overcome this?
回答1:
When you create a session with enter-pssession
, it is its own "entity" - you cannot connect it to an interactive desktop session, nor is there any GUI for the application(s) you start to interact with. It's an interactive text-based console only, and even if you're logged into the console as well, it's two separate user sessions and they cannot communicate.
So even though you can start a process that has a GUI, there is no GUI for it to attach to or display on.
来源:https://stackoverflow.com/questions/27135319/start-process-doesnt-work-in-powershell-remoting