Get Command Prompt On Remote System
Thanks for visiting Daily Cup of Tech!
Here are a few things that you may want to do while you are visiting:
- Subscribe to the RSS feed
- Take a theme tour and check out some of the best DCoT posts
- Check out our latest posts
Even though Windows is extremely GUI friendly, I find that if you really want to do some fine tune high end geeky things on your Windows computer, you pretty much need to do it from a command line.
For those of you who know the power of the command line, you also know that it is really useful to be able to run some of these command line tools remotely. There are a number of different ways to do this. I would like to share with you a couple of my favorites.
PsExec
If you are not familiar with PsExec, then this is going to be a bit of a revelation for you. PsExec is a freeware program that allows you to execute a command on a remote machine. If that command is a command line program, it will send the output of that command back to you.
The real trick comes when you run the command console. Try this command:
psexec \\RemoteComputer cmd.exe
where \\RemoteComputer is the name or IP address of the remote computer (Make sure you use the \\ otherwise the command will fail.)
What this does is connect to the remote computer and then open a command prompt on the remote machine. You can then work with this new command prompt and it will execute all of your actions on the remote system!
In order for this to work for you, you need to have the admin$ share active on the remote computer (which it is by default) and you need to have account information with administrative access to the system. This is mainly used in situations where you have a Windows network and you are the administrator of the network.
SSH on Windows
If you have the time to set up something a bit more elaborate, I would recommend using SSH on your computer. If you set it up properly, you can have remote command access to your computer just by having access to one port. This will then establish an encrypted command line session to the computer.

The other nice part of this is that you can get secure remote access to the computer running SSH from any computer on the Internet by simply forwarding one port on your external firewall to your internal system and pointing your SSH client to your firewall’s external IP address.
If you need a free SSH server for Windows, I would suggest freeSSHd. As for an SSH client, you can’t go wrong with PuTTY.
If you found this post useful, why don't you buy me a cup of coffee to show your gratitude?
5 Responses to “Get Command Prompt On Remote System”
-
Rob Dunn Says:
July 16th, 2007 at 8:26 amYou can also use the telnet service, which comes with Windows 2000 on up (even on workstation). I use a script to enable the Telnet service, connect, and then disable after I’m done. SSH would be the best thing to use, of course, but in a pinch, Telnet works.
Telnet gives you pretty much unfettered command-line access to the remote computer. You still run into issues if you need to run a command for a particular user (you can use runas), but otherwise, it is great for things like ipconfig, and other general workstation-like tasks.
Rob
-
syahid ali Says:
July 17th, 2007 at 5:00 amtelnet is okay but prone to sniffers.
-
Eric Greer Says:
July 19th, 2007 at 9:09 amAs for the first part of this, I posted a batch ’shortcut’ to run things on lots of remote computers in 2 easy steps. That file is here: http://blog.integrii.net/?p=20
I also made this little PowerShell script to help with this task too. http://blog.integrii.net/?p=56
Definately useful!
-
Malcolm Says:
August 21st, 2007 at 6:01 pmI’ve been using putty -> sshd on Linux followed by a ssh to internal Windows2000 server AD master and ISA proxy. From there I can remotely administer the server. I can map internal workstation drives for individual attention but I am unable to connect using
psexec \\workstationname cmd.exe
I have tried with the -u -p options and the -s option.
Using version 1.8.5 the process apears to hang, not returning me to a command prompt.
Using version 1.63 I get the errorcmd exited on workstationname with error code 0.
Any idea what could be causing this or ways to work round it?
Many thanks! -
Matt Says:
October 1st, 2007 at 10:12 amI’m seeing the same problem. I can get around it by using the -d argument, but that means I don’t get back the return code from the process I started remotely.
It gives the workaround, but not ideal.
