- Aug
- 2,152
- 92
This is a follow-up to the “Windows XP Services” thread in the “T&T – Scripting” section of the forums.
Here is another method to determine if a service is Started or Stopped.
In this example, I have created a new function as follows;
To see if the Print Spooler is active, I do the following;
which returns;
This tells me that the Print Spooler is Started.
If I do the following to Stop the Print Spooler;
and use the function again;
it returns;
To get a list of all the functions that are currently running on your XP system, do the following;
On my XP system, this returned;
The @isservice function can use any of these services as a parameter.
This function makes it easy to determine the status of my F-Prot Anti-virus program from a batch file;
Hope you find the @isservice function useful.
Joe
Here is another method to determine if a service is Started or Stopped.
In this example, I have created a new function as follows;
Code:
isservice=`%@exec[sc query | find /i "SERVICE_NAME: %1"]`
Code:
echo %@isservice[spooler]
Code:
SERVICE_NAME: Spooler
0
If I do the following to Stop the Print Spooler;
Code:
net stop spooler
Code:
echo %@isservice[spooler]
Code:
1
Code:
sc query | find /i "SERVICE_NAME:"
Code:
SERVICE_NAME: ALG
SERVICE_NAME: Ati HotKey Poller
SERVICE_NAME: AudioSrv
SERVICE_NAME: BITS
SERVICE_NAME: BOINC
SERVICE_NAME: Bonjour Service
SERVICE_NAME: Browser
SERVICE_NAME: CCALib8
SERVICE_NAME: DcomLaunch
SERVICE_NAME: Dhcp
SERVICE_NAME: dmserver
SERVICE_NAME: Eventlog
SERVICE_NAME: EventSystem
SERVICE_NAME: FastUserSwitchingCompatibility
SERVICE_NAME: FPAVServer
SERVICE_NAME: HidServ
SERVICE_NAME: hpqcxs08
SERVICE_NAME: hpqddsvc
SERVICE_NAME: HPSLPSVC
SERVICE_NAME: HTTPFilter
SERVICE_NAME: JavaQuickStarterService
SERVICE_NAME: lanmanserver
SERVICE_NAME: lanmanworkstation
SERVICE_NAME: Netman
SERVICE_NAME: Nla
SERVICE_NAME: PlugPlay
SERVICE_NAME: PolicyAgent
SERVICE_NAME: ProtectedStorage
SERVICE_NAME: RasMan
SERVICE_NAME: RemoteRegistry
SERVICE_NAME: RichVideo
SERVICE_NAME: RpcSs
SERVICE_NAME: SamSs
SERVICE_NAME: Schedule
SERVICE_NAME: seclogon
SERVICE_NAME: SENS
SERVICE_NAME: SharedAccess
SERVICE_NAME: ShellHWDetection
SERVICE_NAME: spkrmon
SERVICE_NAME: srservice
SERVICE_NAME: SSDPSRV
SERVICE_NAME: stisvc
SERVICE_NAME: TapiSrv
SERVICE_NAME: TermService
SERVICE_NAME: Themes
SERVICE_NAME: TrkWks
SERVICE_NAME: W32Time
SERVICE_NAME: WebClient
SERVICE_NAME: winmgmt
SERVICE_NAME: wscsvc
SERVICE_NAME: WZCSVC
This function makes it easy to determine the status of my F-Prot Anti-virus program from a batch file;
Code:
echo %@isservice[fpavserver]
Joe