Jump to content

error in WMI Query, but working?

Recommended Posts



I've got a piece of code, it works (when ran as administrator is disables the automatic pagefile setting) But the application crashes afterwards.

Can sombody point me in a direction what I'm doing wrong?


$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""

$oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\ROOT\CIMV2")
$colItems = $oWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL")

If IsObj($colItems) Then
   For $objItem In $colItems
        $objItem.AutomaticManagedPagefile = False
   MsgBox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystem" )

Error Message: Error: The requested action with this object has failed.

Edited by J0hn

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


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.