'############################################################################################# '# '# Script pour ajouter le proxy wpad.dat en admin (via le serveur horus) '# '# <-_-_-> marco <-_-_-> SIS <-_-_-> 03/07/15 '# '############################################################################################# ' ' v 2.0 ' '//////// Public appdata, usr Public pathff, pathffComp, lastprof, iesettings Public usrjs, proxy23ff, proxy23ie, proxyamonff, proxyamonie, domain Public WshProcessEnv, fso, objShell Const ForAppending = 8 Const ForWriting = 2 Set Args = WScript.Arguments Set objShell = WScript.CreateObject("WScript.Shell") Set WshProcessEnv = objShell.Environment("Process") Set fso = CreateObject("Scripting.FileSystemObject" ) appdata = WshProcessEnv("APPDATA") usr = WshProcessEnv("USERPROFILE") pathff = appdata & "\Mozilla\Firefox\Profiles\" iesettings = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\" proxy23ff = usr & "\proxy23.ff" proxy23ie = usr & "\proxy23.ie" proxyamonff = usr & "\proxyamon.ff" proxyamonie = usr & "\proxyamon.ie" if args.count > 0 then if Args(0) <> "clean" then domain = args(0) else call clean() end if else domain = "wpad.proxyamon.local" end if Function proxfirefox() 'Modification du proxy pour tous les profils de firefox on error resume next Dim f, f1, fc Set f = fso.GetFolder(pathff) Set fc = f.SubFolders For Each f1 in fc lastprof = lastprof & f1.name pathffComp = pathff & lastprof usrjs = pathffComp & "\user.js" If not fso.FileExists(usrjs) Then fso.CreateTextFile outputd & usrjs, True end if Set objMod = fso.OpenTextFile(usrjs, ForWriting) objMod.WriteLine "user_pref(""network.proxy.autoconfig_url"", ""http://" & domain & "/wpad.dat"");" objMod.WriteLine "user_pref(""network.proxy.type"", 2);" objMod.Close lastprof = "" Next fso.CreateTextFile outputd & proxyamonff, True End Function Function proxie() 'Modification du proxy pour IE et Chrome on error resume next objShell.RegWrite iesettings & "AutoConfigURL", "http://" & domain & "/wpad.dat", "REG_SZ" objShell.RegWrite iesettings & "ProxyOverride", "", "REG_SZ" objShell.RegWrite iesettings & "ProxyEnable", 0, "REG_DWORD" fso.CreateTextFile outputd & proxyamonie, True End Function Function clean() 'Nettoyage de la conf on error resume next if fso.FileExists(proxy23ff) then fso.DeleteFile proxy23ff end if if fso.FileExists(proxy23ie) then fso.DeleteFile proxy23ie end if if fso.FileExists(proxyamonff) then fso.DeleteFile proxyamonff end if if fso.FileExists(proxyamonie) then fso.DeleteFile proxyamonie end if Dim f, f1, fc Set f = fso.GetFolder(pathff) Set fc = f.SubFolders For Each f1 in fc lastprof = lastprof & f1.name pathffComp = pathff & lastprof usrjs = pathffComp & "\user.js" if fso.FileExists(userjs) then fso.DeleteFile usrjs end if next objShell.RegDelete iesettings & "AutoConfigURL" msgbox "La configuration automatique du proxy a été désactivée sur ce poste" wscript.quit end function If not fso.FileExists(proxyamonie) Then call proxie() msgbox "Le proxy http://"& domain &"/wpad.dat a été mis en place pour" & Chr(10) & "Internet Explorer et Google Chrome" end if If not fso.FileExists(proxyamonff) and fso.FolderExists(pathff) then call proxfirefox() msgbox "Le proxy http://"& domain &"/wpad.dat a été mis en place pour" & Chr(10) & "Mozilla FireFox" end if wscript.quit