Search code examples
batch-filetomcatremote-accesspsexec

psexec: the system cannot find the file specified


On server 10.221.2.4 i have the following batch file entitled: restart_Tomcat.bat in C:\Users\Tomcat\Desktop and is working locally.

@ECHO OFF
SET SvcName=Tomcat9

SC QUERYEX "%SvcName%" | FIND "STATE" | FIND /v "RUNNING" > NUL && (
    ECHO %SvcName% is not running 
    ECHO START %SvcName%

    NET START "%SvcName%" > NUL || (
        ECHO "%SvcName%" wont start 
        EXIT /B 1
    )
    ECHO "%SvcName%" is started
    EXIT /B 0
) || (
    ECHO "%SvcName%" is running
    EXIT /B 0
)

I'm trying to run the same batch file from a remote server using the following command:

psexec -e -h -s -u -u username -p  \\10.221.2.4  cmd "C:\Users\Tomcat\Desktop\restart_Tomcat.bat"

However I get the following error:

PsExec v2.43 - Execute processes remotely
Copyright (C) 2001-2023 Mark Russinovich
Sysinternals - www.sysinternals.com

Password:

PsExec could not start tomcat on RINACY03:
The system cannot find the file specified.

The path for the file is correct as can be seen below: enter image description here

Any idea?


Solution

  • I found the solution:

    psexec \\10.221.2.4 -s -u \\domain\userbanw -p myPass cmd /C "C:\Users\Tomcat\Desktop\restart_Tomcat.bat"