-1

I am able to execute basic operation by triggering batch script on remote location using following command.

psexec -e -h -s -u User -p pass \\10.0.0.240 C:\test.bat

But when the test.bat file is calling other program specific script like somepy.py then I am getting error on master batch file that these are not internal command. Master batch file in Host computer:
CODE
psexec -e -h -s -u user -p pwd \\10.0.0.240 C:\Users\Desktop\TEST\test.bat

Command inside test.batlocated in remote PC:

cd C:\Users\Desktop\TEST1
impact -batch test_impact_warp_AP.cmd
`pause`
waitfor /t 5 StartNow

REM wait for 5second echo "Run python script for Warp"
cd C:\Users\Desktop
call warp-python.bat

ipconfig /all
ping google.com

Command inside warp-python.bat present in remote machine:

set PYTHONPATH=C:\Users\Desktop\Python_Reference 
cd C:\Users\Desktop\Python_Reference\examples\PYTHON_SCRIPT
python t_capture.py 
  1. When I executed the test.bat script directly then warp-python.bat as well as test_impact_warp_AP.cmd executes perfectly without any error.
  2. But when i try to execute test.bat from remote location then *python* and *impact* commands are not recognised. and gives following error:

    'Impact' is not recognised as an internal or external Command But ipconfig/all and ping command is executed perfectly in remote PC

  3. What am I missing in the command line argument such that psexec in not able to executed the command in remote location
HaWa
  • 231
  • 2
  • 4
  • 10
  • You might check to see what the environment contains, particularly PATH, on the other machine when running PSEXEC. Powershell can also run remote commands. – lit Oct 10 '15 at 18:36

1 Answers1

0
  1. Add the psexec.exe to your PATH variable in the environment variable or give the full path of psexec.exe in your command.

Example:

c:\users\test\Desktop\psexec.exe -e -h -s -u User -p pass \10.0.0.240 C:\test.bat
  1. Make sure C:\test.bat is present in your remote machine.
Paul
  • 1,176
  • 3
  • 12
  • 27
  • Hi, I tried your step but still psexec is giving ERROR: 'impact' is not recognised as an internal or external command. My setup: test.bat is present in remote machine. This batch file has some Xilinx and python commands. When I run the batch file locally it perfectly executes. I am also able to run psexec to work eg. I can execute ping, ipconfig, cd to remote directory using psexec. But somehow, psexec is giving error while executing commands which are program specific. Am I missing any arguments in the psexec command? – HaWa Oct 12 '15 at 07:37
  • Can you paste the contents of test.bat – Paul Oct 12 '15 at 08:51
  • Inside test.bat ' ipconfig ' 'python -V echo "Running 1st script" set PYTHONPATH=C:\Users\Desktop\TEST\Python_Reference cd C:\Users\Desktop\TEST\Python_Reference\examples\TEST python t_test.py ' . psexec will execute the ipconfig command but fails to recognise python script – HaWa Oct 12 '15 at 09:32
  • @ user1862493 Inside test.bat ipconfig python -V echo "Running 1st script" set PYTHONPATH=C:\Users\Desktop\TEST\Python_Reference cd C:\Users\Desktop\TEST\Python_Reference\examples\TEST python t_test.py '. psexec will execute the ipconfig command but fails to recognise python script – HaWa Oct 12 '15 at 10:05
  • Add your Python directory path to PATH variable in Environment variables in the remote machine. Then execute the same command. It will work. Or try like this. `C:\Users\Desktop\TEST\Python_Reference\python C:\Users\Desktop\TEST\Python_Reference\examples\TEST\t_test.py` in your psexec command – Paul Oct 13 '15 at 04:24