Is it possible to run a vbscript like a service without using Srvany.exe?
I mean I can create the service but when I try to start it I receive an error message (8). I can see the created service but when I manually try to start it "Error 193: 0xc1" appears... (is not a valid Win32 application). Since Srvany is able to solve that does anybody know how to solve the problem?
Fane Duru
I mean I can create the service but when I try to start it I receive an error message (8). I can see the created service but when I manually try to start it "Error 193: 0xc1" appears... (is not a valid Win32 application). Since Srvany is able to solve that does anybody know how to solve the problem?
Code:
Const OWN_PROCESS = 16
Const NOT_INTERACTIVE = False
Const NORMAL_ERROR_CONTROL = 2
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objService = objWMIService.Get("Win32_BaseService")
errReturn = objService.Create("StartService" ,"Personnel Database" , _
"E:\VBScript\Test x\Start.vbs", OWN_PROCESS, NORMAL_ERROR_CONTROL, "Automatic", _
NOT_INTERACTIVE, NULL, "" )
if errReturn = 0 then
wscript.Echo "Service created"
else
Wscript.Echo "Error at creation: " & errReturn
end if
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set objService = objWMI.Get("Win32_Service.Name='StartService'")
intRC = objService.StartService
if intRC > 0 then
WScript.Echo "Error starting service: " & intRC
else
WScript.Echo "Successfully started service"
end if
Fane Duru