Jump to content
Sign in to follow this  
airboss2112

Windows Services

Recommended Posts

airboss2112

I currently have 200 laptop clients in the feild, none are administrators of there laptops.

During a recent upgrade to there laptops a Service was disabled causing a application to fail.

I need a script that will change the startup properties to automatic and to start this service.

I wrote a VBscript that performs this without a hitch however it requires admin right to perform service changes.

I have tried aimlessly to make this work:

VBScript;

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _

("Select * from Win32_Service Where Name ='CSAgent'")

For Each objService in colListOfServices

objService.Change , , , , "automatic"

objService.StartService()

Next

Autoit

I have so far is as follow:

; Set the RunAs parameters to use local adminstrator account

RunAsSet("*******", @ComputerName , "********")

;Enabling CSA Services

$strComputer = "."

$objWMIService = Objget("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$colListOfServices = $objWMIService.ExecQuery _

("Select * from Win32_Service Where Name ='WZCSVC'")

For $objService to $colListOfServices

$objService.StopService()

$objService.Change "automatic"()

$objWMIService.StartService()

Next

; Reset user's permissions

RunAsSet()

Share this post


Link to post
Share on other sites
Jos

I currently have 200 laptop clients in the feild, none are administrators of there laptops.

During a recent upgrade to there laptops a Service was disabled causing a application to fail.

I need a script that will change the startup properties to automatic and to start this service.

I wrote a VBscript that performs this without a hitch however it requires admin right to perform service changes.

I have tried aimlessly to make this work:

VBScript;

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _

("Select * from Win32_Service Where Name ='CSAgent'")

For Each objService in colListOfServices

objService.Change , , , , "automatic"

objService.StartService()

Next

Autoit

I have so far is as follow:

; Set the RunAs parameters to use local adminstrator account

RunAsSet("*******", @ComputerName , "********")

;Enabling CSA Services

$strComputer = "."

$objWMIService = Objget("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$colListOfServices = $objWMIService.ExecQuery _

("Select * from Win32_Service Where Name ='WZCSVC'")

For $objService to $colListOfServices

$objService.StopService()

$objService.Change "automatic"()

$objWMIService.StartService()

Next

; Reset user's permissions

RunAsSet()

RunAsSet ONLY sets the elevated rights for RUN and RUNWAIT .... NO other command/function..

You need to do A RunAsSet() and then restart the script with these elevated rights to accomplish what you want.

I posted this solution many time so just search for that ... :D

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
airboss2112

RunAsSet ONLY sets the elevated rights for RUN and RUNWAIT .... NO other command/function..

You need to do A RunAsSet() and then restart the script with these elevated rights to accomplish what you want.

I posted this solution many time so just search for that ... :D

I have searched Aimlessly and being new I thought there might have been something out there already. From what I am understanding your stating that that I cannot run any other functions thru RunasSet?

Can you please provide an example?

Many thanks in advance.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×