In a batch file residing in a remote desktop I have simply written "python jwRelay.py"
I want to run the batch file using psexec using the following command:
psexec -s -i 2 \\135.20.230.160 -u administrator -p force cmd.exe /c "C:\Users\Administrator\Desktop\jwRelayCDV16\SampleCode\Python\relay.bat"
The issue is when I run the above command the command prompt in the remote machine quickly pops up and closes (I can see through mstsc). How can I keep the command prompt open if I want to debug the code remotely?
In my laptop after running the above command I get this:
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.comcmd.exe exited on 135.24.237.167 with error code 2.
Is there any other alternative than running the script jwRelay.py in interactive mode in the remote machine?
psexec -s -i 2 \\135.20.230.160 cmd.exe /k python path\to\jwRelay.py. If you also want Python to remain open in an interactive shell, usepython -i path\to\jwRelay.py. Also, the "-u" option will be ignored considering "-s" makes it run asSYSTEM.\Sessionsobject directory (checkaccesschk -qso \Sessions). Prior to Vista (NT 6) the console shared session 0 with system services, but NT 6 isolates session 0 to system services. The "-i" option should default to the console session. Trypsexec \\135.20.230.160 -s cmd.exeto open a shell to inspect available sessions.