Jump to content
Sign in to follow this  

Using psexec tool on remote and detected process ID

Recommended Posts


Dear All.

I have one question need everyone help

I have two computer, One is a server, another is Client

Server use Autoit and command line is there 

Execute via CMD on server

Run("cmd.exe", "" , @SW_SHOWMAXIMIZED)
Winwaitactive("administrator: c:\windows\system32\cmd.exe", "", 1)
Send('cd PSTools' & "{Enter}")
Send("psexec -u domain\" & $Username & "{SPACE}" & " -p 123 \\" & $Computername & "{SPACE}" & "-d -i -f -c C:\cmd.bat" & "{Enter}")
Send('pause' & "{Enter}")

It have processID on client computer, but I want to use Processwaitclose($PID) to deceted on server side

How to do this?

Share this post

Link to post
Share on other sites

Have someone can help this?

Share this post

Link to post
Share on other sites

A clarification and a critique:

The PID in question....that is the PID of the process started on the Client via PSEXEC?  You can't use ProcessClose on the Server to kill a process on the Client.  Not sure what your BAT file is doing, but ProcessClose can only close processes on the machine AutoIt is executing.

Critique/Suggestion: There's no need to launch a command prompt and send keystrokes to it, not to mention it's one more thing that could go wrong.  Just execute the PSEXEC line directly (just my two cents)

$strPSToolsPath = "C:\PSTools"
$strExecCMD = '"' & $strPSToolsPath & '\psexec.exe" -u domain\' & $Username & " -p 123 \\" & $Computername & " -d -i -f -c C:\cmd.bat"
Run(@ComSpec & " /k " & $strExecCMD , "" , @SW_SHOWMAXIMIZED)


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this