running a bat file using psexec

create share 676 Reputation points
2023-11-04T11:56:55.1933333+00:00

Hi,

I need to run a psexec command on remote pcs that should first change the directory to

C:\program files (x86)\antivirus

and then run ch.exe file. I tried but failed. I tried running it locally on the PC with CMD but failed with error message: "The system cannot find the path specified"

What is the proper way to run exe files from the command prompt without first going to the directory path of the exe file?

Thanks.

Windows for business | Windows Client for IT Pros | User experience | Other
Microsoft System Center | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Andreas Baumgarten 129.5K Reputation points MVP Volunteer Moderator
    2023-11-04T12:25:57.9366667+00:00

    Hi @create share ,

    to execute an exe with CMD just add the related full path in front of the exe. If the path contains spaces put "" around all.

    For instance:

    "c:\Program Files (x86)\Just A Test\write.exe"

    enter image description here


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards Andreas Baumgarten

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. create share 676 Reputation points
    2023-11-04T15:05:07.4+00:00

    Yes, it is working. I was making a mistake.

    Thanks.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.