meet_arc has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monk friends, I am a beginner to Perl script. But I want to Start / Stop window service(In Control Panel>Administrative tools>Services) by using Perl script. Eg: Suppose I want to Start / Stop "SQL Server" service, then I should be able to do it by just executing Perl Script. Can someone help me doing this, or can provide me a script with steps of execution? I need it very badly friends. Thanks in advance for your help and support. Regards.
  • Comment on Want to Start / Stop windows service through executing Perl Script

Replies are listed 'Best First'.
Re: Want to Start / Stop windows service through executing Perl Script
by BrowserUk (Patriarch) on Jun 01, 2009 at 09:23 UTC
      Thanks a lot BrowserUk for your solution. I am able to get desired output succesfully with ur comments. I would also like to enhance my this script. I would now like to go to remote level, I mean to say I would like to Start / Stop service running on other machine, by running script on my desktop machine. Can you please help me wayout?

        Did you look at the help for the net command? Did you search google? Perhaps the sc command is also of interest. Note that sc comes as standard on xp, Windows 2003 (and I believe above), it may be on one of the resource CDs for windows 2000/NT4

        Martin

Re: Want to Start / Stop windows service through executing Perl Script
by marto (Cardinal) on Jun 01, 2009 at 07:05 UTC
      Thnx Martin for replying. Can you please provide me a small sample script?

        What code have you written and how does it fail for you?

        Perlmonks is not a code writing service, so please show us what efforts you've made and where you encountered problems.