WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: bettman on July 30, 2014, 08:25:38 AM

Title: wntSvcStatus
Post by: bettman on July 30, 2014, 08:25:38 AM
Greetings,

Just wanted confirmation on the usage of wntSvcStatus when checking for the existence of a service. Will the aforementioned function return a 1 if the service exists and a 0 if it does not?

Thank you.
Title: Re: wntSvcStatus
Post by: Deana on July 30, 2014, 09:11:42 AM
WntSvcStatus with a request of 0 (ServiceExist) will returns @FALSE(0) if a service doesn't exist. If the service does exist, it will return a non-zero value.

Code (winbatch) Select
AddExtender('wwwnt34i.dll',0,'wwwnt64i.dll')
result = wntSvcStatus("", "SampleServiceName", 0, 0)
If result
   Pause('wntSvcStatus-ServiceExist','Service Exists!')
Else
   Pause('wntSvcStatus-ServiceExist','Service Does Not Exist!')
Endif
Exit
Title: Re: wntSvcStatus
Post by: bettman on July 30, 2014, 09:18:37 AM
I did see that in the help file; in my testing, a 1 was always returned if a service existed and a 0 if not found. Are you saying that different values could be returned based on found/not found? The reason I'm asking is I'm checking for the existence of three services and adding the results to a variable. If the combined results = 3, my script will advance otherwise it will loop until all three services are found.
Title: Re: wntSvcStatus
Post by: Deana on July 30, 2014, 09:44:08 AM
Yes you can probably expect a return value of 1 if the service exists. However the documentation does seem to indicate it can be a positive integer. To be safe you could create your own counter and increment by one on each positive result.