I am trying to spawn a cmd.exe shell on a remote machine using psexec then proceed to running commands on that machine and reading the output. I.e. running pwd.
Unfortunately, the code I have now will just immediately exit cmd on the remote system
I'm trying to use the current code
#include <Constants.au3>
$pid = Run('C:\Users\test\Desktop\psexec.exe \\192.168.1.123 -u test -p "P@$$word1" -h -s cmd',@SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
StdinWrite($pid,"pwd")
StdinWrite($pid,@CRLF)
Local $data
Sleep(2000)
$data &= StdoutRead($pid)
ConsoleWrite("Debug:" & $data & @LF)
StdinWrite($pid,"cd ")
StdinWrite($pid,"C:\users\test2")
StdinWrite($pid,@CRLF)
StdinWrite($pid)
$data &= StdoutRead($pid)
ConsoleWrite("Debug:" & $data & @LF)
http://stackoverflow.com/questions/19206834/command-prompt-and-autoit-stdinwrite <- credits to this stack overflow post
Unfortunately, on my end, my cmd just starts/stops with this prompt
Connecting with PsExec service on 192.1.123...Starting cmd on 192.168.1.123...
cmd exited on 192.168.1.123 with error code 0.
Any ideas how I can keep my shell open over psexec and still interact with it using AutoIT?
Any feed back would be amazing! Thanks!