ScriptingSteve Posted September 27, 2005 Share Posted September 27, 2005 I am writing a script to change settings of Windows Services. I am implementing Microsoft's script sample: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colServiceList = objWMIService.ExecQuery _ ("Select * from Win32_Service where StartMode = 'Manual'") For Each objService in colServiceList errReturnCode = objService.Change( , , , , "Disabled") Next I have it working in AutoIt 3.1.1.76: If IsObj($colItems) then For $serviceItem in $colItems $ServChange = $serviceItem.Change( , , , , "Disabled") Next Endif The problem is the line "$ServChange = $serviceItem.Change( , , , , "Disabled")" produces a syntax error at compile time. If I click "Continue Anyway", the resultant compiled script works properly. What syntax should I be using in the $ServChange= line to prevent this compilation error? Link to comment Share on other sites More sharing options...
this-is-me Posted September 27, 2005 Share Posted September 27, 2005 I imagine you would use Change("", "", "", "", "Disabled") Who else would I be? Link to comment Share on other sites More sharing options...
Developers Jos Posted September 27, 2005 Developers Share Posted September 27, 2005 The problem is the line "$ServChange = $serviceItem.Change( , , , , "Disabled")" produces a syntax error at compile time. If I click "Continue Anyway", the resultant compiled script works properly.What syntax should I be using in the $ServChange= line to prevent this compilation error?The syntax check is done by AU3Check and it expects a value like "",0,Default or else it gives this error.If the Syntax is valid for AutoIt3 then Tylo needs to have a look at AU3Check to see if it can be supported by AU3check as well.. 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...
ScriptingSteve Posted September 28, 2005 Author Share Posted September 28, 2005 Two issues: The Windows function fails when I tried ("","","", etc) (I already tried that) Based on the Microsoft articles, and the VB script samples they have posted, the correct syntax for the WMI function is ( , , , ,"Thing here") So for now it's a syntax limitation... Link to comment Share on other sites More sharing options...
ScriptingSteve Posted September 28, 2005 Author Share Posted September 28, 2005 Just upgraded to 3.1.1.78, and upgraded Scite to the latest version ('default' wasn't being accepted as a keyword in the version I was using). Changing $ServChange = $serviceItem.Change( , , , , "Disabled") to: $ServChange = $serviceItem.Change(default ,default ,default ,default , "Disabled") compiles OK and works fine. Thanks! 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