Jump to content

Recommended Posts

I found a website where it is explained how to use wmi to check the tpm status of the tmp security chip.

http://windowsitpro.com/security/checking-status-trusted-platform-module-command-line

I tried this with autoit, but had no success.

Anyone here who can give little support to me?

Thanks

#include <Array.au3>

$ScriptName     = "TPM Status"

Dim $sResult
$strComputer = "lapxxx"

$objWMIService = ObjGet("wmic /namespace:\\.\root\cimv2\security\microsofttpm")
;$objWMIService = ObjGet("wmic /namespace:\\" & $strComputer & "\root\cimv2\security\microsofttpm")
;$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.InstancesOf("Select * from Win32_Tpm")

For $objItem In $colItems
    $IsActivated = $objItem.IsActivated_InitialValue
    $IsEnabled = $objItem.IsEnabled_InitialValue

    MsgBox(0, $ScriptName,  "IsActivated: " & $IsActivated & @CRLF & _
                                                    "IsEnabled: " & $IsEnabled & @CRLF & _
                                                    "x: " )
Next




$oMTpm = ObjGet("winmgmts:\\.\root\cimv2\Security\MicrosoftTpm")
$oCol = $oMTpm.InstancesOf("Win32_Tpm")


For $oObj In $oCol

    ConsoleWrite($oObj.IsActivated_InitialValue & @CRLF)
    ConsoleWrite($oObj.IsEnabled_InitialValue & @CRLF)
    ConsoleWrite($oObj.IsOwned_InitialValue & @CRLF)
    ConsoleWrite($oObj.SpecVersion & @CRLF)
    ConsoleWrite($oObj.ManufacturerVersion & @CRLF)
    ConsoleWrite($oObj.ManufacturerVersionInfo & @CRLF)
    ConsoleWrite($oObj.ManufacturerId & @CRLF)
    ConsoleWrite($oObj.PhysicalPresenceVersionInfo & @CRLF)

Next

 

 

Link to post
Share on other sites
; TPM Security Info

Opt ( 'MustDeclareVars', 1 )

Local $objWMIService, $colItem, $objItem        ; Declare
Local $strComputer = "."                        ; Local Computer

; WMI Object
$objWMIService = ObjGet ( "WinMgmts:{impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}//" & $strComputer & "\root\CIMV2\Security\MicrosoftTpm" )

; WMI Object check.
If IsObj ( $objWMIService ) Then
    ConsoleWrite ( "Object YES" & @CRLF )   ; Debug console message
Else
    ConsoleWrite ( "Object NO" & @CRLF )
    Exit 1  ; Exit Script Object error / WMI MicrosoftTpm not found.
EndIf

$objItem = $objWMIService.InstancesOf ( "Win32_Tpm" )

For $colItems In $objItem
    ConsoleWrite ( "IsActivated : " & $colItems.IsActivated_InitialValue & @CRLF )
    ConsoleWrite ( "IsEnabled : " & $colItems.IsEnabled_InitialValue & @CRLF )
    ConsoleWrite ( "IsOwned : " & $colItems.IsOwned_InitialValue & @CRLF )
    ConsoleWrite ( "SpecVersion : " & $colItems.SpecVersion & @CRLF )
    ConsoleWrite ( "ManufacturerVersion : " & $colItems.ManufacturerVersion & @CRLF )
    ConsoleWrite ( "ManufacturerVersionInfo : " & $colItems.ManufacturerVersionInfo & @CRLF )
    ConsoleWrite ( "ManufacturerId : " & $colItems.ManufacturerId & @CRLF )
    ConsoleWrite ( "PhysicalPresenceVersionInfo : " & $colItems.PhysicalPresenceVersionInfo & @CRLF )
Next

Hi, I don't have TPM enabled and i am running Windows in a virtual machine. Anyway i narrowed your'e code a bit down and rewrote a little bit. Hope this works for you. 

Link to post
Share on other sites

One more question about the manufactureid.

How to convert it from the id to text?

 

Found this about it.

Data type: uint32
Access type: Read-only
ManufacturerId

The identifying information that uniquely names the TPM manufacturer.

When the data is unavailable, zero is returned.

This integer value can be translated to a string value by interpreting each byte as an ASCII character. For example, an integer value of 1414548736 can be divided into these 4 bytes: 0x54, 0x50, 0x4D, and 0x00. Assuming the string is interpreted from left to right, this integer value translated to a string value of "TPM".

 

Link to post
Share on other sites
  • 4 years later...
On 8/5/2016 at 5:20 PM, pluto41 said:
; TPM Security Info

Opt ( 'MustDeclareVars', 1 )

Local $objWMIService, $colItem, $objItem        ; Declare
Local $strComputer = "."                        ; Local Computer

; WMI Object
$objWMIService = ObjGet ( "WinMgmts:{impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}//" & $strComputer & "\root\CIMV2\Security\MicrosoftTpm" )

; WMI Object check.
If IsObj ( $objWMIService ) Then
    ConsoleWrite ( "Object YES" & @CRLF )   ; Debug console message
Else
    ConsoleWrite ( "Object NO" & @CRLF )
    Exit 1  ; Exit Script Object error / WMI MicrosoftTpm not found.
EndIf

$objItem = $objWMIService.InstancesOf ( "Win32_Tpm" )

For $colItems In $objItem
    ConsoleWrite ( "IsActivated : " & $colItems.IsActivated_InitialValue & @CRLF )
    ConsoleWrite ( "IsEnabled : " & $colItems.IsEnabled_InitialValue & @CRLF )
    ConsoleWrite ( "IsOwned : " & $colItems.IsOwned_InitialValue & @CRLF )
    ConsoleWrite ( "SpecVersion : " & $colItems.SpecVersion & @CRLF )
    ConsoleWrite ( "ManufacturerVersion : " & $colItems.ManufacturerVersion & @CRLF )
    ConsoleWrite ( "ManufacturerVersionInfo : " & $colItems.ManufacturerVersionInfo & @CRLF )
    ConsoleWrite ( "ManufacturerId : " & $colItems.ManufacturerId & @CRLF )
    ConsoleWrite ( "PhysicalPresenceVersionInfo : " & $colItems.PhysicalPresenceVersionInfo & @CRLF )
Next

Hi, I don't have TPM enabled and i am running Windows in a virtual machine. Anyway i narrowed your'e code a bit down and rewrote a little bit. Hope this works for you. 

Today I found this old entry and I did want to try this script. It does not work any longer it seems. 

$objWMIService looks empty -> Object No is written into the console. 

Can anyone check and confirm?

Have there been some changes?

Thank you

 

Link to post
Share on other sites

Take a look here:

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

Link to post
Share on other sites

I have found that one and read it. 

It is too much code for what I really need. 

Just want to connect to the wmi class and grab these values.

class Win32_Tpm
{
  boolean IsActivated_InitialValue;
  boolean IsEnabled_InitialValue;
  boolean IsOwned_InitialValue;
  string  SpecVersion;
  string  ManufacturerVersion;
  string  ManufacturerVersionInfo;
  uint32  ManufacturerId;
  string  PhysicalPresenceVersionInfo;
};
Quote

 

 

Link to post
Share on other sites

Just tried this, but it does not work. 

#include <MsgBoxConstants.au3>

$ScriptName     = "TPM Status"



Opt ( 'MustDeclareVars', 1 )

Local $objWMIService, $colItem, $objItem        ; Declare
Local $strComputer = "."                        ; Local Computer

; WMI Object
$objWMIService = ObjGet("WinMgmts:{impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}\\" & $strComputer & "\root\CIMV2\Security\MicrosoftTpm")

; WMI Object check.
If IsObj ( $objWMIService ) Then
    ConsoleWrite ( "Object YES" & @CRLF )   ; Debug console message
Else
    ConsoleWrite ( "Object NO" & @CRLF )
    Exit 1  ; Exit Script Object error / WMI MicrosoftTpm not found.
EndIf

 

Link to post
Share on other sites

Add a COM error handler to your script for more detailed error information. The help file describes in ObjEvent how to do.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

I am no expert, not sure where to find what you mean. 

Maybe one here can help me a little bit, as said I am no expert. 

In my eyes the error handling is one of the biggest mistakes in autoit here is big room for improvements. 

The stupid error message "variable used withouth being declacred in line 14123" for example helps nobody. 

Link to post
Share on other sites
  • Moderators

blumi,

Quote

The stupid error message "variable used withouth being declacred in line 14123" for example helps nobody. 

On the contrary it is quite helpful - if you used Au3Stripper on your script before compiling. And if you ran your script through Au3Check you would probably find out that you had an undeclared variable before you compiled your script. Both of those utilities are included in the SciTE4AutoIt3 package, which also gives you lots of other useful aids to your AutoIt programming.

As to the proximate problem - you find a comprehensive example of COM error handling in the ObjEvent page of the Help file, as water told you  above.

Finally if you do not like AutoIt then there are plenty of other languages out there for you to try.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

I did not say I don't like autoit and I could do some small helpfull scripts for me with it. 

I don't like the error handling. I have read in other posts about Au3Check and Au3Stripper, and I did some tries with it. 

But I don't know how to use it correct. May be here would be a tutorial very helpfull. May be one exists an I don't know. 

Same with the Com error in the ObjEvent page, I don't know where to find, I searched in the help but can't find it. 

For you here it is all so easy, cause you use autit very often. If you don't use it so often, it is nice to have a place where I can read thing again and again, so I don't have to ask here. 😉

Link to post
Share on other sites

Stripped down example from the help file (ObjEvent). Add your code after the frist line and you will get detailed information what goes wrong written to the console.

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

; Your code goes here

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Okay thank you. I will save this code and try it to use more often in other scripts. 

Now I get some more details why it does not work, but I can't find out why it does not work.

TPM Status3.au3 (37) : ==> COM Error intercepted !
    err.number is:      0x80041003
    err.windescription: 
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    0
    err.scriptline is:  37
    err.retcode is:     0x00000000

Any ideas?

Link to post
Share on other sites

Hresult 0x80041003 stands for "Access denied".

Google returns a lot of results when searching for "hresult 0x80041003 WMI" like https://social.technet.microsoft.com/Forums/ie/en-US/4e0b3b10-859c-43de-80b9-a8a480d6e432/unable-to-save-wmi-object-new-settings-0x80041003-acess-denied?forum=winserverManagement

Have a  look at the Eventlog as well - you might get more details about this problem there.

Details about WMI can be found here: https://docs.microsoft.com/en-au/windows/win32/wmisdk/wmi-start-page

