airboss2112 Posted June 16, 2006 Share Posted June 16, 2006 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() Link to comment Share on other sites More sharing options...
Developers Jos Posted June 16, 2006 Developers Share Posted June 16, 2006 (edited) 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 colListOfServicesobjService.Change , , , , "automatic"objService.StartService()NextAutoit I have so far is as follow:; Set the RunAs parameters to use local adminstrator accountRunAsSet("*******", @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 permissionsRunAsSet()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 ... Edited June 16, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
airboss2112 Posted June 19, 2006 Author Share Posted June 19, 2006 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 ... 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now