Jump to content
Sign in to follow this  
john123

Please help me get infomation in "General tab" via autoit script.

Recommended Posts

Authenticity

Dim $oWMI =  ObjGet('winmgmts:{impersonationLevel=impersonate}!//./root/cimv2')
Dim $oOSs = $oWMI.InstancesOf('Win32_OperatingSystem')

For $oOS In $oOSs
    ConsoleWrite($oOS.Caption & @TAB & $oOS.Version & @LF)
NextoÝ÷ ØêÚºÚ"µÍÛØ[ÛÛÝ    ÌÍÝYÓÔÕTÒSÓSÈH ÌÎNÙÛÜÓÔÕÚ[Û[ÔÚ^NÙÛÜÓXZÜÚ[ÛÉÌÎNÈ [ÈÂBIÌÎNÙÛÜÓZ[ÜÚ[ÛÙÛÜÐZ[[XÙÛÜÔ]ÜRYØÚÞÔÑÚ[ÛÌLIÌÎNÂBB[H    ÌÍÝÔÕHHÝXÝÜX]J  ÌÍÝYÓÔÕTÒSÓSÊBÝXÝÙ]]J   ÌÍÝÔÕK ÌÎNÙÓÔÕÚ[Û[ÔÚ^IÌÎNËÝXÝÙ]Ú^J    ÌÍÝÔÕJJB[H ÌÍØT]HØ[
    ÌÎNÚÙ[Ì    ÌÎNË ÌÎNÚ[    ÌÎNË ÌÎNÑÙ]Ú[Û^    ÌÎNË ÌÎNÜÌÎNËÝXÝÙ]  ÌÍÝÔÕJJBYÝÜ[SØØ[   ÌÍÜÓÙÈH   ÌÎNÓXZÜÚ[Û    ÌÎNÈ [ÈÝXÝÙ]]J   ÌÍÝÔÕK ÌÎNÙÓXZÜÚ[ÛÌÎNÊH  [È [ÈÂBIÌÎNÓZ[ÜÚ[Û ÌÎNÈ [ÈÝXÝÙ]]J   ÌÍÝÔÕK ÌÎNÙÓZ[ÜÚ[ÛÌÎNÊH  [È [ÈÂBIÌÎNÐZ[[X  ÌÎNÈ [ÈÝXÝÙ]]J   ÌÍÝÔÕK ÌÎNÙÐZ[[XÌÎNÊH   [È [ÈÂBIÌÎNÔ]ÜHQ ÌÎNÈ [ÈÝXÝÙ]]J   ÌÍÝÔÕK ÌÎNÙÔ]ÜRY  ÌÎNÊH    [È [ÈÂBIÌÎNÐÔÑÚ[Û ÌÎNÈ [ÈÝXÝÙ]]J   ÌÍÝÔÕK ÌÎNÜÞÔÑÚ[ÛÌÎNÊH  [ÈBBPÛÛÛÛUÜ]J ÌÍÜÓÙÊB[ÙBPÛÛÛÛUÜ]J ÌÎNÊ ÌL×ËÊIÌÎNÈ   [È [È ÌÎNÊ×ÓÊIÌÎNÈ   [È [È ÌÎNÊ ÌÎNÉÌÎNÊJ ÌÎNÉÌÎNÊIÌÎNÈ  [ÈB[YÌÍÝÔÕHH

I still don't know how to get the 2002...? Maybe it's fix so XP is 2002 and Vista is always 200X?

Edited by Authenticity

Share this post


Link to post
Share on other sites
john123

Thanks Authenticity so much.

Have a nice day.

Edited by john123

Share this post


Link to post
Share on other sites
john123

Hi Authenticity and everyone.

I complie two script above. I run mini-setup with sysprep.exe and add them to sysprep.inf (run after mini-setup - with Runonce). The second script run fine but first script don't run. I think first script don't work with SYSTEM account (after mini-setup, windows login as System account). Can you explain about this problem?

Sorry for bother.

Thank you so much.

Share this post


Link to post
Share on other sites
trancexx

Run it like this (unless some "obj" guy wouldn't be faster to elaborate before):

$oError = ObjEvent("AutoIt.Error", "_ErrFunc")

Dim $oWMI = ObjGet('winmgmts:{impersonationLevel=impersonate}!//./root/cimv2')
Dim $oOSs = $oWMI.InstancesOf('Win32_OperatingSystem')

For $oOS In $oOSs
    ConsoleWrite($oOS.Caption & @TAB & $oOS.Version & @LF)
Next


Func _ErrFunc()
    
;FileWrite("MyWMILog.txt", "Error is:   " & Ptr($oError.Number))
    MsgBox(0, "WMI Error", "Error is:   " & Ptr($oError.Number))

EndFunc

Or just wait for someone smarter :D

Btw, no bunny is quite ok with me.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
john123

Thanks Trancexx. I've just tested. I got error message : 0x8004100A. Perhap WMI don't run until full operating system installed (for user account, don't include SYSTEM account).

I really need phrase "Microsoft windows xp professional" to make a label on my application, this application run after mini-setup.

How can fix this error?.

Edited by john123

Share this post


Link to post
Share on other sites
trancexx

Thanks Trancexx. I've just tested. I got error message : 0x8004100A. Perhap WMI don't run until full operating system installed (for user account, don't include SYSTEM account).

I really need phrase "Microsoft windows xp professional" to make a label on my application, this application run after mini-setup.

How can fix this error?.

Description for that error is:

WBEM_E_CRITICAL_ERROR
0x8004100A
An internal, critical, and unexpected error occurred. Report this error to Microsoft Technical Support.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
rajeshontheweb
trancexx

You have all that as AutoIt's macros and Authenticity posted an alternative call.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
rajeshontheweb

WinAPI - Structure - OSVersionInfo

hoooray, i might have got it , pls check if u can find out how to use it : WinAPI -Function - IsOS - very detailed info on usage here: IsOS @ geoffchappell

Syntax
BOOL IsOS(    
    DWORD dwOS
);
OS_NT   1
OS_PROFESSIONAL 20

<edit>

trancexx, i had earlier checked and rechecked it doesnt tell OS Edition, or i have overlooked at something.

i checked these: @OS - Arch, Build, Version, ServicePack, Lang none of these return the OS Edition.

Edited by rajeshontheweb

Share this post


Link to post
Share on other sites
trancexx

Try this before (it's a modification of Authenticity's - see the bunny):

Global $tOSVI = DllStructCreate("dword OSVersionInfoSize;" & _
        "dword MajorVersion;" & _
        "dword MinorVersion;" & _
        "dword BuildNumber;" & _
        "dword PlatformId;" & _
        "char CSDVersion[128];" & _
        "ushort ServicePackMajor;" & _
        "ushort ServicePackMinor;" & _
        "ushort SuiteMask;" & _
        "ubyte ProductType;" & _
        "ubyte")

DllStructSetData($tOSVI, "OSVersionInfoSize", DllStructGetSize($tOSVI))

Global $acall = DllCall("kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($tOSVI))

If Not @error Then
    Global $sMsg = "Major Version: " & DllStructGetData($tOSVI, "MajorVersion") & @LF & _
            "Minor Version: " & DllStructGetData($tOSVI, "MinorVersion") & @LF & _
            "Build Number: " & DllStructGetData($tOSVI, "BuildNumber") & @LF & _
            "Platform ID: " & DllStructGetData($tOSVI, "PlatformId") & @LF & _
            "CSDVersion: " & DllStructGetData($tOSVI, "CSDVersion") & @LF & _
            "ServicePackMajor: " & DllStructGetData($tOSVI, "ServicePackMajor") & @LF & _
            "ServicePackMinor: " & DllStructGetData($tOSVI, "ServicePackMinor") & @LF & _
            "SuiteMask: " & DllStructGetData($tOSVI, "SuiteMask") & @LF & _
            "ProductType: " & DllStructGetData($tOSVI, "ProductType") & @LF
    ConsoleWrite($sMsg)
Else
    ConsoleWrite("(\_/)" & @LF & "(o_O)" & @LF & "('')('')" & @LF)
EndIf

If DllStructGetData($tOSVI, "PlatformId") = 2 Then
    If DllStructGetData($tOSVI, "MajorVersion") = 5 And DllStructGetData($tOSVI, "MinorVersion") = 1 And DllStructGetData($tOSVI, "ProductType") = 1 Then
        ConsoleWrite("! Windows XP")
        If Not BitAND(DllStructGetData($tOSVI, "SuiteMask"), 512) Then
            ConsoleWrite(" Professional" & @CRLF)
        Else
            ConsoleWrite(@CRLF)
        EndIf
    EndIf
EndIf

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
rajeshontheweb

Oh Great, thats very handy. so, GetVersionEx itself gives us the info??? anyways, IsOS also works well only if u give the right parameters returned by GetVersionEx.

The IsOS function asks first to have an OSVERSIONINFOEXA structure filled, and failing that, an OSVERSIONINFOA structure.

ooh, as usual, it depends on how technical u can search for information. i checkedup this suitemask and this interesting thing came up:

;  VER_SUITE_SMALLBUSINESS =               1 = 0x00000001
;  VER_SUITE_ENTERPRISE =                 2 = 0x00000002
;  VER_SUITE_BACKOFFICE =                 4 = 0x00000004
;  VER_SUITE_COMMUNICATIONS =             8 = 0x00000008
;  VER_SUITE_TERMINAL =                16 = 0x00000010
;  VER_SUITE_SMALLBUSINESS_RESTRICTED =   32 = 0x00000020
;  VER_SUITE_EMBEDDEDNT =                64 = 0x00000040
;  VER_SUITE_DATACENTER =               128 = 0x00000080
;  VER_SUITE_SINGLEUSERTS =           256 = 0x00000100
;  VER_SUITE_PERSONAL =               512 = 0x00000200
;  VER_SUITE_BLADE =                    1024 = 0x00000400

;  To test properly for any flavor of WinXP, the following must be true:
;   The PlatformID must be 2 [NT platform family]
;   The O.S. Major Version must be 5.
;   The O.S. Minor Version must be 1.
;   The Product Type must be 1 [workstation, not server]
;   If the result of (VerSuite & 512) is non-zero then that indicates that WinXP Home Edition is
;   being used.  If (VerSuite & 512) is zero then WinXP Professional Edition is being used.

PS: I hope i can quote such snippets here is it within the forum rules pls correct me whenever i go wrong thanks a lot.

<edited again> just more thought into it, above serves our purpose, but still, i think IsOS() would give us more precise and to the point answer - isnt it true? (this is to clarify my understanding)

(Logic as i've understood) 
If IsOS(WIN_NT) Not  False  & IsOS(OS_Professional) Not False Then <WINDOWS XP PROFESSIONAL>
Edited by rajeshontheweb

Share this post


Link to post
Share on other sites
trancexx

Oh Great, thats very handy. so, GetVersionEx itself gives us the info??? anyways, IsOS also works well only if u give the right parameters returned by GetVersionEx.

That is done internally. You can use it like this maybe:

$aCall = DllCall("shlwapi.dll", "int", 437, "dword", 20); 437 is the function (exported by ordinal)

ConsoleWrite($aCall[0] & @CRLF)

Description for 20 is: The program is running on Windows NT Workstation or Windows 2000 (or one of its successors) Professional.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
john123

Try this before (it's a modification of Authenticity's - see the bunny):

Global $tOSVI = DllStructCreate("dword OSVersionInfoSize;" & _
        "dword MajorVersion;" & _
        "dword MinorVersion;" & _
        "dword BuildNumber;" & _
        "dword PlatformId;" & _
        "char CSDVersion[128];" & _
        "ushort ServicePackMajor;" & _
        "ushort ServicePackMinor;" & _
        "ushort SuiteMask;" & _
        "ubyte ProductType;" & _
        "ubyte")

DllStructSetData($tOSVI, "OSVersionInfoSize", DllStructGetSize($tOSVI))

Global $acall = DllCall("kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($tOSVI))

If Not @error Then
    Global $sMsg = "Major Version: " & DllStructGetData($tOSVI, "MajorVersion") & @LF & _
            "Minor Version: " & DllStructGetData($tOSVI, "MinorVersion") & @LF & _
            "Build Number: " & DllStructGetData($tOSVI, "BuildNumber") & @LF & _
            "Platform ID: " & DllStructGetData($tOSVI, "PlatformId") & @LF & _
            "CSDVersion: " & DllStructGetData($tOSVI, "CSDVersion") & @LF & _
            "ServicePackMajor: " & DllStructGetData($tOSVI, "ServicePackMajor") & @LF & _
            "ServicePackMinor: " & DllStructGetData($tOSVI, "ServicePackMinor") & @LF & _
            "SuiteMask: " & DllStructGetData($tOSVI, "SuiteMask") & @LF & _
            "ProductType: " & DllStructGetData($tOSVI, "ProductType") & @LF
    ConsoleWrite($sMsg)
Else
    ConsoleWrite("(\_/)" & @LF & "(o_O)" & @LF & "('')('')" & @LF)
EndIf

If DllStructGetData($tOSVI, "PlatformId") = 2 Then
    If DllStructGetData($tOSVI, "MajorVersion") = 5 And DllStructGetData($tOSVI, "MinorVersion") = 1 And DllStructGetData($tOSVI, "ProductType") = 1 Then
        ConsoleWrite("! Windows XP")
        If Not BitAND(DllStructGetData($tOSVI, "SuiteMask"), 512) Then
            ConsoleWrite(" Professional" & @CRLF)
        Else
            ConsoleWrite(@CRLF)
        EndIf
    EndIf
EndIf

I tested. Everything done. Code work fine.

I love AutoIT and this forum.

Thanks you very much.

Good luck to you.

John123.

Share this post


Link to post
Share on other sites
trancexx

That's great!

Don't forget to recycle your bottles, cans, and paper products. Use public transport and only recycled computer paper (if it's not recycled refuse to use it and just throw it away).


♡♡♡

.

eMyvnE

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  

×