Windows Scripting BLOG

Due to limited time working on this project this place is not intended to people who are new to scripting but much more for people who are already familiar with the VBS/WMI syntax.

Donnerstag, 17. Mai 2007

Set proxy Settings in IE for currently logged on user

On Error Resume
NextstrComputer = "."HKEY_USERS = &H80000003
strKeyPath = "\Software\Microsoft\Windows\CurrentVersion\Internet Settings\"strEntryName = "AutoConfigURL"dwValue = "http://proxy/pac/proxy.pac" 'change to reflect Proxy
Set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMICimService = objWMILocator.ConnectServer(strComputer, "root\cimv2")
Set colItems = objWMICimService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
nm = objItem.UserNameResult = InStrRev(nm, "\")
tre = len(nm)tre1 = tre - ResultRes = right(nm,tre1)
Set colOS = objWMICimService.ExecQuery("Select * from WIN32_UserAccount where Name="""& Res & """")
for each obj in colOS
sidentry = obj.SID
Nextnext
Set objReg = GetObject _ ("winmgmts:{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\default:StdRegProv")
comppath = "" & sidentry & "" & strKeyPath & ""
retVal = objReg.SetStringValue(HKEY_USERS, comppath, strEntryName, dwValue)
if retval <> 0 thenWScript.Echo "Setting Proxy failed"ElseWScript.Echo "Setting Proxy done for User: " & Res & " and Proxy: " & dwValue
End If
' Proxy Change for non-transparent Proxies by Julian Ruf

Keine Kommentare: