Brethern --

This one is killing me. I've got a very simple script that when called from the command line, will stop any service I specify but when over the HTTP, looks like it executes OK but doesn't do anything to the service.

I have gone into the service I want to mess with (under properties), toggled to the "Log on" pane and made sure to check the "Allow service to interact with desktop" for ALL IIS related services.

This is clearly some permissions problem, but I'm stumped. This is WinXP and IIS 6, BTW.

Thanks,
mdog

use CGI qw/:standard escape unescape/; use Win32; use Win32::Service; my $Server = ""; my %statusCode; $statusCode{1} = "Stopped"; $statusCode{4} = "Started"; my $serviceName = $ARGV[0]; my $action = $ARGV[1]; main(); sub main{ print header; print "hi"; stopService($Server,"MSFtpsvc"); #if($action eq "start"){ # startService($Server,$serviceName); #} elsif($action eq "stop"){ # stopService($Server,$serviceName); #} #ServiceState(); } sub ServiceState{ my %status; Win32::Service::GetStatus($Server, $serviceName, \%status); print qq|Service $serviceName is currently: | . $statusCode{$statu +s{CurrentState}} . "\n"; } #********************************************************************* # Stop/Start service sub stopService { my ($Server, $Service) = @_ ; my %status; Win32::Service::GetStatus($Server, $Service, \%status); if($status{CurrentState} eq "4"){ Win32::Service::StopService($Server, $Service); } sleep 5; Win32::Service::GetStatus($Server, $Service, \%status); if($status{CurrentState} ne "4"){ print "$Service is stopped\n"; } } sub startService { my ($Server, $Service) = @_ ; my %status; Win32::Service::GetStatus($Server, $Service, \%status); if($status{CurrentState} ne "4"){ Win32::Service::StartService($Server, $Service); } sleep 5; Win32::Service::GetStatus($Server, $Service, \%status); if($status{CurrentState} eq "4"){ print "$Service is started\n" } }

In reply to CGI + IIS + Win32::Service == Doh! by mdog

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.