Expert Software Company : News

miercuri, 19 mai 2010

Creare, Stergere si Verificare Serviciu Windows

Creare Proces Windows

OWN_PROCESS = 16
NOT_INTERACTIVE = .F.
ControlError = 2 &&Normal
TipInicio = "Manual"
NomSer = "MyService"
NomMostrar = "Nombre para mostrar - MiServicio"

cRutaEXE = "c:\windows\system32\pd.exe"
cIniSesion = "NT AUTHORITY\LocalService"

objWMI = GetObject("winmgmts:\\")
objSer = objWMI.Get("Win32_BaseService")

errRet = objSer.Create(NomSer, NomMostrar, cRutaExe, OWN_PROCESS, ControlError,
TipInicio, NOT_INTERACTIVE, cIniSesion, "" )

? errRet


Eliminare serviciu Windows
objWMI = GetObject("winmgmts:\\")
cCadWMI = "Select * from Win32_Service Where Name = 'DbService'"
oServ = objWMI.ExecQuery(cCadWMI)

For Each miS in oServ
miS.StopService()
miS.Delete()
Next

Verificare Stare serviciu Windows

objWMI = GetObject("winmgmts:\\")
cCadWMI = "Select * from Win32_Service"
objSer = objWMI.ExecQuery(cCadWMI)

For Each oSys in objSer
? oSys.DisplayName + " " + oSys.State
Next

Niciun comentariu:

Trimiteți un comentariu