Sample Code to Start and Stop a Service
Keywords: start and stop a service
;while loop example %sysid% defined earlier from text file AddExtender("WWWNT34I.DLL") sysid="\\SERVER" state=0 service="AvSync Manager" state = wntSvcStatus(sysid, service, 0, 2) ;get service status if state != 1 wntSvcControl(sysid,service , 0, 1) ;stop service endif while state != 1 ;loop until service is reported as stopped. TimeDelay(1) wntSvcControl(sysid, service, 0, 4) ;update status in servicemanager state = wntSvcStatus(sysid, service, 0, 2) ;get service status endwhile Message(service, "Service should be stopped now") state = wntSvcStatus(sysid, service, 0, 2) ;get service status if state !=4 wntSvcStart(sysid, service, 0, "", "") ;start service endif while state != 4 ;loop until service starts again. TimeDelay(1) wntSvcControl(sysid, service, 0, 4) ;update status in servicemanager state = wntSvcStatus(sysid, service, 0, 2) ;get service status endwhile Message(service,"Service should be started now")
Article ID: W14948