php script to check if a windows service is running?
fsockopen() ?
I can't claim I know what on earth the above does though
I just did a quick google. I'm still learning php
Code:
if ($handle = fsockopen ('localhost', 80, $errnum, $errmsg, 1))
{
echo ('A web server is running on this system<br>');
fclose ($handle);
}
else
{
echo ($errnum . ' ' . $errmsg . '<br>');
echo ('A web server is not running on this system<br>');
}
if ($handle = fsockopen ('localhost', 443, $errnum, $errmsg, 1))
{
echo ('A secure web server is running on this system<br>');
fclose ($handle);
}
else
{
echo ($errnum . ' ' . $errmsg . '<br>');
echo ('A secure web server is not running on this system<br>');
}
A web server is running on this system
Warning: fsockopen() [function.fsockopen]: unable to connect to
localhost:443 (A connection attempt failed because the connected party
did not properly respond after a period of time, or established
connection failed because connected host has failed to respond. ) in D:
\Gordon McVey\apachedev\cmsNew\index.php on line 18
10060 A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond.
A secure web server is not running on this system
I just did a quick google. I'm still learning php
Last edited by Markus; Mar 24, 2009 at 11:44 AM.
Scooby Regular
Joined: Sep 1999
Posts: 6,956
Likes: 0
From: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Scooby Regular
Joined: Sep 1999
Posts: 6,956
Likes: 0
From: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Sorry, not tried using it myself, so I have no sample code. Looking at the manual pages, there is an example for win32_set_service_status so it should be easy enough to work it out 
Maybe something like (pseudo code)...
$svcStatus=win32_query_service_status ('ServiceName');
if $svcStatus[1] == WIN32_SERVICE_RUNNING
{
display it's running message
}

Maybe something like (pseudo code)...
$svcStatus=win32_query_service_status ('ServiceName');
if $svcStatus[1] == WIN32_SERVICE_RUNNING
{
display it's running message
}
Trending Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
34
Nov 7, 2024 04:10 PM
Scott@ScoobySpares
Full Cars Breaking For Spares
61
Jan 11, 2021 03:08 PM
Scott@ScoobySpares
Full Cars Breaking For Spares
7
Dec 14, 2015 08:16 AM





