running a bat file using psexec

create share 666 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 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,826 questions
Microsoft System Center
Microsoft System Center
A suite of Microsoft systems management products that offer solutions for managing datacenter resources, private clouds, and client devices.
1,030 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,133 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 111.7K Reputation points MVP
    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 666 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 Answers by the question author, which helps users to know the answer solved the author's problem.