Jump to content

Compile Error for WMI scripting


Recommended Posts

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

  • Developers

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...