Skip navigation

Remote Command Service

Remotely administer and run command-line programs

As an IT professional, you'd rather remotely control your system from the comfort of your desk than walk to the server room every time you need to make changes. And you probably also would like to reduce the number of Windows 2000 Server Terminal Services sessions you must open every time you want to run tasks or commands on the system. The Microsoft Windows 2000 Resource Kit's Remote Command Service tool, which lets you remotely administer and run command-line programs, can help you realize those goals.

I work in an environment that has more than 300 servers, about 40 of which are Citrix MetaFrame Windows XP servers. MetaFrame servers provide the same services and therefore tend to be identical in terms of hardware and software, so any changes I make to one server must be replicated to the rest of the servers—in my case, that means 40 Terminal Services or ICA sessions. Remote Command Service gives me an easier and more efficient way to perform these simple tasks. The tool can't perform miracles, but it can remotely handle a lot of the daily administrative tasks that otherwise require local logons. Let's look at some examples of how you can use this tool.

Uses for Remote Command Service
One command I frequently use is Change Logon, which lets you enable or disable user logons to a Terminal Services session. When you set Change Logon to disable, new users can't establish new connections to the server. You can also use this command to determine whether the user logon session mode status is enabled or disabled. Before I installed Remote Command Service, every time I wanted to perform maintenance on a server or prevent user logons to one or more servers, I had to log on and run Change Logon locally or install the Citrix management console locally, then use a GUI. The process was lengthy and required several steps to accomplish one simple task. After I installed Remote Command Service, I could enable, disable, or query any server from a command-line window on my workstation.

You can also use Remote Command Service to obtain a directory listing of files on a particular server (i.e., a simple Dir command) or to share a folder on that server. You can use the tool in conjunction with the Net Share command to remotely share and unshare directories. If you want to map a drive on one or more servers, you can use Remote Command Service with Net Use instead of logging on to the servers. And you can use the tool in scripts to deal with frequently used commands or tasks.

Installing and Using the Tool
To install and use the tool, install a copy of the resource kit on your machine. By default, the resource kit installs in \%systemroot%\Program Files\Resource Kit and stores the Remote Command Service files in a subdirectory named RCMD. The directory will contain two files: rcmd.exe, the file you use to launch the command-line client (you can copy and use this client on any machine from which you want to initiate commands), and rcmdsvc.exe, the server component that you install on every server or workstation you want to run remote commands on. The rcmd.exe file creates a command session, or "virtual console," whenever a client connects to the server. You can simultaneously connect as many as 10 clients to the remote command server on a computer, and all the clients operate securely and independently of one another.

To install rcmdsvc.exe, log on as an administrator to the XP, Win2K, or Windows NT 4.0 machine you want to run remote commands on, copy the file into \%systemroot%winnt\system32, and type

rcmdsvc -install

at the command prompt. To start the service, type

net start rcmdsvc

You can now copy the rcmd.exe file to any location and start using it. Open a command prompt, and browse to the directory in which you saved the rcmd.exe file. Enter the Rcmd command. The Help files specify the Rcmd command parameters as

rcmd \[server_name \[command\] \]

Although these parameters aren't difficult to understand, they don't follow the traditional format conventions that Microsoft uses for command strings. Here's a simpler and easier format that you can use:

rcmd \\<servername> <command>

where servername is the name of the server you want to remotely execute a command on and command is the tool or utility you want to run on that server to execute a particular task. This command opens a command-line session with the specified server. Or, you can simply type

rcmd

at the command prompt, in which case you'll be prompted to enter a server name. Exit this mode by typing

exit

or by pressing Ctrl+Break.

You can use the following commands to apply some of the previously mentioned examples. (To execute these commands, user accounts will require some level of administrative privileges.)

Code to enable, disable, or query a server:

rcmd \\bartsvr change logon /disable
rcmd \\bartsvr change logon /enable
rcmd \\bartsvr change logon /query

Code that uses the Net Share command to share and unshare a directory listing:

rcmd \\bartsvr net share sharename=path to share directory
 (e.g., D:\software)
rcmd \\bartsvr net share sharename /delete /y

Code to display a directory listing on the remote server:

rcmd \\bartsvr dir

Code to map a drive to a shared resource on the remote server:

rcmd \\bartsvr net use x: \\homersvr\software
rcmd \\bartsvr net use x: /delete

If you want to uninstall rcmdsvc.exe from the host server, log on to that server with an account that has administrative rights, open a command prompt, and type

rcmdsvc -uninstall

The following script is an example of how to use Rcmd in a script. The script uses rcmd.exe to clear the Print Spooler files and restart the service.

rcmd \\bartsvr net stop "Print Spooler"
rcmd \\bartsvr del  %windir%\system32\spool\printers\*.* /q
rcmd \\bartsvr net start "Print Spooler"

Remote Control Freedom
Now that you know about the Remote Command Service, you no longer have to run Terminal Services sessions to execute certain commands from the command prompt. You can even incorporate the tool into your scripts and schedule them to run automatically, thus eliminating or minimizing user interaction. Tools such as Remote Command Service bring you one step closer to total remote control capability and the freedom to manage and troubleshoot your system from virtually anywhere in the world.

TAGS: Windows 7/8
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish