Jump to content

Getting an error but dont know why.


Recommended Posts

Hi all

I made an OS function for something im working on like this

ConsoleWrite(_OS())
MsgBox(64, "Test", _OS())

Func _OS()
Local $OS
Local $objWMIService = ObjGet("winmgmts:localhostrootCIMV2")
Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL")
If IsObj($colItems) Then
  For $objItem In $colItems
   $OS = $objItem.Caption & " / " & $objItem.OSArchitecture & " / " & $objItem.CSDVersion & @CRLF
   Return $OS
  Next
EndIf
EndFunc   ;==>_OS

But on any XP machine it fails??

Its fine on vista and above

I thought scriptomatic was for xp as well, and the other 6 or so other functions i made are fine all except this one.

Have i done something wrong or just an anomolie?

It fails on the line before this Func _OS() with Error the requested action with this object has failed

Edited by Chimaera
Link to comment
Share on other sites

Hi!

OSArchitecture

Windows Server 2003, Windows 2000, Windows NT 4.0, Windows XP, and Windows Me/98/95: This property is not available.

Font: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394239%28v=vs.85%29.aspx

Regards,

João Carlos.

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

Sorry M8 yes it does i had to mod the function like this to solve it

Func _OS()
Local $OS, $sArchTest
If @OSArch = "X86" Then
  $sArchTest = "32-Bit"
Else
  $sArchTest = "64-Bit"
EndIf
Local $objWMIService = ObjGet("winmgmts:localhostrootCIMV2")
Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL")
If IsObj($colItems) Then
  For $objItem In $colItems
   $OS = $objItem.Caption & " / " & $sArchTest & " / " & $objItem.CSDVersion & @CRLF
   Return $OS
  Next
EndIf
EndFunc   ;==>_OS
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...