' ---------------------------------------------------------- ' Script d'activation/désactivation de proxy web ' Syntaxe: setproxy [] ' ' Paramètre : ' : URL du fichier de configuration automatique ' si ce paramètre est absent, cela désactive l'usage d'un proxy ' Exemples : ' setproxy http://www.monserveur.net/autoconfproxy.pac ' setproxy ' ' JC BELLAMY © 2003 ' ---------------------------------------------------------- Const SW_HIDE=0 Const SW_SHOWNORMAL=1 Dim net, shell, args, fso, tf Set net = Wscript.CreateObject("WScript.Network") Set shell = WScript.CreateObject("WScript.Shell") Set args = Wscript.Arguments Set fso = WScript.CreateObject("Scripting.FileSystemObject") ficreg=GetPath() & "setproxy.reg" Set tf=fso.CreateTextFile(ficreg,true) tf.writeline "REGEDIT4" tf.writeline tf.writeline "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]" If args.count=0 Then tf.writeline """AutoConfigURL""=-" tf.writeline tf.writeline "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]" tf.writeline """DefaultConnectionSettings""=hex:3c,00,00,00,01,00,00,00,09,00,00,00,00,00,00,\" tf.writeline "00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\" tf.writeline "00,00,00,00,00,00,00,00,00,00,00,00" tf.writeline """SavedLegacySettings""=hex:3c,00,00,00,04,00,00,00,09,00,00,00,00,00,00,00,00,\" tf.writeline "00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\" tf.writeline "00,00,00,00,00,00,00,00,00,00" Else proxy=args(0) tf.writeline """AutoConfigURL""=""" & proxy & """" tf.writeline tf.writeline "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]" tf.writeline """SavedLegacySettings""=hex:3c,00,00,00,06,00,00,00,0d,00,00,00,00,00,00,00,00,\" tf.writeline "00,00,00,2e,00,00,00,\" writeBinProxy tf.writeline "00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\" tf.writeline "00,00,00,00,00,00" tf.writeline """DefaultConnectionSettings""=hex:3c,00,00,00,02,00,00,00,0d,00,00,00,00,00,00,\" tf.writeline "00,00,00,00,00,2e,00,00,00,\" writeBinProxy tf.writeline "00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\" tf.writeline "00,00,00,00,00,00,00,00" end if tf.writeline tf.close shell.run "regedit.exe /s """ & ficreg & """",SW_SHOWNORMAL Wscript.quit '-------------------------------------------------------------------- ' Fonction de récupération du répertoire courant Function GetPath() Dim path path = WScript.ScriptFullName GetPath = Left(path, InStrRev(path, "\")) End Function '-------------------------------------------------------------------- Sub writeBinProxy sbin="" j=0 lmax=len(proxy) For i = 1 To lmax j=j+1 c=mid(proxy,i,1) If sbin<>"" Then sbin=sbin & "," sbin=sbin & Hex(Asc(c)) If (j>=25) or (i=lmax) Then sbin=sbin & ",\" tf.writeline sbin sbin="" j=0 End If Next End Sub '--------------------------------------------------------------------