WELCOME

2009年8月12日 星期三

Remote Command Line On Windows

For a while now I’ve been curious if there was a way on Windows to get a remote command line from another computer. You know, just a plain old command prompt, that when you entered commands they ran on a remote computer instead of your own. This is a staple on Linux systems, since they are all based on the command line, but with GUI-based Windows it was proving trickier to do.
I had found some halfway solutions that never seemed to work right, and I wasn’t too happy with any of them. But today I think I finally found the answer I was looking for. It does depend on a free little software download, but aside from that there’s no installation or setup required on either computer.
I first read about it on this site. What you do is go to a certain MS TechNet page and download the PSTools package (linked in the right sidebar). This software is from Sysinternals, a development group that was acquired by Microsoft a couple of years ago. So it’s “official” MS software, much like the PowerToys.
Anyway, here are the instructions for use:
  1. Download PsTools.zip from this site.
  2. Extract to a folder on your hard drive. If you can put them in the path, like in C:\Windows\System32, even better.
  3. Open a Command Prompt: Start > Run > cmd.exe
  4. Change to the directory you extracted the files to: cd c:\pstools, for example.
  5. Enter the command psexec \\RemoteComputer cmd.exe. Replace RemoteComputer with the name of the computer you want to take control of. You have to have admin rights on the remote computer.
  6. A Sysinternals EULA might pop up. Accept it.
  7. Watch as a new command prompt appears in your console window. You’re now controlling the remote computer!
I really think this is something that should be folded into Windows itself. And maybe it will be, since Sysinternals is under Microsoft control now. I know that when I’m working from home, or working on my Tahoe office computers from Carson City, sometimes I just want a command line on the remote computer, especially if I’m doing a little housekeeping behind the scenes while a user is on the computer. Now I can do it with no problem, now that I’ve found this neat little tool.
And PsExec is just one of 12 tools in the PsTools package. The rest of them are probably just as useful.
 
範例:
c:\>psexec \\140.137.215.118 -u bar -p 1234 cmd.exe
C:\>shutdown /s

沒有留言:

張貼留言