![]() |
General Programming »
Internet / Network »
General
Advanced
Remote processes and machine control of Windows NT based systems (2000/XP)By Prateek KaulTrigger/monitor/kill processes and shutdown/reboot machines remotely. |
VC6, VC7, VC7.1Win2K, WinXP, Win2003, MFC, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Fig. 1 Client application running with various context menu(s)
There are times as a Windows network administrator you would like to control certain aspects of machines sitting remotely, without having to install and trigger an application on the remote machine which will communicate with the administrator's machine.
Add a machine whose control is required and processes to be monitored (refer fig. 2).

Fig. 2 Adding a machine
In case of an error, an information balloon will be shown in the system tray as shown in fig. 3.

Fig. 3 Information balloon

Fig. 4 Timer refresh rate
Save the connected machine(s) information to the requested directory. All machine monitoring can again be loaded while using the File -> Open command, without adding all machines individually.
Security note:- Currently the administrator passwords are just serialized to a file without encryption. Hence, one can see the passwords by just opening the file in a normal text editor.

Fig. 5 Client application with the server executable embedded in it's resources
The client application holds the server application (executable) in it�s resource section, like any other resource, viz., bitmaps, icons, menus etc. (refer fig. 5).
WNetAddConnection2().
(CRemoteAdministrator::EstablishAllConnections() in the
accompanying project).
CRemoteAdministrator::
CopyServiceExeToRemoteMachine() in the accompanying project) Refer fig. 6 for the remote copying scheme

Fig. 6 Server executable copying scheme
The client application gets the HANDLE to the service manager of the remote machine, as an IPC connection has been established above. The client application then starts the server executable copied in the remote machine�s System32 directory as a service. This all is independent, done automatically and is unknown to user of the remote machine.
RemoteAdminProcessInfoThread())
RemoteAdminExecuteProcessThread())
RemoteAdminKillProcessThread())
RemoteAdminSysShutdownThread())
The client is a standard SDI application based on MFC�s document/view architecture. The important classes in the client application are :
CMachineInfo : This class holds the HANDLES to four named pipes
with which a remote machine connection has been established for requesting
different tasks (remote process read, start, kill and machine shutdown/reboot).
This class also holds a list of current processes on the remote machine. It also
contains strings for password, IP and logon type (which has to be Administrator
only). CMachineInfo is derived from MFC�s Cobject so
that it can be serialized.
CRemoteAdministrator : This class handles all the network
communication based on named pipes with different remote machines. This class
holds a list of CMachineInfo objects. This
CMachineInfo list can be serialized to a file and loaded later.
CRemoteAdminDoc : This is the MFC�s CDocument
derived class which holds all data regarding the application. This class holds
the only object of CRemoteAdministrator. RemoteAdminProcessInfoThread(),
RemoteAdminExecuteProcessThread(),
RemoteAdminKillProcessThread(),
RemoteAdminSysShutdownThread()).
UpdateProcessInfoList()).
lServicePipeInstanceCount is incremented. Similarly, when a named
pipe is disconnected, it is decremented. When there are no named pipes
(lServicePipeInstanceCount == 0), the server application is stopped
and deleted from the remote machine. Inspired by the tools at Sysinternals. Thanks to Zoltan Csizmadia for sharing his code).
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 26 Aug 2003 Editor: Chris Maunder |
Copyright 2003 by Prateek Kaul Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |