|
|
|||||||
How can I tell if a service is running? I tried several of the examples posted but none seem to work correctly. Need to check if "Norton AntiVirus Server" is running. Thanks |
||||||||
|
|
|||||||
Please take a look at the UDF Forum, as it contains a couple of 'check service' UDFs or search the UDF Forum for 'service'. |
||||||||
|
|
|||||||
Those examples seem a little much for a starter. |
||||||||
|
|
|||||||
Although not elegant and does little else, this will tell you if the service is running... code:For example: servicestate("Spooler") returns "Running"function servicestate($_service,optional $remotepc) Just threw this together so please be understanding if it contains a bug or two, but it did work in my simple test above. [ 27. May 2003, 22:11: Message edited by: Al_Po ] |
||||||||
|
|
|||||||
Then please take a look at the FAQ Forum under How to use UDFs |
||||||||
|
|
|||||||
Al_Po's example requires WMI and will thus only work under Windows 2000/XP/2003 by default. Also, there are already a total of eight UDFs dealing with this issue usng different approaches. |
||||||||
|
|
|||||||
I see all the approaches but I'm having difficulty following them. I guess I will try to figure it out on my own. |
||||||||
|
|
|||||||
give me a chance to get home and I will walk you through an example. About 5:30 PM EST I will be back online. |
||||||||
|
|
|||||||
If you have Win2000 or higher the above script should do the trick... What OS are you running? Another Example... If servicestate("Norton Antivirus Server") = "Running" ...your code here... endif |
||||||||
|
|
|||||||
I will be on and off the forum. Let me know if you want to discuss an example. |
||||||||
|
|
|||||||
Sure. I'm looking at one called active service. |
||||||||
|
|
|||||||
have you tried xnet ? Xnet is written by Ruud and is since ever then in the KiXtart distribution |
||||||||
|
|
|||||||
ActiveServive(Service) is nothing more than a wrapper for using XNET.exe which is a utility in your KiXtart distribution. Read the XNET help file. Then look at this code again. It just calls XNET, reports the return and returns a value for NT. The @WIN = 1 means NT. The else would be for Win9x computers and it checks the registry for Win9x services. |
||||||||
|
|
|||||||
Check out fADSIServiceRun(). This code uses ADSI via COM to work with services. In it is simple code that will show how to get the status of a service. code:$objService = Getobject("WinNT://$Computer/$Service,Service") [ 28. May 2003, 00:16: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Jochen, thanks. That works fine. Howard, I understand the points that you brought up but what I didn't underdstand was the $servicename. Where is that being declared? Above this script? Thanks |
||||||||
|
|
|||||||
Usage: $active=ACTIVESERVICE("WINS") code:$servicename in the above example is "WINS" which was passed into the function when used in the script.function activeservice($servicename) The function definition specified what parameters are to be accepted by a function. These parms can be mandatory or optional. See the FUNCTION command in the docs. [ 28. May 2003, 00:24: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Thanks Howard. I appreciate your help. |
||||||||
|
|
|||||||
Any other questions? |
||||||||
|
|
|||||||
Here is a version tailored to what you want to find. Reading and Experimenting will help increase your knowledge as well. When you have time please review the KiXtart manual as well as the FAQ section here on the board. You can also download the HELPFILE from my site (the link is in my signature) From a DOS prompt on either Windows 2000 or XP : Using KiXtart v4.21 NOTICE: The remote system must have WMI installed. 2000/XP have it by default, NT 4 does not. Please review this FAQ for further information on this. http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=10;t=000048 C:\SCRIPTS\KIX32.EXE CHECKNAV.KIX [ 28. May 2003, 00:56: Message edited by: NTDOC ] |
||||||||
|
|
|||||||
Long line police. You're busted DOC |
||||||||
|
|
|||||||
I'll leave it for noobies. Don't want them to confuse them with where/how lines can be broken. |
||||||||
|
|
|||||||
jhansenjr, you must also realize that service name come in two flavors. short name as used in the registry services key and the display name. Ths can be easily seen by using SCLIST.exe. code:Some methods may want the short name and others may want the long name. Some don't care.Alerter Alerter Here something not from Microsoft: http://www.jsifaq.com/SUBL/tip5900/rh5936.htm [ 28. May 2003, 01:01: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Thank you everyone for your help. |