Starting and stopping Windows services from Unix

Posted by: wfaulk

Starting and stopping Windows services from Unix - 29/11/2004 17:59

Windows's NET START and STOP commands can be directed to another computer, so that I can shut down services on one machine without having to log into it directly.

Is there any utility under Unix that anyone knows of that would allow me to do the same thing -- that is, shutdown and restart a Windows service on an (obviously) remote computer.
Posted by: andy

Re: Starting and stopping Windows services from Unix - 29/11/2004 19:25

One way is to install sshd on the Windows box, then you can ssh in and run any command line tools you like.

It can be a pig to get sshd installed on Windows, I think I used this http://sshwindows.sourceforge.net/ installer in the end on my Windows server.

Edit: How annoying. Just checked out the "net" command via ssh on my Windows box. While running "net" commands do work, you don't get to see the output of the command. It must be doing something non-standard to output its text.

Typical...
Posted by: andy

Re: Starting and stopping Windows services from Unix - 29/11/2004 19:33

Doing some googling seems to indicate this net.exe problem is specific to some versions of the cygwin dll.
Posted by: wfaulk

Re: Starting and stopping Windows services from Unix - 29/11/2004 19:45

Yeah, I thought of that way, and I don't like that way. Windows already has RPC commands to do exactly what I want; I should be able to use them directly.

Also, it seems that NET START doesn't work remotely. You have to use a command called SC to start services remotely. I think it's part of the Resource Kit.
Posted by: tfabris

Re: Starting and stopping Windows services from Unix - 29/11/2004 19:46

Interesting, I have been using NETSVC from the resource kit, I hadn't heard about SC.
Posted by: PaulWay

Re: Starting and stopping Windows services from Unix - 29/11/2004 20:08

Thinks: The Perl Win32:: modules have code in them to start and stop services. I'd have to look through them to be sure, but I'd imagine there's a facility in there to be able to specify which machine you wanted to perform this on (not just local). And I'm pretty sure they're portable to non-Win32 systems. Have a look at those...

I suppose they might rely on running on a Windows machine in order to access the Win32 API. Maybe the details of the Win32 RPC protocol hasn't been fully reverse engineered^dbdbscrutinised. Maybe the Perl modules are just front-ends to binary backends which can only run on a Win32 machine. None of these would surprise me given Microsoft's stinginess with publishing standards (and record for disobeying its own). So it's probably 50/50.

Just a thought,

Paul
Posted by: andy

Re: Starting and stopping Windows services from Unix - 29/11/2004 20:10

It looks like using RPC from Linux to Windows is in theory possible:

http://blogs.cocoondev.org/michaelm/archives/002118.html

Can't find and examples of an implementation though.
Posted by: wfaulk

Re: Starting and stopping Windows services from Unix - 29/11/2004 20:17

Yeah. Win32:Services, apparently. Won't even begin to install on my Solaris machine. Looks like it depends on some Win32 stuff that would be built into the base Perl.
Posted by: wfaulk

Re: Starting and stopping Windows services from Unix - 29/11/2004 21:11

It looks like Samba's rpcclient program almost does what I want (in that it seems to deal with the same sorts of remote things), except that (1) it doesn't seem to do exactly what I want, and (2) doesn't seem to actually work in doing the things it claims to do.
Posted by: andy

Re: Starting and stopping Windows services from Unix - 30/11/2004 06:59

I found the same problem when I tried playing with it last night.