We have a crummy legacy Windows application (already discussed here) which replicates content to from a Windows host to many Linux hosts. We several instances of it running on several boxes. Each instance has its own .ini
file containing a list destination servers. Fairly often we need to change the content of these files and restart the process, a process which is done by hand by our ops team. I'd like to replace this with a simple web-based utility (running on a Linux host) which allows users to generate the configuration files, send them to the hosts and restart the services. Generating the files is easy -- I'd probably use Perl and Template Toolkit -- and since the servers export their configuration directories copying the data is relatively easy as well.
What're my options for restarting the Windows services? Win32::Service
? I haven't had a chance to look very far yet so if you say "x::y
makes this easy, but watch out for z" you'd save me a lot of time. Is it even possible? Alternatively, perhaps you could suggest a better way to tackle this problem (replacing the software sadly is not one!) I'm not trying to be lazy, just avoid wasting time fiddling with modules that might not do what I want.
You can use net stop [service name] to stop it and net start [service name] to start it up again basically restarting the service. To combine them just do this - net stop [service name] && net start [service name] .
Start and run the serviceIn Windows, open the Services desktop app. Press Windows+R to open the Run box, enter services. msc, and then press Enter or select OK.
Ubuntu includes a utility that can help with managing Windows systems, wmic
- WMI Client
. With proper permissions, WMI
can easily stop and start Windows services.
(An example from the man page, not on service control.)
EXAMPLE
wmic -U [domain/]adminuser%password //host "select * from Win32_ComputerSystem"
Winexe can do this; it's the Linux equivalent to Sysinternal's very useful PsExec tool.
The last time I used Winexe was a couple of years ago, so this may have changed, but at the time, there were a couple of caveats:
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 dont say about this, but it work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With