I have some command-line commands to execute on a Windows machine. The programs I need to run are only available on Windows.

Is there a way to easily to do something like I would do with SSH? Example of what I mean:

ssh username@windows-box.mycompany.com "remote command to execute"

...or do I have to Remote Desktop just to do this? (I'd like to run the commands programmatically from another computer rather than running them by hand.)

link|improve this question

2  
Belongs on superuser.com – Paul R Mar 31 '10 at 13:41
I thought that too for a bit... but this is part of a programming project in which I would like to distribute some tasks to Windows computers, so I thought it would be better here. – Benjamin Oakes Mar 31 '10 at 13:56
So, am I correct in reading between the lines that this "other computer" is not running windows, and that this is the reason you want/need to execute these commands remotely? – SamB Apr 24 '10 at 15:41
@SamB: Yes, that's correct. I'm using Ubuntu on my main machine. – Benjamin Oakes Apr 26 '10 at 19:52
feedback

migrated from stackoverflow.com Mar 31 '10 at 16:43

This question came from our site for professional and enthusiast programmers.

5 Answers

up vote 6 down vote accepted

One approach, of course, is to actually run an SSH server on the windows box. But a more Windows-focused solution is a tool from the SysInternals folks (now part of Microsoft) called PsExec, which is designed to do exactly what you want.

link|improve this answer
1  
But PsExec only runs on Windows systems, right? – SamB Apr 24 '10 at 15:49
feedback

You need a SSH server running on windows. like http://www.kpym.com/2/kpym/index.htm

There isnt any installed by default, And I have been using this for some time. it is good

link|improve this answer
Remark, this solution does not support key authentication. – Sorin Sbarnea Sep 7 '10 at 7:58
feedback

You can use the freesshd server from fresshd.com. It does work great, you will set-up the server in seconds :)

link|improve this answer
This looks as a nice solution but, the forum is down (cannot post) and it looks that it doesn't allow domain logins. – Sorin Sbarnea Apr 30 '10 at 12:36
Also, this is only 'free', meaning that every time you do a SSH it will display you a login message asking you to register(buy) it, you have to wait 5+ seconds to be able to continue. – Sorin Sbarnea Sep 7 '10 at 8:18
Remark, this is a slow SSH server. – Sorin Sbarnea Sep 7 '10 at 8:20
feedback

I've had a lot of good experience installing cygwin and its sshd port. There are wrappers which will turn it into a windows service, and you get the bash shell as an extra.

http://chinese-watercolor.com/LRP/printsrv/cygwin-sshd.html is a decent starting point, you can evaluate if it is what you want.

link|improve this answer
Agreed, cygwin + ssh is nice and easy, and you get a conveniently unix-like shell and environment to run your programs from. If you like ssh, you probably already know Unix. – apenwarr Mar 31 '10 at 15:24
feedback

you can install an SSH server on your Windows machines, or you can turn on Terminal services on windows (check your documentation), and then use Perl(or Python) to do a telnet to the server to execute your commands. See Net::Telnet(Perl) for examples of connecting through telnet

link|improve this answer
Well, it's all fine and dandy to say RTFM, but that would be easier if we could find said manual... any tips, such as the name of page and maybe an MSDN/Technet link -- especially now that it seems like MS may have finally learned the value of an URL? – SamB Apr 24 '10 at 15:53
Also, isn't there some registry change needed to get it let you have more than one logged-in session at the same time on anything less than Server? I doubt MS would want to make the docs for that easy to find, assuming that there are any docs for that... – SamB Apr 24 '10 at 20:27
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.