tinkythomas Posted October 31, 2008 Share Posted October 31, 2008 Hi, I am trying to modify a vbscript for use in autoit. The code I have is as follows:_DisableService("Alerter", "Disabled") Func _DisableService($service, $State) Dim $objWMIService, $colServiceList, $objService, $errReturnCode Dim $strComputer $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") ;ConsoleWrite($objWMIService) $colServiceList = $objWMIService.ExecQuery _ ("Select * from Win32_Service where Name = " & "'" & $service & "'" & '"') ;ConsoleWrite($colServiceList) For $objService In $colServiceList If $objService.State = "Running" Then $objService.StopService() Sleep(5000) EndIf $objService.ChangeStartMode($State) Next EndFunc ;==>_DisableService But this doesn't work and I can't figure it out. Can anyone help me? Thanks Link to comment Share on other sites More sharing options...
Developers Jos Posted October 31, 2008 Developers Share Posted October 31, 2008 Try: _DisableService("Alerter", "Disabled") Func _DisableService($service, $State) Dim $objWMIService, $colServiceList, $objService, $errReturnCode Dim $strComputer $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") ;ConsoleWrite($objWMIService) $colServiceList = $objWMIService.ExecQuery _ ("Select * from Win32_Service where Name = '" & $service & "'") ;ConsoleWrite($colServiceList) For $objService In $colServiceList If $objService.State = "Running" Then $objService.StopService() Sleep(5000) EndIf $objService.ChangeStartMode($State) Next EndFunc ;==>_DisableService Jos 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...
tinkythomas Posted October 31, 2008 Author Share Posted October 31, 2008 Thank you so much! I can never get literal strings right. I can never work out where to put a single or double quote All is now working perfectly! 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