Restarting a Windows service from a Linux window

We have an outdated legacy Windows application (already discussed here ) that copies content from a Windows host to many Linux hosts. We have several cases where it works on multiple mailboxes. Each instance has its own .ini file containing the list end servers. Quite often, we need to change the contents of these files and restart the process, which is performed manually by our ops team. I would like to replace this with a simple web-based utility (running on a Linux host) that allows users to create configuration files, send them to hosts, and restart services. Generating files is easy - I would probably use Perl and the Template Toolkit, and since servers export their configuration directories by copying data, it is also relatively easy.

What are my options for restarting windows services? Win32::Service ? I didnโ€™t have the opportunity to look very far, so if you say โ€œ x::y makes it easy, but watch out for zโ€, you would save me a lot of time. Is it possible? Alternatively, perhaps you could suggest a better way to solve this problem (replacing the software, unfortunately, not one!) I'm not trying to be lazy, just not wasting time driving with modules that might not do what I want .

+4
source share
6 answers

Ubuntu includes a utility that can help manage Windows systems, wmic - WMI Client . With the correct permissions, WMI can easily stop and start Windows services.

(example from the man page, not for service management.)

Example

wmic -U [domain /] adminuser% password // host "select * from Win32_ComputerSystem"

+3
source

Winexe can do this; it is the Linux equivalent, equivalent to Sysinternal, a very useful PsExec tool.

The last time I used Winexe was a couple of years ago, so this could change, but there were a few caveats at the time:

  • Terminal processing was not well implemented, so entering non-alphanumeric keys into a remote command can be strange. If you are working with a script, this should not be a problem.
  • Like PsExec, Winexe works by installing a service in a Windows window, and then informing the service about the launch of a command. Unlike PsExec, after that the service was not cleared. The installed service is harmless and does not start when Winexe does nothing, so it is pretty safe.
+2
source

You can use Winexe

 $ winexe -U HOME/Administrator%'Pass123' //host 'cmd /C net stop wuauserv && net start wuauserv && echo AutoUpdates service restarted' 

The password is written between '' <- Manual does not say this, but it works.

+2
source

You can restart the Windows service from the Windows command line using:

 net stop service_name net start service_name 

You can find the service name by clicking properties in the Services window.

This may help you script.

+1
source

The most specific way would be to create a web service that handles updating ini and restarting services, but given that this is an internal solution that is likely to be massive redundant.

0
source

I usually include telnet, telnet in the field remotely and use "net stop ServiceName" and "net start ServiceName".

0
source

All Articles