The forum returns something like this:

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jguinch
      Hello.
      I did create these few functions several months ago. I post here, if it can interest someone.
      These functions based on WMI queries allow you to manage printers : add / delete printer, driver, port, or obtain configuration, set default printer ... I let you discover it with the code.

       
      Here is the list of the available functions :
      _PrintMgr_AddLocalPort
      _PrintMgr_AddLPRPort
      _PrintMgr_AddPrinter
      _PrintMgr_AddPrinterDriver
      _PrintMgr_AddTCPIPPrinterPort
      _PrintMgr_AddWindowsPrinterConnection
      _PrintMgr_CancelAllJobs
      _PrintMgr_CancelPrintJob
      _PrintMgr_EnumPorts
      _PrintMgr_EnumPrinter
      _PrintMgr_EnumPrinterConfiguration
      _PrintMgr_EnumPrinterDriver
      _PrintMgr_EnumPrinterProperties
      _PrintMgr_EnumPrintJobs
      _PrintMgr_EnumTCPIPPrinterPort
      _PrintMgr_Pause
      _PrintMgr_PortExists
      _PrintMgr_PrinterExists
      _PrintMgr_PrinterSetComment
      _PrintMgr_PrinterSetDriver
      _PrintMgr_PrinterSetPort
      _PrintMgr_PrinterShare
      _PrintMgr_PrintTestPage
      _PrintMgr_RemoveLocalPort
      _PrintMgr_RemoveLPRPort
      _PrintMgr_RemovePrinter
      _PrintMgr_RemovePrinterDriver
      _PrintMgr_RemoveTCPIPPrinterPort
      _PrintMgr_RenamePrinter
      _PrintMgr_Resume
      _PrintMgr_SetDefaultPrinter
       
       
      And some examples :
      #include <Array.au3> #include "PrintMgr.au3" _Example() Func _Example() ; Remove a printer called "My old Lexmark printer" : _PrintMgr_RemovePrinter("My old Lexmark printer") ; Remove the driver called "Lexmark T640" : _PrintMgr_RemovePrinterDriver("Lexmark T640") ; Remove the TCP/IP printer port called "TCP/IP" _PrintMgr_RemoveTCPIPPrinterPort("MyOLDPrinterPort") ; Add a driver, called "Samsung ML-451x 501x Series", and driver inf file is ".\Samsung5010\sse2m.inf" _PrintMgr_AddPrinterDriver("Samsung ML-451x 501x Series", "Windows NT x86", @ScriptDir & "\Samsung5010", @ScriptDir & "\Samsung5010\sse2m.inf") ; Add a TCP/IP printer port, called "MyTCPIPPrinterPort", with IPAddress = 192.168.1.10 and Port = 9100 _PrintMgr_AddTCPIPPrinterPort("MyTCPIPPrinterPort", "192.168.1.10", 9100) ; Add a printer, give it the name "My Printer", use the driver called "Samsung ML-451x 501x Series" and the port called "MyTCPIPPrinterPort" _PrintMgr_AddPrinter("My Printer", "Samsung ML-451x 501x Series", "MyTCPIPPrinterPort") ; Set the printer called "My Printer" as default printer _PrintMgr_SetDefaultPrinter("My Printer") ; Connect to the shared printer "\\192.168.1.1\HPDeskjetColor") _PrintMgr_AddWindowsPrinterConnection("\\192.168.1.1\HPDeskjetColor") ; List all installed printers Local $aPrinterList = _PrintMgr_EnumPrinter() _ArrayDisplay($aPrinterList) ; List all printers configuration Local $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration() _ArrayDisplay($aPrinterConfig) ; List all installed printer drivers Local $aDriverList = _PrintMgr_EnumPrinterDriver() _ArrayDisplay($aDriverList) ; Retrieve the printer configuration for the printer called "Lexmark T640" $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration("Lexmark T640") _ArrayDisplay($aPrinterConfig) ; Add a local printer port (for a file output) _PrintMgr_AddLocalPort("c:\temp\output.pcl") ; Remove the local port _PrintMgr_RemoveLocalPort("c:\temp\output.pcl") ; Enum a print job Local $aJobList = _PrintMgr_EnumPrintJobs() _ArrayDisplay($aJobList) EndFunc ;==>_Example Download link :
      PrintMgr_Example.au3  PrintMgr.au3
       
    • By hek
      Hey everyone,
      Was wondering how I would be able to implement this on a local computer instead of using connectserver? 
      Any suggestions or help would be appreciated. Thanks. 
    • By DirtyJohny
      Hi everyone.Need rewrite this function how in еxample.
      Original:
      #RequireAdmin #NoTrayIcon Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next MsgBox(262144,'Monitors '&$lss.Count,$sss&" "&@CR) $lss=Null $sls=Null EndFunc _a() Example:
      Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) If IsObj($ObjService) Then For $objItemMB In $ObjMB $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)
    • By shital
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** RunAs(test", @ComputerName, "testinng",2,"wmic product where ""name= '%notepadexamples%'"" call uninstall", @SystemDir & "\wbem", @SW_MAXIMIZE)  it not working 
       
    • By Colduction
      Hi AutoIt Programmers!

      I've seen a code that gives Name of Group by writing it's group's SID, but this one response very slower than Windows Command-Line WMIC
       
      Func _GetLocalGroupName($sSID = 'S-1-5-18') $objWMIService = ObjGet ("winmgmts:\\" & @ComputerName & "\root\cimv2") $colItems = $objWMIService.ExecQuery('SELECT Name FROM Win32_Group where SID="' & $sSID & '"') For $GroupNames in $colItems MsgBox (0,"",$GroupNames.Name) ExitLoop Next EndFunc I don't want call and use any third-party programs even CMD, i just want use from Windows API, netapi32.dll or AutoIt Functions (Standalone).
      Do you have any idea to improve speed/performance of this code? I'll happy of your comments
       
       
       
      ====================== SOLOUTION by @Subz ======================
       
×
×
  • Create New...