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 Mar 24, 2009 | 11:23 AM
  #1  
ChristianR's Avatar
ChristianR
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: May 2001
Posts: 6,329
Likes: 1
From: Europe
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
Reply
Old Mar 24, 2009 | 11:42 AM
  #2  
Markus's Avatar
Markus
Scooby Regular
25 Year Member
 
Joined: Mar 1999
Posts: 25,080
Likes: 0
From: The Great White North
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; Mar 24, 2009 at 11:44 AM.
Reply
Old Mar 24, 2009 | 11:45 AM
  #3  
Markus's Avatar
Markus
Scooby Regular
25 Year Member
 
Joined: Mar 1999
Posts: 25,080
Likes: 0
From: The Great White North
Default

This is another one I found.
Reply
Old Mar 24, 2009 | 11:46 AM
  #4  
Iain Young's Avatar
Iain Young
Scooby Regular
 
Joined: Sep 1999
Posts: 6,956
Likes: 0
From: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Default

PHP: win32service - Manual

That should do the job nicely
Reply
Old Mar 24, 2009 | 12:25 PM
  #5  
ChristianR's Avatar
ChristianR
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: May 2001
Posts: 6,329
Likes: 1
From: Europe
Default

cheers guys will take a look. i did google before i posted, but found nothing that was right lol
Reply
Old Mar 24, 2009 | 12:41 PM
  #6  
ChristianR's Avatar
ChristianR
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: May 2001
Posts: 6,329
Likes: 1
From: Europe
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!
Reply
Old Mar 24, 2009 | 12:57 PM
  #7  
Iain Young's Avatar
Iain Young
Scooby Regular
 
Joined: Sep 1999
Posts: 6,956
Likes: 0
From: Swindon, Wiltshire Xbox Gamertag: Gutgouger
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
}
Reply
Old Mar 24, 2009 | 02:52 PM
  #8  
ChristianR's Avatar
ChristianR
Thread Starter
Scooby Regular
iTrader: (1)
 
Joined: May 2001
Posts: 6,329
Likes: 1
From: Europe
Default

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

$svcStatus=win32_query_service_status ('ServiceName', 'MachineName');
Reply
Related 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
MeisterR
Car Parts For Sale
1
Sep 15, 2015 07:07 PM




All times are GMT +1. The time now is 04:48 AM.