-
Notifications
You must be signed in to change notification settings - Fork 0
/
getlist.vbs
65 lines (51 loc) · 2.74 KB
/
getlist.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
on error resume Next
Const HKLM = &H80000002
Const HKCU = &H80000001
Const strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Const strKeyPathwin ="SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
Const ForReading = 1
Const ForAppending = 8
Const FilePath ="\\dir\\"
Set Wshell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemobject")
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("ipconfig")
strIpConfig = objScriptExec.StdOut.ReadAll
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
Set colMatches = objRegEx.Execute(strIpConfig)
If colMatches.Count > 0 Then
if (objFSO.FileExits(FilePath & colMatches(0).Value & "(" & WshNetwork.ComputerName & ")" &".txt")) then
Set MyFile = objFSO.GetFile(FilePath & colMatches(0).Value & "(" & WshNetwork.ComputerName & ")" &".txt")
MyFile.Delete
End If
End If
Set textWriteFile = objFSO.OpenTextFile(FilePath & colMatches(0).Value & "(" & WshNetwork.ComputerName & ")" &".txt",forappending,True)
Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
objReg.EnumKey HKCU, strKeyPath,arrSubKeys
For Each strSubKey In arrSubKeys
intRet = objReg.GetStringValue(HKCU, strKeyPath & strSubKey,"DisplayName",strValue)
If strValue <> "" And intRet = 0 And Left(strSubKey, 2) <> "KB" Then
textWriteFile.WriteLine(strValue)
End If
Next
Set objReglm = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
objReg.EnumKey HKLM, strKeyPath,arrSubKeys
For Each strSubKey In arrSubKeys
intRet = objReg.GetStringValue(HKLM, strKeyPath & strSubKey,"DisplayName",strValue)
If strValue <> "" And intRet = 0 And Left(strSubKey, 2) <> "KB" Then
textWriteFile.WriteLine(strValue)
End If
Next
Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
objReg.EnumKey HKLM, strKeyPathwin,arrSubKeys
For Each strSubKey In arrSubKeys
intRet = objReg.GetStringValue(HKLM, strKeyPathwin & strSubKey,"DisplayName",strValue)
If strValue <> "" And intRet = 0 And Left(strSubKey, 2) <> "KB" Then
textWriteFile.WriteLine(strValue)
End If
Next