Reputation: 3069
My Requirement is as follows:
Upvotes: 0
Views: 2188
Reputation: 5893
(Answer in question converted to a community wiki answer.)
The OP wrote:
Solution:
Firstly, you should know the psexec parameter -i, -i is "Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session." it is about the user sessionID, so I must know which acount is logon pc1, and what's his user sessionID
The very easy way to know his user sessionID is to open windows task manager on pc1 and click the "Users" tab, and the "ID" column is his user sessionID,
So, you get the user sessionID and you use it on pc2, here is the code
psexec \ip or pc name -u user -p pwd -accepteula -i 2 cmd
and you will get a cmd window on pc1
But user sessionID is dynamic, so I write a batch file to get user sessionID
@echo off REM Default sessionID=2 set sessionID=2 for /F "tokens=1,2,3,4,5" %%A in ('"query user | find "Active""') DO ( set sessionID=%%C ) echo %sessionID%
Upvotes: 1