Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Setting IE Proxy

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,28318
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Setting IE Proxy
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Setting IE Proxy - 11/24/2005 4:57:35 PM   
  yrh4401

 

Posts: 4
Score: 0
Joined: 11/24/2005
Status: offline
'********************************************************************
'* File:           IEProxy.VBS
'* Created Date: 2004/11/23
'* Author         : Ray Yen
'* Version        :   1.0
'*
'* Main Function:
'*
'* Usage:
'   For Example : cscript IEProxy.vbs
'Registry
'[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
'"ProxyEnable"=dword:00000001
'"ProxyServer"="bbb.com:80"
'"ProxyOverride"="<local>"
'*
'*Installs a hypothetical software program (using a Windows Installer package) on a remote computer.
'* Requires delegation for the computer and user accounts involved in the procedure.
'********************************************************************
Const HKEY_CLASSES_ROOT  = &H80000000
Const HKEY_CURRENT_USER  = &H80000001
Const HKEY_LOCAL_MACHINE  = &H80000002
Const HKEY_USERS   = &H80000003
Const HKEY_CURRENT_CONFIG  = &H80000005
Const REG_SZ  = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD  = 4
Const REG_MULTI_SZ = 7
'For Environment Variables
Dim strEnvOSName
Dim strEnvOSVersion
Dim strEnvOSLanguage
Dim strEnvOSPatch
Dim strEnvOSPatchVersion
Dim strEnvIEVerion
Dim strEnvOEVersion

'Proxy Server Client Setting
Dim strProxyServer
Dim strProxyEnable
Dim strProxyOverride
strProxyServer = "bbb.com:80"
strProxyEnable = 1    'DWORD
strProxyOverride = "<local>"
Dim strTestMode
'======== Customize variables =============
'strTestMode=True      'Show Debug Message
strTestMode=False      'Don't Show Debug Message
Call CheckOS()
Call Main()
'===================================
' Main Sub
'Note :
' Value : 1 = Permit , 5 = Not Accept
'===================================
Sub Main()
Dim strComputer, strRegistryLoc, strRegistryName
Dim strRegistryFullPath
Dim subkey
Dim vntSubKeyListArray
Dim strRegistryType
Dim blnResult
Dim strExistedValue
strComputer = "."      'Or IP Address

'Setting Registry String
strRegistryType = "HKEY_CURRENT_USER"
   strRegistryLoc = "Software\Microsoft\Windows\CurrentVersion\Internet Settings"   
strRegistryName = "ProxyServer" 
'Check exist registry
strRegistryFullPath = strRegistryType & "\" & strRegistryLoc & "\" & strRegistryName
PrintDebug "strRegistryFullPath = " & strRegistryFullPath 

strExistedValue = fnRegRead(strRegistryFullPath)
PrintDebug "Read Existed Registry Value = " & strExistedValue

'If client proxy server setting <> setting value the write the registry to client
If Trim(strExistedValue) <> strProxyServer Then

 'Write ProxyServer
 strRegistryName = "ProxyServer"
 strRegistryFullPath = strRegistryType & "\" & strRegistryLoc & "\" & strRegistryName
 blnResult = fnRegWrite(strRegistryFullPath,strProxyServer,"REG_SZ")
 PrintDebug "Write ProxyServer : " & blnResult
 
 'Write ProxyEnable
 strRegistryName = "ProxyEnable"
 strRegistryFullPath = strRegistryType & "\" & strRegistryLoc & "\" & strRegistryName
 blnResult = fnRegWrite(strRegistryFullPath,strProxyEnable,"REG_DWORD")
 PrintDebug "Write ProxyEnable : " & blnResult
   
 'Write ProxyOverride
 strRegistryName = "ProxyOverride"
 strRegistryFullPath = strRegistryType & "\" & strRegistryLoc & "\" & strRegistryName
 blnResult = fnRegWrite(strRegistryFullPath,strProxyOverride,"REG_SZ")
 PrintDebug "Write ProxyOverrider : " & blnResult
  
End If

PrintDebug "Script Running Done!"
End Sub
'=========================
'Read Registry
'=========================
Function fnRegRead(strRegistry)
On Error Resume Next
   Dim wshShell
   Dim bKey
  
   Set wshShell = Wscript.CreateObject("WScript.Shell")
   bKey = wshShell.RegRead(strRegistry)
  
   fnRegRead = bKey
  
   If Err.Number <> 0 Then
       Msg = "Error # " & CStr(Err.Number) & " was generated by " & Err.Source & Chr(13)
       PrintScreen "Error Message : " & Msg
       PrintScreen "Error Description : " & Err.Description
       Err.Clear       
       fnRegRead = 0   
   End If     
End Function
'=========================
'Write Registry
'strRegType : REG_SZ....
'=========================
Function fnRegWrite(strRegistry , intValue, strRegType)
On Error Resume Next
   Dim wshShell
  
   Set wshShell = Wscript.CreateObject("WScript.Shell")
   wshShell.RegWrite strRegistry, intValue, strRegType
 
   fnRegWrite = True
  
   If Err.Number <> 0 Then
       Msg = "Error # " & CStr(Err.Number) & " was generated by " & Err.Source & Chr(13)
       PrintScreen "Error Message : " & Msg
       PrintScreen "Error Description : " & Err.Description
       Err.Clear               
       fnRegWrite = False
   End If
End Function
'=========================
'Get Remote  Registry value
'GetDWORDValue Method of the StdRegProv Class
'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/getdwordvalue_method_in_class_stdregprov.asp
'=========================
Function GetRemoteRegValue(strComputer,strKeyPath,strValueName,strRegistryType)
On Error Resume Next
Dim oReg
Dim dwValue
Dim intCount
Dim blnResult 

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") 
blnResult = oReg.GetDWORDValue(strRegistryType,strKeyPath,strValueName,dwValue)

   GetRemoteRegValue = dwValue
  
End Function
'=========================
'Get Local Registry value
'=========================
Function RetriveRegistry(strKeyPath,strValueName,strRegistryType)
On Error Resume Next
Dim strComputer
Dim dwValue
Dim blnResult
   strComputer = "."
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
blnResult = oReg.GetDWORDValue(strRegistryType,strKeyPath,strValueName,dwValue)
RetriveRegistry = dwValue

End Function
'===========================================================================
'List Registry Subkey (Return Array)
'===========================================================================
Function vntEnumSubKey(strComputer,strKeyPath,strRegistryType)
On Error Resume Next
Dim oReg
   Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
oReg.EnumKey strRegistryType, strKeyPath, arrSubKeys 
vntEnumSubKey = arrSubKeys

End Function 
'=============== Function Area ===========================
'
'=============== Function Area ===========================
Sub WriteLine(strLine)
On Error Resume Next
    objLogFile.WriteLine strLine
End Sub
Sub PrintScreen(strMessage)
Wscript.Echo strMessage
End Sub
Sub PrintDebug(strMessage)
If strTestMode=True Then
 Wscript.Echo strMessage
End If
End Sub
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Setting IE Proxy Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts