Is there a way to stop a windows service (possibly on a remote machine) using ruby?
+3
A:
The %x command, and Windows command line utilities like "AT" and "NET STOP".
e.g.
@result = %x[AT \\computername 00:00 "NET STOP service"]
00:00 being the current time plus a reasonable buffer to account for the clocks being out of sync. Also, the AT command requires elevation on Vista/Server 2008/Windows 7.
cdonner
2009-10-02 18:06:28
I've used "net" many times, although I've switched to "sc" which has more capability than "net" (and looks more logical since most services have nothing to do with "net"working.) :)http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx
JMD
2009-10-02 18:30:53
SC is better, since it works remotely without the help of the AT command ...
cdonner
2009-10-02 18:39:45