• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • 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!
0
bbanis2k
Asked:
bbanis2k
  • 2
1 Solution
 
BMPTSCommented:
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.
0
 
bbanis2kAuthor Commented:
I will try that...
0
 
Iced-evilCommented:
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 
Next

Open in new window

0
 
bbanis2kAuthor Commented:
This worked pefectly fine!  Thank you
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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