in reply to Re: Stop/start Windows services with perl
in thread Stop/start Windows services with perl

Gordon,

The application that will utilize this script specifies using only net stop/start commands.

Thanks for the info though

Kris
  • Comment on Re: (2) Stop/start Windows services with perl

Replies are listed 'Best First'.
Re: Re: (2) Stop/start Windows services with perl
by TheFluffyOne (Beadle) on Nov 22, 2003 at 09:17 UTC

    Hmmm... well in that case, I would use something like:

    @rc = `net stop messenger`; if ($rc[1] =~ /success/) { print "Messenger stopped successfully\n"; } else { print "Problem occurred stopping Messenger\n"; } @rc = `net start messenger`; if ($rc[1] =~ /success/) { print "Messenger started successfully\n"; } else { print "Problem occurred starting Messenger\n"; }

    You might also want to run `net start` on its own first and search for the name of the service you're about to start or stop -- that way you'll know whether it's running.

    Gordon