Have you tried?

P:\test>perl -e"system 'net stop mysql'" The MySQL service is stopping. The MySQL service was stopped successfully. P:\test>perl -e"system 'net start mysql'" The MySQL service is starting. The MySQL service was started successfully.

Update: As a footnote. The NET STOP command is documented to take care of stopping and starting dependant services:

The syntax of this command is: NET STOP service NET STOP stops Windows services. Stopping a service cancels any network connections the service is using. Also, some services are dependent on others. Stopping one service can stop others. Some services cannot be stopped. service May be one of the following services: ALERTER BROWSER CLIENT SERVICE FOR NETWARE CLIPBOOK DHCP CLIENT FILE REPLICATION MESSENGER NET LOGON NT LM SECURITY SUPPORT PROVIDER REMOTE ACCESS CONNECTION MANAGER ROUTING AND REMOTE ACCESS RPCLOCATOR SCHEDULE SERVER SPOOLER TCP/IP NETBIOS HELPER SERVICE UPS WORKSTATION NET STOP can also stop services not provided with Windows.

The 3rd paragraph is the relevant one. See the MS docs for what determines whether a service is stoppable or not and what constitutes dependance.

There seems very little logic in trying to re-create the logic built into these system commands when they are readily usable from Perl?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

In reply to Re: Win32 - Dependant services by BrowserUk
in thread Win32 - Dependant services by Smaug

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.