• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

VB Script needed to alter local server services

I have a couple of servers, that whenever they reboot critical services fail to start.  I have to log into the server and change the password on the local service accounts.  I then am able to start the services just fine.

I really need a VB Script that can automate this for me.  I need it to be able to assign user name and password for the service locally, then I need it to start the service.

I spent 4 hours on the phone with Symantec and they were no help.  I also have a SQL server that is doing the same thing on a remote network in a different domain and context altogether.

Any help would be great!
  • 2
1 Solution
instead of using VB just use a batch file and the SC command

SC config to set password
(sc <server> config [service name] <option1> <option2>)

sc start and stop
(sc <server> start [service name] <arg1> <arg2>)

go to a command prompt and type SC /? or SC Config /?.

If you are dead set on VBS then just start the command prompt and stream the commands into the command window.
bbanis2kAuthor Commented:
I will try that...
Here a a VBScript that does what you need
strComputer = "computername"
strService = ".\servicename"
strPassword = "password"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service")
For Each objservice in colServiceList
    If objService.Startname = strService Then
        errReturn = objService.Change( , , , , , , ,strPassword)
        errReturn = objService.StartService()
    End If 

Open in new window

bbanis2kAuthor Commented:
This worked pefectly fine!  Thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now