Sign in to follow this  
Followers 0
roman

Problem with using the Win32_Service class

4 posts in this topic

Hi

I have wrote this function:

Func ServiceChangeStartMode($ServiceName, $ServiceStartMode)
    $oColListOfServices = $oWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE Name='" & $ServiceName & "'")
    For $oObjService in $oColListOfServices
       ; Solution 1:
        $oObjService.ChangeStartMode($ServiceStartMode)
       ; Solution 2:
        $oObjService.Change( , , , , $ServiceStartMode)
    Next
    If @error Or Not IsObj($oObjService) Then Exit
EndFunc

The code line below remark "Solution 1" works, the code line below remark "Solution 2" does not. (Of course i use either the first or the second code line, not both together)

The reason i found in Solultion 2 is, that i can't skip the four preceding parameters of this method this way; the method either allways interpretes all inside the brackets as the first parameter or i get an syntax error like in this case.

Knows anybody how to use the change method of the Win32_Service class correctly?

Sorry about my english.

Thanks for all suggestions!

Roman.

Share this post


Link to post
Share on other sites



Hi

I have wrote this function:

Func ServiceChangeStartMode($ServiceName, $ServiceStartMode)
    $oColListOfServices = $oWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE Name='" & $ServiceName & "'")
    For $oObjService in $oColListOfServices
      ; Solution 1:
        $oObjService.ChangeStartMode($ServiceStartMode)
      ; Solution 2:
        $oObjService.Change( , , , , $ServiceStartMode)
    Next
    If @error Or Not IsObj($oObjService) Then Exit
EndFunc

...

Hello Roman,

The 'empty arguments' syntax has been replaced by the 'default' keyword since AutoIt beta version 3.1.1.xx (oops, forgot the exact version number).

So the line would be:

; Solution 2:
        $oObjService.Change(default ,default , default , default , $ServiceStartMode)

Regards,

-Sven

Share this post


Link to post
Share on other sites

Hello Roman,

The 'empty arguments' syntax has been replaced by the 'default' keyword since AutoIt beta version 3.1.1.xx (oops, forgot the exact version number).

So the line would be:

; Solution 2:
        $oObjService.Change(default ,default , default , default , $ServiceStartMode)

Regards,

-Sven

Thanks a lot! I will try it... :P

Regards,

Roman.

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  
Followers 0