Click here to Skip to main content
11,410,129 members (61,822 online)
Click here to Skip to main content

Executing programs remotely in Windows NT/2000/XP

, 16 Jan 2003
Rate this:
Please Sign up or sign in to vote.
Starting programs on different machines is easy using these utilities.


The need to start programs remotely can be very useful. Specifically I needed to be able to start a handful of applications remotely simply to cover the possibility of failure.


Two components were necessary to make the remoting work. First, a simple application is needed to simply accept arguments and program names and submit them for remote execution. Secondly, an NT service was needed on any machine wishing to allow the remote execution to take place.

Service Installation

To install the service, simply execute the following command after downloading the .exe:

After executing this command, go into the services manager (from the administrative tools in control panel) and be sure the service is set up to be able to interact with the desktop:

Application Installation

Simply download the application and place it in the path on any machine wishing to submit programs for remote execution.

Starting a program remotely

To execute a program remotely, simply invoke rexec.exe and pass it the following parameters:

  1. ip address of machine to process program.
  2. name of program/script/batch file.
  3. arguments to be passed to the program/script/batch defined in argument 2 when being started remotely.

Example: To start notepad on machine at IP and have it initially load a file \\fileserver1\test file.txt rexec would be given the following arguments:

rexec notepad.exe "\\fileserver1\test file.txt" 

Note that for this to work properly, the remote execution service must be installed and started on the machine @

The code

In the spirit of code re-use, the NTService class was taken from an article by TODD C. WILSON on The class was originally created by Joerg Koenig.

The service simply listens for connections on a pre defined port. When connections are received from the rexec application instances they are threaded off into connection processing threads. The connection threads simply grab the program and it's arguments off the socket, start the program, and terminate. The remote execution application connects to the service at the specified IP. Next the app sends the program name and arguments to the remote service.


That's it. Nothing complicated. But quite useful. Please let me know if you have comments or ideas for improvement.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Tim Kohler
Chief Technology Officer
United States United States
Working to keep a technology company up to date. Wondering when Microsoft will hire a fresh, innovative guy to run the company.

Comments and Discussions

Questionsocket connection failed PinmemberMember 47689816-May-12 22:31 
QuestionPSExec could be the solution to all of you that have problems. PinmemberMember 820973731-Oct-11 9:51 
Questionrexec is giving connection refused Pinmembermaestromani20-Sep-11 6:29 
AnswerRe: rexec is giving connection refused PinmemberAZeitler13-Dec-11 11:20 
GeneralI have the program working locally on one windows xp pro machine but can't install service in windows 7 PinmemberStephane Poirier23-Aug-11 12:55 
GeneralSuggestions for people who have problems Pinmemberjdixon227826-Mar-10 7:21 
Question'Local System' can't access network share folder PinmemberSekhar Kumar5-May-08 7:37 
Generalruntime to terminate Pinmemberkalle10-Dec-07 6:46 
GeneralSocket Connection Failed Pinmemberyug_chary12-Oct-07 2:12 
When i tried to run the program remotely, "Socket Connection Failed" error message is dispalyed. Can anyone please help me out.

GeneralRe: Socket Connection Failed PinmemberEli Hazan27-Mar-08 12:07 
GeneralRe: Socket Connection Failed Pinmembervipul052719-Nov-09 19:11 
GeneralRe: Socket Connection Failed Pinmembernax2284-May-10 0:53 
GeneralRe: Socket Connection Failed Pinmemberxytsrm22-Jan-11 5:04 
GeneralImprovment issues PinmemberElad raz14-Mar-07 2:50 
Generaloutput Pinmembersdev4003-Jan-07 14:39 
GeneralRemote execution does not work Pinmemberautoguy10011-May-06 4:42 
QuestionWhy is it asking for username and password? Pinmemberlearningvisual5-Apr-06 13:49 
AnswerRe: Why is it asking for username and password? Pinmemberjkleiss25-Sep-06 11:11 
AnswerRe: Why is it asking for username and password? PinmemberBlades6-Mar-08 7:21 
GeneralRe: Why is it asking for username and password? Pinmemberjkleiss6-Mar-08 8:48 
GeneralRemote execution does not complete Pinmembermholzer5423-Nov-05 10:13 
GeneralGreat utility, congratulations. Pinmemberlancer22719-Oct-05 1:37 
GeneralRe: Great utility, congratulations. Pinmemberksshaan2-Jul-08 19:29 
GeneralRe: Great utility, congratulations. Pinmemberjdixon227826-Mar-10 5:22 
Generalgreat job and a question Pinmembermsmarlene15-Jul-05 9:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150414.5 | Last Updated 17 Jan 2003
Article Copyright 2003 by Tim Kohler
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid