Login | |
|
 |
RE: Creating a Windows service - 11/30/2006 11:41:50 PM
|
|
 |
|
| |
SAPIENScripter
Posts: 276
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
|
Can't you change "NT AUTHORITY\LocalService" to "NT AUTHORITY\LocalSystem" ?
_____________________________
Jeffery Hicks Windows PowerShell MVP SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com Follow Me: http://www.twitter.com/JeffHicks
|
|
| |
|
|
|
 |
RE: Creating a Windows service - 12/1/2006 6:14:38 AM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
this is exactly what I have been looking for and have been too busy to get around to it I'm going to modify it to make it a bit more generic for use in other scripts and I will repost it. Thanks!
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
 |
RE: Creating a Windows service - 12/1/2006 9:07:26 AM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
here are my additions: InstallService ".","testing","c:\program files\test file.exe" DeleteService ".", "testing" Function InstallService(strComputer, strName, strProg) Dim objWMIService, objService, errReturn Const OWN_PROCESS = 16 Const NOT_INTERACTIVE = False Const NORMAL_ERROR_CONTROL = 2 Set objWMIService = GetObject( "winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2" ) Set objService = objWMIService.Get("Win32_BaseService") errReturn = objService.Create(strName , strName, "" & strProg & "", OWN_PROCESS, NORMAL_ERROR_CONTROL, "Manual",_ NOT_INTERACTIVE, "LocalSystem", "Test service to see if i can install one.") If errReturn = "0" Then WScript.Echo strName & " has been added." Else WScript.Echo "There were errors adding the service." End If End Function Sub DeleteService(strComputer, strName) Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colListOfServices = objWMIService.ExecQuery _ ("Select * from Win32_Service Where Name = '" & strName & "'") For Each objService in colListOfServices objService.StopService() return = objService.Delete() Next If return = "0" Or return = "16" Then WScript.Echo strName & " has been marked for deletion." Else WScript.Echo "There were errors deleting the service." End If End Sub
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|