vbs script to change firefox proxy server
So far i have this, I am planning to send this script to a number of people on the network so it changes their proxy server to the correct one.
The trouble is i need to some how implement a part where it gets the folder that is in C:\documents and settings\administrator\application data\mozilla\firefox\Profiles\
Because the part in bold is the profile name, which is different on every computer.
user_pref("network.proxy.autoconfig_url", "http://102.10.0.0:3132/proxy.pac"); - this is the line which is in the firefox settings file
Each user that i will send this too has the same wrong proxy entered so i basicaly wanted to do a search on the file for the line above and replace it with
user_pref("network.proxy.autoconfig_url", "http://10.0.0.1:3132/proxy.pac");
Is this that diffiicult? Please give me your input
Const ForReading = 1
Const ForWriting = 2
firefold = C:\documents and settings\administrator\application data\mozilla\firefox\Profiles\lr3u7j6k.default\prefs.js"
firerep = user_pref("network.proxy.autoconfig_url", "http://102.10.0.0:3132/proxy.pac");
firenew = user_pref("network.proxy.autoconfig_url", "http://10.0.0.1:3132/proxy.pac");
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(" & firefold & ", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, " & firerep & ", "& firenew & ")
Set objFile = objFSO.OpenTextFile("& firefold & ", ForWriting)
objFile.WriteLine strNewText
Re: vbs script to change firefox proxy server
the profile folder is in the profiles.ini file for each user in the firefox folder
Re: vbs script to change firefox proxy server
Hi there,
I searched for hours to get a "ready to use" solution to alter firefox proxy via GPO or script, but I didn't find one.
So I just wrote that little vbscript to change Firefox proxy (or even other settings).
You may even call it via startup-GPO or login script =)
First you have to setup a file named "user.js" like this:
(assuming 192.168.99.244 is your proxy-server)
Code:
user_pref("network.proxy.backup.ftp", "192.168.99.254");
user_pref("network.proxy.backup.ftp_port", 8080);
user_pref("network.proxy.backup.gopher", "192.168.99.254");
user_pref("network.proxy.backup.gopher_port", 8080);
user_pref("network.proxy.backup.socks", "192.168.99.254");
user_pref("network.proxy.backup.socks_port", 8080);
user_pref("network.proxy.backup.ssl", "192.168.99.254");
user_pref("network.proxy.backup.ssl_port", 8080);
user_pref("network.proxy.ftp", "192.168.99.254");
user_pref("network.proxy.ftp_port", 8080);
user_pref("network.proxy.gopher", "192.168.99.254");
user_pref("network.proxy.gopher_port", 8080);
user_pref("network.proxy.http", "192.168.99.254");
user_pref("network.proxy.http_port", 8080);
user_pref("network.proxy.share_proxy_settings", true);
user_pref("network.proxy.socks", "192.168.99.254");
user_pref("network.proxy.socks_port", 8080);
user_pref("network.proxy.socks_remote_dns", true);
user_pref("network.proxy.ssl", "192.168.99.254");
user_pref("network.proxy.ssl_port", 8080);
user_pref("network.proxy.type", 1);
Then put "user.js" it in a folder together with the following vbscript.
Name it ChangeFirefoxSettings.vbs or something like that.
Running the script copies "user.js" in all (if more than one exists) firefox-profiles of the current user:
Code:
FileToCopy = "user.js"
Set oFSO = CreateObject("Scripting.FileSystemObject")
'get AppdataPath
Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
AppdataPath = WshSysEnv("APPDATA")
FoxProfilePath = AppdataPath & "\Mozilla\Firefox\Profiles\"
' is firefox and user.js present?
if oFSO.FolderExists(FoxProfilePath) AND oFSO.FileExists(FileToCopy) Then
' copy user.js in all profilefolders to get around those random profile names =)
For Each ProfileFolder In oFSO.GetFolder(FoxProfilePath).Subfolders
oFSO.GetFile(FileToCopy).Copy ProfileFolder & "\" & FileToCopy, True
Next
End If
' clean up
Set oFSO = Nothing
Set WshShell = Nothing
Set WshSysEnv = Nothing
I hope this will help =)
cheers
zlep