Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create script that starts program as a service?

Status
Not open for further replies.

vasara

Technical User
Aug 8, 2002
9
FI
Hello,

I have this vbs script which should install a new service, but it doesn't work. Can anyone tell me what's wrong in this script.

Here's the script:

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("MyService", _
"My service test", _
"c:\test\my.exe", _
OWN_PROCESS, _
NORMAL_ERROR_CONTROL, _
"Manual", _
NOT_INTERACTIVE, _
"NT AUTHORITY\LocalService", "")

Wscript.Echo errReturn

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top