Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

php script to check if a windows service is running?

Thread Tools
 
Search this Thread
 
Old 24 March 2009, 11:23 AM
  #1  
ChristianR
Scooby Regular
Thread Starter
iTrader: (1)
 
ChristianR's Avatar
 
Join Date: May 2001
Location: Europe
Posts: 6,329
Likes: 0
Received 1 Like on 1 Post
Default php script to check if a windows service is running?

Anyone have a php script that can check a server if a windows service is running or not?
Thanks
Old 24 March 2009, 11:42 AM
  #2  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

fsockopen() ?

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 can't claim I know what on earth the above does though I just did a quick google. I'm still learning php

Last edited by Markus; 24 March 2009 at 11:44 AM.
Old 24 March 2009, 11:45 AM
  #3  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

This is another one I found.
Old 24 March 2009, 11:46 AM
  #4  
Iain Young
Scooby Regular
 
Iain Young's Avatar
 
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes on 0 Posts
Default

PHP: win32service - Manual

That should do the job nicely
Old 24 March 2009, 12:25 PM
  #5  
ChristianR
Scooby Regular
Thread Starter
iTrader: (1)
 
ChristianR's Avatar
 
Join Date: May 2001
Location: Europe
Posts: 6,329
Likes: 0
Received 1 Like on 1 Post
Default

cheers guys will take a look. i did google before i posted, but found nothing that was right lol
Old 24 March 2009, 12:41 PM
  #6  
ChristianR
Scooby Regular
Thread Starter
iTrader: (1)
 
ChristianR's Avatar
 
Join Date: May 2001
Location: Europe
Posts: 6,329
Likes: 0
Received 1 Like on 1 Post
Default

fsockopen, wont do what i want unfort.

win32_query_service_status seems ideal, now trying to find some sample code. if you find some post it up!
Old 24 March 2009, 12:57 PM
  #7  
Iain Young
Scooby Regular
 
Iain Young's Avatar
 
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes on 0 Posts
Default

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
}
Old 24 March 2009, 02:52 PM
  #8  
ChristianR
Scooby Regular
Thread Starter
iTrader: (1)
 
ChristianR's Avatar
 
Join Date: May 2001
Location: Europe
Posts: 6,329
Likes: 0
Received 1 Like on 1 Post
Default

i need win32_query_service_status to query a service on another machine
Old 24 March 2009, 03:02 PM
  #9  
Iain Young
Scooby Regular
 
Iain Young's Avatar
 
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes on 0 Posts
Default

$svcStatus=win32_query_service_status ('ServiceName', 'MachineName');
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Scott@ScoobySpares
Full Cars Breaking For Spares
61
11 January 2021 03:08 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
33
29 August 2017 07:18 PM
Scott@ScoobySpares
Full Cars Breaking For Spares
7
14 December 2015 08:16 AM
MeisterR
Car Parts For Sale
1
15 September 2015 07:07 PM



Quick Reply: php script to check if a windows service is running?



All times are GMT +1. The time now is 06:19 PM.