Click here to Skip to main content
12,349,379 members (69,309 online)
Click here to Skip to main content
Add your own
alternative version

Stats

283.2K views
9.6K downloads
73 bookmarked
Posted

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.

Introduction

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.

Overview

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 123.21.61.12 and have it initially load a file \\fileserver1\test file.txt rexec would be given the following arguments:

rexec 123.21.61.12 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 @ 123.21.61.12.

The code

In the spirit of code re-use, the NTService class was taken from an article by TODD C. WILSON on CodeGuru.com. 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.

Summary

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

License

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

Share

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.

You may also be interested in...

Comments and Discussions

 
GeneralPlease help me! Pin
dSolariuM14-Jul-05 21:08
memberdSolariuM14-Jul-05 21:08 
GeneralGreat Job! Pin
James White16-May-05 11:06
memberJames White16-May-05 11:06 
General30258D71-1170-4923-B320-A14480854B1F.txt Pin
macorc13-Dec-04 22:45
membermacorc13-Dec-04 22:45 
GeneralNo reaction Pin
macorc13-Dec-04 2:06
membermacorc13-Dec-04 2:06 
GeneralRe: No reaction Pin
Member 939721531-Aug-12 10:56
memberMember 939721531-Aug-12 10:56 
GeneralRunning vbs script on remote computer Pin
jsvalois@excite.com11-Sep-04 9:09
memberjsvalois@excite.com11-Sep-04 9:09 
GeneralRe: Running vbs script on remote computer Pin
Prashant S. Patali25-Nov-04 16:59
memberPrashant S. Patali25-Nov-04 16:59 
GeneralCannot start multiple threads from a remotely executed program Pin
epiieq129-Jul-04 14:55
memberepiieq129-Jul-04 14:55 
GeneralProblems in XP Pin
clive10021-Jul-04 4:40
memberclive10021-Jul-04 4:40 
GeneralRe: Problems in XP Pin
bazzelle19-Aug-04 7:29
memberbazzelle19-Aug-04 7:29 
AnswerRe: Problems in XP Pin
RM_Coder27-Feb-08 10:51
memberRM_Coder27-Feb-08 10:51 
GeneralName and User ID prompts Pin
mag14-Jun-04 9:07
membermag14-Jun-04 9:07 
AnswerRe: Name and User ID prompts Pin
RM_Coder27-Feb-08 10:53
memberRM_Coder27-Feb-08 10:53 
GeneralAuthentication and Security Pin
aissakoo4-Jun-04 4:08
memberaissakoo4-Jun-04 4:08 
GeneralRe: Authentication and Security Pin
mag14-Jun-04 13:43
membermag14-Jun-04 13:43 
GeneralRe: Authentication and Security Pin
aissakoo4-Jun-04 14:44
memberaissakoo4-Jun-04 14:44 
AnswerRe: Authentication and Security Pin
RM_Coder27-Feb-08 10:54
memberRM_Coder27-Feb-08 10:54 
QuestionRe: Authentication and Security Pin
girlpilot10-Jan-07 10:37
membergirlpilot10-Jan-07 10:37 
Generalsocket connection fails Pin
WPCP24-May-04 4:23
memberWPCP24-May-04 4:23 
GeneralRe: socket connection fails Pin
WPCP24-May-04 8:25
memberWPCP24-May-04 8:25 
Generalneed help Pin
josephboban16-Apr-04 9:50
memberjosephboban16-Apr-04 9:50 
QuestionHow to executing MFC application in Limited account of Xp Home Operating System Pin
Rajeev Kumat26-Mar-04 18:38
sussRajeev Kumat26-Mar-04 18:38 
AnswerRe: How to executing MFC application in Limited account of Xp Home Operating System Pin
DanishShamim8111-Sep-04 2:48
sussDanishShamim8111-Sep-04 2:48 
GeneralRe: How to executing MFC application in Limited account of Xp Home Operating System Pin
Rostik198031-Oct-06 8:21
memberRostik198031-Oct-06 8:21 
GeneralNEED HELP!!!!!!!!!!!!!!!!!!!!! Pin
omega70815-Mar-04 4:20
memberomega70815-Mar-04 4:20 
Generalproblem with connection Pin
Anonymous12-Feb-04 18:58
sussAnonymous12-Feb-04 18:58 
GeneralRe: problem with connection Pin
Joffrey12-Mar-04 1:26
memberJoffrey12-Mar-04 1:26 
GeneralRe: problem with connection Pin
RUser015-Dec-05 2:41
memberRUser015-Dec-05 2:41 
GeneralRe: problem with connection Pin
Badci-Tox28-Feb-06 5:46
memberBadci-Tox28-Feb-06 5:46 
GeneralRe: problem with connection Pin
Dieter3-Dec-07 20:57
memberDieter3-Dec-07 20:57 
AnswerRe: problem with connection Pin
RM_Coder27-Feb-08 10:56
memberRM_Coder27-Feb-08 10:56 
Generalsometimes, remote command is not launched Pin
llavayssiere20-Jan-04 4:12
memberllavayssiere20-Jan-04 4:12 
Generalnot getting service manager Pin
skpanda8-Jan-04 23:14
memberskpanda8-Jan-04 23:14 
GeneralSecurity Problem Pin
Zandra R.31-Oct-03 9:58
memberZandra R.31-Oct-03 9:58 
GeneralRe: Security Problem Pin
mag15-Jun-04 10:52
membermag15-Jun-04 10:52 
GeneralRe: Security Problem Pin
Zandra7-Jun-04 2:01
memberZandra7-Jun-04 2:01 
GeneralURGENT - Unix to Windows Pin
murli_00711-Aug-03 2:12
membermurli_00711-Aug-03 2:12 
GeneralRe: URGENT - Unix to Windows Pin
RM_Coder27-Feb-08 10:58
memberRM_Coder27-Feb-08 10:58 
GeneralUnix to Windows remote Pin
murli_00710-Aug-03 18:59
membermurli_00710-Aug-03 18:59 
Generalremotely executing a script/command on OS2 machin from Window 2000 machine Pin
nsrk26-Jul-03 13:12
membernsrk26-Jul-03 13:12 
GeneralRe: remotely executing a script/command on OS2 machin from Window 2000 machine Pin
mag15-Jun-04 10:46
membermag15-Jun-04 10:46 
GeneralRC1015: cannot open include file 'res\\rexecService.rc2' Pin
Al-20-Apr-03 21:19
sussAl-20-Apr-03 21:19 
GeneralRe: RC1015: cannot open include file 'res\\rexecService.rc2' Pin
llavayssiere20-Jan-04 6:17
memberllavayssiere20-Jan-04 6:17 
GeneralRe: RC1015: cannot open include file 'res\\rexecService.rc2' Pin
Anonymous16-May-04 7:37
sussAnonymous16-May-04 7:37 
GeneralNT service program swallow up all CPU resource Pin
Golden Lee18-Jan-03 16:28
memberGolden Lee18-Jan-03 16:28 
GeneralRe: NT service program swallow up all CPU resource Pin
Tim Kohler19-Jan-03 5:26
memberTim Kohler19-Jan-03 5:26 
GeneralPsExec by SysInternals Pin
Thomas Freudenberg17-Jan-03 4:51
memberThomas Freudenberg17-Jan-03 4:51 
GeneralRe: PsExec by SysInternals Pin
Paul Farry18-Jan-03 13:41
memberPaul Farry18-Jan-03 13:41 
GeneralXCmd Pin
Lau19-Jan-03 16:16
memberLau19-Jan-03 16:16 
GeneralRemote Execution Pin
Golden Lee16-Jan-03 21:55
memberGolden Lee16-Jan-03 21:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web02 | 2.8.160621.1 | Last Updated 17 Jan 2003
Article Copyright 2003 by Tim Kohler
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid