Common WMI tasks

Post a reply


In an effort to prevent automatic submissions, we require that you type the text displayed into the field underneath.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Common WMI tasks

Re: Common WMI tasks

Post by Tomer » 13 Oct 2016, 01:42

very useful! tnx

Re: Common WMI tasks

Post by arcticir » 14 Aug 2014, 10:49

I ask, can detect whether there is a touch screen, and get its message?


Like this, but I did not find the direct detection of the touch screen

Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: Common WMI tasks

Post by tank » 09 Feb 2014, 14:43

In light of my error in judgement and search skills. I am going to Reference
jNizM wrote:AHK - WMI - Snippets
... -.-
at the top of this. I was in the process of trying to remove duplicates from this thread and merge the topic to his when i realized for the most part that the entire thread was more refined versions of these calls. Most of the ones I compiled to this list are raw examples where His is more a refined results and more useful as-is

Re: Common WMI tasks

Post by Menixator » 08 Feb 2014, 09:03

jNizM wrote:AHK - WMI - Snippets
... -.-


LOL :P

Re: Common WMI tasks

Post by jNizM » 06 Feb 2014, 01:50

Get Process properties via AHK using WMI

Post by hoppfrosch » 06 Feb 2014, 01:31

Get Process properties:

Re: Common WMI tasks

Post by lexikos » 06 Feb 2014, 00:35

There are color tags in many of the examples, which do not work.

Instead of using ._NewEnum and While, you can use a for-loop. For example, see below.

The string passed to ComObjGet can be shortened quite a bit in many cases. The local computer name \\.\ can be omitted. {impersonationLevel=impersonate}! and root\cimv2 can be omitted, provided that the default impersonation level and default namespace in the registry have their standard values.

For me, this makes it much easier to write WMI scripts from memory, without having to refer to documentation or other code.

Code: [Select all]GeSHi © Codebox Plus

; Get a list of executables running on this computer.
for obj in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where ExecutablePath is not null")
s .= obj.ExecutablePath "`n"
Sort s, U ; Remove duplicates.
MsgBox % s

I just learned that you can also get a specific WMI class or instance directly, though I'm not sure of the details. For example, this shows the file system of drive C:

Code: [Select all]GeSHi © Codebox Plus

MsgBox % ComObjGet("winmgmts:root\cimv2:Win32_LogicalDisk=""C:""").FileSystem

Common WMI tasks

Post by tank » 05 Feb 2014, 23:47

tank wrote:In light of my error in judgement and search skills. I am going to Reference
. jNizM's more a refined results and more useful as-is


Compiled from wmi-tasks-com-with-ahk-l
Posted here for ease. All credit to SBC and Shajul

WMI Tasks COM with AHK_L

Some examples from MSDN http://msdn.microsof...5(v=VS.85).aspx.

New users can convert all the MSDN examples given to Native AHK code, I am just giving some examples


CD-ROM drives details:

Code: [Select all]GeSHi © Codebox Plus

strComputer := "." 
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . strComputer . "\root\cimv2")

colItems := objWMIService.ExecQuery("Select * from Win32_CDROMDrive")._NewEnum
While colItems[objItem]
MsgBox % "Device ID: " . objItem.DeviceID
. "`nDescription: " . objItem.Description
. "`nName: " . objItem.Name


Ping without ping.exe :

Code: [Select all] [Expand]GeSHi © Codebox Plus



Computer system details:

Code: [Select all] [Expand]GeSHi © Codebox Plus



Operating system details and free physical memory:

Code: [Select all] [Expand]GeSHi © Codebox Plus



Properties of the mouse used on computer:

Code: [Select all] [Expand]GeSHi © Codebox Plus



List Desktop settings:

Code: [Select all] [Expand]GeSHi © Codebox Plus



List BIOS details

Code: [Select all] [Expand]GeSHi © Codebox Plus


Memory:

Code: [Select all] [Expand]GeSHi © Codebox Plus


Onboard Devices:

Code: [Select all] [Expand]GeSHi © Codebox Plus


Hard Drives:

Code: [Select all] [Expand]GeSHi © Codebox Plus


Motherboard:

Code: [Select all] [Expand]GeSHi © Codebox Plus


CPU:

Code: [Select all] [Expand]GeSHi © Codebox Plus


Product:

Code: [Select all]GeSHi © Codebox Plus

;http://msdn.microsoft.com/en-us/library/aa394105%28v=vs.85%29.aspx 
PropertyList := "Caption,Description,IdentifyingNumber,Name,SKUNumber,UUID,Vendor,Version"
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2")
WQLQuery = Select * From Win32_ComputerSystemProduct
colSysProduct := objWMIService.ExecQuery(WQLQuery)._NewEnum
While colSysProduct[objSysProduct]
Loop, Parse, PropertyList, `,
ProductInfo .= A_LoopField . ":`t" . objSysProduct[A_LoopField] . "`n"
MsgBox % ProductInfo

****



List of Installed Applications

Code: [Select all] [Expand]GeSHi © Codebox Plus



List of Installed Audio and Video Codecs

Code: [Select all] [Expand]GeSHi © Codebox Plus



List of Fonts installed with Applications

Code: [Select all] [Expand]GeSHi © Codebox Plus



List of User Accounts

Code: [Select all] [Expand]GeSHi © Codebox Plus



List of System Accounts

Code: [Select all] [Expand]GeSHi © Codebox Plus



List of Shared Folders and Printes

Code: [Select all] [Expand]GeSHi © Codebox Plus



List of running processes (narrowed down to those which path can be retrieved)

Code: [Select all]GeSHi © Codebox Plus

strComputer := "." 
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . strComputer . "\root\cimv2")
colItems := objWMIService.ExecQuery("SELECT Caption,ExecutablePath,ProcessID FROM Win32_Process where ExecutablePath is not null")._NewEnum
While colItems[objItem]
MsgBox % "Caption: " . objItem.Caption
. "`nProcessID: " . objItem.ProcessID
. "`nExecutablePath: " . objItem.ExecutablePath

Top