Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use vbs to list all the components that can be called on the machine

Shulou Source: shulou.com Published: 2022-06-03 19:37:32 09月17日 Update

This article focuses on "how to use vbs to list all the components that can be called on the machine", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use vbs to list all the components that can be called on the machine.

Core code

Set wshshell = CreateObject ("WScript.Shell") set registry = CreateObject ("regtool.tob") 'get a dictionary object storage key name set dict = CreateObject ("Scripting.Dictionary")' enumerate all keys in HKEY_CLASSES_ROOT set allkeys = registry.RegEnum ("HKCR\") 'exclude all key names in the keys. Where is the first point of for each key in allkeys'(skip the initial point)? Pos = Instr (2, key, ".") If pos > 0 then 'there's a dot. Is there another one? Pos2 = Instr (pos+1, key, ".") If pos2 > 0 then 'yes, so this name is version specific' check whether we already have a 'version-independent progid! Independent = left (key, pos2-1) if not dict.Exists (independent) then'no, store it dict.Add key, 0 end if else 'this one is version-independent. 'do we already have a version-dependent' progID in store? Vdpid = "" for each element in dict if len (element) > len (key) then if left (element, len (key) + 1) = key & ". Then 'yes, return name vdpid = element exit for end if end if next' any version dependent progID found? If vdpid= "" then'no, add to store dict.add key, 0 else 'yes, replace dict.Remove vdpid dict.add key, 0 end if end if end if next MsgBox dict.Count & "Objects found!" For each key in dict list = list & key & vbCrlf next MsgBox list outputfile = "C:\ OBJECT.TXT" set fs = CreateObject ("Scripting.FileSystemObject") set output = fs.CreateTextFile (outputfile, true) print dict.Count & "Objects found!" Print list output.close wshshell.run outputfile sub Print (text) 'write information to the record file output.WriteLine text end sub here, I believe you have a better understanding of "how to use vbs to list all the components that can be called on the machine", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Machines components content learning practical deeper code interests practicality practicality objects simple operations files methods more friends cores websites channels storage Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei Shulou Information Linux MySQL