This routine replaces a string in the text file user.js. The file is located in each user’s profile which also contains a random string as part of the path name.
Imports System.Net Imports System.IO Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim strPath As String = "c:\users" Dim arrFolders() As String = System.IO.Directory.GetDirectories(strPath) Dim MozPath As String '---------------------------------------------------------------- ' get list of profiles '---------------------------------------------------------------- For Each arrFolder As String In arrFolders MozPath = arrFolder & "\AppData\Roaming\Mozilla\Firefox\Profiles\" If My.Computer.FileSystem.DirectoryExists(MozPath) = True Then Dim arrGUIDpath() As String = System.IO.Directory.GetDirectories(MozPath) For Each arrGUIDfolder As String In arrGUIDpath If My.Computer.FileSystem.FileExists(arrGUIDfolder & "\user.js") = True Then Console.WriteLine("notepad " & arrGUIDfolder & "\user.js") '---------------------------------------------------------------- ' 1. rename the user.js file ' 2. replace the proxy defintion string tinto user.js '---------------------------------------------------------------- Try My.Computer.FileSystem.DeleteFile(arrGUIDfolder & "\user2.js") Catch ex As Exception Application.DoEvents() End Try My.Computer.FileSystem.CopyFile(arrGUIDfolder & "\user.js", arrGUIDfolder & "\user2.js") My.Computer.FileSystem.WriteAllText(arrGUIDfolder & "\user.js", _ My.Computer.FileSystem.ReadAllText(arrGUIDfolder & "\user2.js").Replace("user_pref(""network.proxy.type"", 4);", _ "user_pref(""network.proxy.type"", 0);"), False) End If '---------------------------------------------------------------- ' clean up to avoid confusion in the future '---------------------------------------------------------------- Application.DoEvents() Try My.Computer.FileSystem.DeleteFile(arrGUIDfolder & "\user2.js") Catch ex As Exception Application.DoEvents() End Try Next End If Next End End Sub End Class