Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Native Winbatch Service
There can be problems with both ways. With svrany with you stop the service it just kills the application, with this it allows you to shut down yourlself. But with this you have to make sure you do keep track of what the servce has been told to do yourself.
I have included the UDF's (based off the example in the tech batabase) and a demo app (that does nothing).
; Name: Demo.wbt
; Description: Demo Winbatch Service script
; Comments:
; *** Please update the Version number each time you change this script
; The version is Major.Minor.Test
GoSub Init
; Loop forever
While 1
; check to see if the service has been paused, if so we should not do anything.
If !Pasued Then
;Here is where you can do what ever you want
EndIf
;Check to see if anything is happening to the service
Service_Message_Check()
EndWhile
Exit
;******************************************
;********* System Initilation **********
;******************************************
:Init
; Include other wbt files
#Include "Inc_Service.wbt"
If Param0 > 0 Then
; If '--debug' is passed in then log all all commands to a log file
If StrLower(Param1) == "--debug" Then
tracefile = StrCat(Path,"\debug.log")
If FileExist(tracefile)
FileDelete(tracefile)
EndIf
DebugTrace(@ON,tracefile)
EndIf
; If '--install' is passed in then Install the program as a service. The account that the service runs as will need to be changed once installed.
If StrLower(Param1) == "--install" Then
ret = Install_Service("WbtDemo","Winbatch Service Demo", "C:\temp\demo.exe")
; Check to see if the service was installed correctly
If ret <> 0 Then
Message("Error!","Error while creating service. Error Number: %Ret%")
Else
Message("Service Created","Please rename demo.exe to Demo.exs now. And change the account for the service.")
EndIf
; Quit application
Exit
EndIf
End If
; Go and configure the program to run as a service
Service_Init ()
Return