如何用C#多开不同身份的Tor浏览器?解决第二个浏览器空白问题
Hey there! I see you’re trying to spin up multiple Tor Browser instances with separate identities using C#, but hitting that frustrating blank screen on the second one. Let’s break down why this happens and fix it up.
Why the Second Instance Goes Blank
Tor Browser depends on isolated profile and data directories for each instance to maintain unique identities and avoid resource conflicts. When you launch a second instance without specifying these, it tries to share the same files and state as the first one—this causes it to fail loading properly, resulting in that empty window.
Fixing Your Code
The solution is to launch each Tor Browser instance with its own dedicated profile and data directories, plus a flag to force a new independent session. Here’s how to modify your C# code:
First, note that Tor Browser’s core executable is firefox.exe located inside the Browser folder of your Tor Browser bundle. We’ll pass command-line arguments to this executable to isolate each instance:
using System; using System.Diagnostics; using System.IO; class MultiTorLauncher { static void Main(string[] args) { // Update this path to match your Tor Browser installation string torBrowserExe = @"C:\Program Files\Tor Browser\Browser\firefox.exe"; // Launch first instance with unique identifiers LaunchTorInstance(torBrowserExe, "TorInstance_01"); // Add a small delay to let the first instance initialize (optional but recommended) System.Threading.Thread.Sleep(3000); // Launch second instance with different unique identifiers LaunchTorInstance(torBrowserExe, "TorInstance_02"); } static void LaunchTorInstance(string exePath, string instanceName) { // Create unique, isolated directories for this instance string profileDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), $"TorProfiles\\{instanceName}"); string torDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), $"TorData\\{instanceName}"); // Ensure directories exist (create if they don't) Directory.CreateDirectory(profileDir); Directory.CreateDirectory(torDataDir); // Set up process start info with critical arguments ProcessStartInfo startInfo = new ProcessStartInfo { FileName = exePath, // These arguments force isolation and a new session Arguments = $"--ProfileDirectory=\"{profileDir}\" --DataDirectory=\"{torDataDir}\" -no-remote", UseShellExecute = true, WindowStyle = ProcessWindowStyle.Normal }; // Start the Tor Browser instance Process.Start(startInfo); } }
Critical Details to Note:
-no-remoteflag: This is non-negotiable—it prevents the second instance from attaching to the first running Tor Browser process, forcing it to start a completely independent session.- Unique directories: Each instance gets its own
ProfileDirectory(stores user data like cookies, history) andDataDirectory(stores Tor circuit configuration and identity state), so their identities stay separate. - Path adjustment: Make sure
torBrowserExepoints to the correct location offirefox.exein your Tor Browser bundle—this varies by installation.
Troubleshooting If You Still See Blank Windows:
- Check folder permissions: Ensure your user account has write access to the profile/data directories we’re creating.
- Update Tor Browser: Older versions might have bugs with multiple instance isolation—grab the latest version from the official site.
- Increase launch delay: If instances are starting too quickly, add a longer
Thread.Sleep()between launches to let the first instance fully initialize.
内容的提问来源于stack exchange,提问作者BadAss

