get-ie-proxy-names-and-values.vbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OPTION EXPLICIT | |
ForceScriptEngine("cscript") | |
Const ForAppending = 8 | |
Const HKEY_CURRENT_USER = &H80000001 | |
Dim fso, WSHNetwork, strComputer, CScolItems, objItem, strCompDom, strComputerDomain, strLogPath, strFileDate, objTextFile, objReg, objWMIService, strKeyPath, arrValueNames, arrValueTypes, i, z, ValueName, iValues, BinaryValues(), strValues | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set WSHNetwork = CreateObject("WScript.Network") | |
strComputer = WSHNetwork.ComputerName | |
' | |
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" ) | |
Set CScolItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") | |
For Each objItem in CScolItems | |
strComputerDomain = lcase(objItem.Domain) | |
Next | |
'SETUP SOME FILE/LOGGING PROPERTIES | |
strLogPath = "\\SOME_SERVER\SOME_VERY_OPEN_HIDDEN_SHARE$\" | |
strFileDate = Replace(FormatDateTime(Date(),2),"/","-") | |
'CREATE TEXT FILE SYSTEM OBJECT | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set objTextFile = fso.OpenTextFile(strLogPath & "VPN_PROXIES_VALUES" & ".txt",8,True) | |
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ | |
strComputer & "\root\default:StdRegProv") | |
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" | |
objReg.EnumValues HKEY_CURRENT_USER, strKeyPath, arrValueNames, arrValueTypes | |
For i=0 To UBound(arrValueNames) | |
If arrValueNames(i)="DefaultConnectionSettings" or arrValueNames(i)="SavedLegacySettings" or arrValueNames(i)="" Then | |
'Do Nothing | |
Else | |
ValueName = arrValueNames(i) | |
objReg.GetBinaryValue HKEY_CURRENT_USER, strKeyPath, ValueName, iValues | |
strValues="" | |
For z = lBound(iValues) to uBound(iValues) | |
strValues=strValues & iValues(z) & "," | |
Next | |
objTextFile.WriteLine strFileDate & "," & strComputer & "," & strComputerDomain & "," & ValueName & "," & strValues | |
End If | |
Next | |
objTextFile.Close | |
'TIDY UP | |
Set fso = Nothing | |
Set WSHNetwork = Nothing | |
Set strComputer = Nothing | |
Set strLogPath = Nothing | |
Set strFileDate = Nothing | |
Set objTextFile = Nothing | |
Set objWMIService = Nothing | |
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Sub ForceScriptEngine(strScriptEng) | |
' Forces this script to be run under the desired scripting host. | |
' Valid arguments are "wscript" or "cscript". | |
' The command line arguments are passed on to the new call. | |
Dim arrArgs | |
Dim strArgs | |
For Each arrArgs In WScript.Arguments | |
strArgs = strArgs & " " & Chr(34) & arrArgs & Chr(34) | |
Next | |
If Lcase(Right(Wscript.FullName, 12)) = "\wscript.exe" Then | |
If Instr(1, Wscript.FullName, strScriptEng, 1) = 0 Then | |
CreateObject("Wscript.Shell").Run "cscript.exe //Nologo " & _ | |
Chr(34) & Wscript.ScriptFullName & Chr(34) & strArgs | |
Wscript.Quit | |
End If | |
Else | |
If Instr(1, Wscript.FullName, strScriptEng, 1) = 0 Then | |
CreateObject("Wscript.Shell").Run "wscript.exe " & Chr(34) & _ | |
Wscript.ScriptFullName & Chr(34) & strArgs | |
Wscript.Quit | |
End If | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment