G
I want to create a web-based tool that will allow me to stop and start
a specfic service.
I was able to use the sample code to generate a list of all services
and, for each, its corresponding status.
What I am unable to do is stop or start a service using StopService or
StartService. I am using the translated/hashed/keyed value as the
parameter. For example, instead of using "WebTrends Reporting UI", I
am using "wtinterface", but it still does not work.
I thought it might be permissions inside the web browser (web server
running as System account), but when I run my test script from the
command line as administrator, it doesn't work either. My stop script
is listed below.
Any suggestions?
Thanks!
-peter
use strict;
use warnings;
use Win32::Service qw[GetServices GetStatus StartService StopService];
print "Content-type: text/html\n\n";
my (%status);
print "<STRONG>WebTrends Reporting UI</STRONG><BR><BR>\n";
GetStatus('', 'wtinterface', \%status);
foreach (keys %status)
{
if ($_ eq 'CurrentState')
{
print "The current status is $status{$_}.<BR>\n" ;
}
}
StopService('', 'wtinterface');
print "The service was stopped (I think).<BR>";
GetStatus('', 'wtinterface', \%status);
foreach (keys %status)
{
if ($_ eq 'CurrentState')
{
print "The current status is $status{$_}.<BR>\n" ;
}
}
a specfic service.
I was able to use the sample code to generate a list of all services
and, for each, its corresponding status.
What I am unable to do is stop or start a service using StopService or
StartService. I am using the translated/hashed/keyed value as the
parameter. For example, instead of using "WebTrends Reporting UI", I
am using "wtinterface", but it still does not work.
I thought it might be permissions inside the web browser (web server
running as System account), but when I run my test script from the
command line as administrator, it doesn't work either. My stop script
is listed below.
Any suggestions?
Thanks!
-peter
use strict;
use warnings;
use Win32::Service qw[GetServices GetStatus StartService StopService];
print "Content-type: text/html\n\n";
my (%status);
print "<STRONG>WebTrends Reporting UI</STRONG><BR><BR>\n";
GetStatus('', 'wtinterface', \%status);
foreach (keys %status)
{
if ($_ eq 'CurrentState')
{
print "The current status is $status{$_}.<BR>\n" ;
}
}
StopService('', 'wtinterface');
print "The service was stopped (I think).<BR>";
GetStatus('', 'wtinterface', \%status);
foreach (keys %status)
{
if ($_ eq 'CurrentState')
{
print "The current status is $status{$_}.<BR>\n" ;
}
}