TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: dubb on February 15, 2018, 10:21:39 AM
-
Question in the title.
-
Method in post. (http://www.theswamp.org/index.php?topic=42807.msg533923#msg533923)
-
(defun vk_ReleaseObjects (lst)
(foreach o (if (atom lst)
(list lst)
lst
)
(and o
(= (type o) 'VLA-OBJECT)
(not (vlax-object-released-p o))
(vlax-release-object o)
)
)
)
(defun vk_GetWbem (Class Props / LocatorObj ServiceObj ObjectSetObj OutList)
(and (setq LocatorObj (vlax-create-object "WbemScripting.SWbemLocator"))
(setq ServiceObj (vlax-invoke LocatorObj 'ConnectServer "." "root\\cimv2" nil nil nil nil nil nil))
(setq ObjectSetObj (vlax-invoke ServiceObj 'ExecQuery (strcat "SELECT * FROM " Class)))
(vlax-for Obj ObjectSetObj
(setq OutList (cons (mapcar (function (lambda (p) (vlax-get Obj p))) Props) OutList))
)
)
(vk_ReleaseObjects (list ObjectSetObj ServiceObj LocatorObj))
(reverse OutList)
)
(vk_GetWbem "Win32_Process" (list "Name" "ExecutablePath" "CommandLine"))
one can also grab lots of other stuff with that
(vk_GetWbem "Win32_NetworkAdapterConfiguration" (list "MACAddress" "IPAddress"))
(vk_GetWbem "Win32_Processor" (list "ProcessorId" "Manufacturer" "CurrentClockSpeed"))
-
Awesome! this works pretty good. All I need to do is modify it to verify a specific process. This script returns an entire list of processes, so I use assoc to locate the process i need.
(defun vk_ReleaseObjects (lst)
(foreach o (if (atom lst)
(list lst)
lst
)
(and o
(= (type o) 'VLA-OBJECT)
(not (vlax-object-released-p o))
(vlax-release-object o)
)
)
)
(defun vk_GetWbem (Class Props / LocatorObj ServiceObj ObjectSetObj OutList)
(and (setq LocatorObj (vlax-create-object "WbemScripting.SWbemLocator"))
(setq ServiceObj (vlax-invoke LocatorObj 'ConnectServer "." "root\\cimv2" nil nil nil nil nil nil))
(setq ObjectSetObj (vlax-invoke ServiceObj 'ExecQuery (strcat "SELECT * FROM " Class)))
(vlax-for Obj ObjectSetObj
(setq OutList (cons (mapcar (function (lambda (p) (vlax-get Obj p))) Props) OutList))
)
)
(vk_ReleaseObjects (list ObjectSetObj ServiceObj LocatorObj))
(reverse OutList)
)
(vk_GetWbem "Win32_Process" (list "Name" "ExecutablePath" "CommandLine"))
one can also grab lots of other stuff with that
(vk_GetWbem "Win32_NetworkAdapterConfiguration" (list "MACAddress" "IPAddress"))
(vk_GetWbem "Win32_Processor" (list "ProcessorId" "Manufacturer" "CurrentClockSpeed"))
-
<code>
one can also grab lots of other stuff with that
<code>
Very nice!
Russian hacker spotted.. :lol:
-
Russian hacker
hehe :)
neither of those
just a common ukrainian ;)
-
I always think of vodka when I see VovKa. :lmao:
-
Another take (may be flawed, enduring crushing headache) ...
(defun _WbemGet ( class props / locator service query temp result )
(vl-catch-all-apply 'eval
'( (vlax-for x
(setq query
(vlax-invoke
(setq service
(vlax-invoke
(setq locator (vlax-create-object "WbemScripting.SWbemLocator"))
'ConnectServer "." "root\\cimv2" nil nil nil nil nil nil
)
)
'ExecQuery
(strcat "SELECT * FROM " class)
)
)
(setq temp
(cons
(mapcar
(function (lambda (p) (vl-catch-all-apply 'vlax-get (list x p))))
(if (listp props) props (list props))
)
temp
)
)
)
)
)
(foreach x (mapcar 'list (list query service locator))
(vl-catch-all-apply 'vlax-release-object x)
)
(foreach l temp
(or
(null (apply 'or l))
(member l result)
(setq result (cons l result))
)
)
(if (listp props) result (mapcar 'car result))
)
(_WbemGet "Win32_Process" '(Name ExecutablePath CommandLine))
(_WbemGet "Win32_Process" '(Name ProcessID))
(_WbemGet "Win32_Process" 'Name)
Edit: Modified so you can see when you request an invalid property:
(_WbemGet "Win32_Process" '(Name Bogosity))
Cheers.
-
did someone say vovka?
-
This thread may also be of interest:
http://www.theswamp.org/index.php?topic=38102
did someone say vovka?
Superb :lol:
-
Product of Sweden / Product of Ukraine
Thank goodness, as far as I know, the Swedish and Ukrainian relations are not an issue.
-
I always think of vodka when I see VovKa. :lmao:
one of my professors at the university (yep he was an American) told me that my name sounds to him like Volvo (yep it is a Swedish car)
the Swedish and Ukrainian relations are not an issue.
300 years ago we even fought together against Russia :)
did someone say vovka?
and now Swedish vodka... all is interconnected in this world... :)
p.s. you would not believe guys, but my wife teaches Swedish at the university
-
What's all the Swedish talk about? :whistling:
-
What's all the Swedish talk about? :whistling:
i've never met one
have no idea what they are up to ;-)
-
What about Dan Akroyds Vodka I think it was voted best in world, made in Canada, but some one who chases ghosts needs a good shot every now and then.