How to Run Batch File Remotely

MD Aminul Islam Feb 02, 2024
How to Run Batch File Remotely

Sometimes we need to use a computer remotely from a different location. We can do this with some third-party software like TeamViewer.

But we can execute a Batch file from the remote directory without third-party software. In this article, we are going to see how we can run a Batch file from a remote location, and we are going to see an example command to make the topic easier.

Run Batch File Remotely

For this purpose, we will use a built-in Batch command named psexec. Below is an example of the command.

psexec \\IPofTheRemoteServer d:\directory\to\file\YourFile.bat

This command contains some important flags you can use based on your needs. Let’s see them in detail.

-a Uses for selecting the processor. The lowest number of the CPU is 1.
-c This flag is for copying the specified executable from the remote system for execution.
-d This flag tells the system not to wait for process termination.
-e This flag will not load the specified account profile.
-f This flag will copy the specified program file through the program file existing on the remote computer.
-i This flag tells to run the program to interact with the session’s PC specified on a remote system.
-h Checks whether the targeted system is Windows Vista or higher.
-l This flag is used to run the process in a limited user mode. It also provides integrity to the process.
-n This flag counts the timeout when connecting to the host computer.
-p This flag provides the password and username when connecting to the host computer.
-r This flag specifies the remote service name for creating or interacting with.
-s This flag will run the remote process in a system account.
-u This flag specifies the optional user name when login into the remote computer.
-v This flag specifies the version number of the remote system.
-w This flag sets the working directory of a process relative to the remote computer.
-x This flag is to display the UI on a Winlogon secure desktop of a local system.
-priority This flag specifies the priority of a process.
arguments This flag specifies the arguments that need to be passed.
MD Aminul Islam avatar MD Aminul Islam avatar

Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.

LinkedIn

Related Article - Batch File