Archive

Archive for the ‘Sysinternals’ Category

RCMD, the remote command prompt

March 24, 2008 1 comment

Batch IconOne of the most powerful parts of windows is the command line interface (cmd.exe). I have done things from directory listings to adding users locally, editing registry and even as far as manipulating windows services.

Being able to do all this from command line is great, but when you have multiple machines at different locations, It is nice to do some remote work from time to time. In comes PSEXEC from Microsoft’s Sysinternals. using PSEXEC and a little know-how on writing batch files, I created a batch file that will allow me to use the command line interface on remote PC while the user is still logged on.

The batch is as follows

psexec //%1 -u domainname\user -p password c:\windows\system32\cmd.exe

pause

saving this batch file as c:\windows\rcmd.bat will allow you to start the run command and type rcmd computername and you should get a command prompt for that PC (if you are an administrative user on that PC)

This is great for spot checks or quick changes, but when you want to make changes, but when you need to make changes on more than one PC, you can create a batch file with these changes and use PSEXEC to run the batch on a list of workstations.

First you want to create a text file (I call mine hosts.txt) and input each computer name or IP of the workstation (one host per line)

Next is to open up a command line and type in the following

psexec @hosts.txt -u domain\user -p password -c batchfile.bat

To keep things neat and tidy, I generally creatediscriptive folder with psexec, the batch file, the hosts file and a batch including this command called runme.bat.

Advertisements