Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Creating a Windows service

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,40272
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Creating a Windows service
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Creating a Windows service - 11/30/2006 8:50:24 PM   
  molemenacer

 

Posts: 31
Score: 0
Joined: 11/13/2006
From: England
Status: offline
Hi all,

I am installing a windows service with a vbscript and have been able to achieve this, my question is how to install it as a local system rather than local service. 


      

I know the NT AUTHORITY\LocalService is the area that needs changed but cannot find what it needs to be instead.

Any help would be appreciated

Thanks in advance
 
 
Post #: 1
 
 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

(in reply to molemenacer)
 
 
Post #: 2
 
 RE: Creating a Windows service - 11/30/2006 11:55:10 PM   
  molemenacer

 

Posts: 31
Score: 0
Joined: 11/13/2006
From: England
Status: offline
No, i already tried that, thanks for teh help but i have found the way through trial and error.

All you need is "LocalSystem" instead of NT AUTHORITY\LocalService


      

(in reply to SAPIENScripter)
 
 
Post #: 3
 
 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

(in reply to molemenacer)
 
 
Post #: 4
 
 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

(in reply to kirrilian)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Creating a Windows service Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts