I have had the same issue for several years. I don't know of a Perl solution but there is a system level solution that is simple to implement via perl. You can shell out to windows and use the net stop/net send commands to bring down and bring up the server. The main drawback is that, while you can stop all dependant services with one command, you have to start all the services by hand. I have it set up this way.
my @services = qw(MSSQLServerOLAPService SQLServerAgent MSSQLSERVER
+ )
foreach (@services){
my $rtncd = system("net stop $_") >> 8;
# some error checking & other code if wanted
}
foreach (reverse @services){
my $rtncd = system("net start $_") >> 8;
# some error checking & other code if wanted
}
The order of the service shutdown and startup is based on the order of ops I have observed on my system. I've occasionally thought of exploring Win32::API to see if I could access the restart option that way but I haven't found the time yet and this solution has worked solidly for many years.
Hope this helps.
PJ
use strict; use warnings; use diagnostics;