Monday, July 12, 2010

How To: Start Vidalia, Privoxy, and uTorrent as Part of a File Association in Windows

Today I set up the Vidalia bundle with uTorrent and looked at making the 3 as automatic as possible.

Problem: Despite the fact that Vidalia is supposed to be able to start Privoxy, I couldn't get the configuration file to load correctly (using command line and setting configuration both failed). Also, I don't start the programs at windows startup, and uTorrent opens automatically from .torrent files, so I would have to start Vidalia seperately myself anyway.

If it sounds like a case of severe laziness, I can explain, in actuality I set this up for someone to whom I didn't feel like explaining the whole tor + privoxy + bittorrent system to, and it's a lot easier to teach "When you want to start a torrent, a bunch of stuff will automatically run for you"

So the answer is batch file + windows file association = multiple programs opening each time a torrent is opened.

Creating the batch file:
To create a batch file in windows, simply create a new text document (Right click on empty part of Desktop > New > Text Document) insert the batch commands I've created, and use Save As to save the file as "yourfilename.bat".

To start out, here is the batch file commands:


tasklist /FI "IMAGENAME eq vidalia.exe" 2>NUL c:\windows\system32\find.exe /I "vidalia.exe">NUL
if NOT "%ERRORLEVEL%"=="0" start /b "vidalia" "C:\Program Files(x86)\Vidalia Bundle\Vidalia\vidalia.exe"
cd "C:\Program Files (x86)\Vidalia Bundle\Privoxy\"
tasklist /FI "IMAGENAME eq privoxy.exe" c:\windows\system32\find.exe /I "privoxy.exe">NUL
if NOT "%ERRORLEVEL%"=="0" start /b "privoxy" "C:\Program Files (x86)\Vidalia Bundle\Privoxy\privoxy.exe"
start /b "utorrent" "C:\Program Files (x86)\uTorrent\uTorrent.exe" %1

The paths:
"C:\Program Files(x86)\Vidalia Bundle\Vidalia\"
"C:\Program Files (x86)\Vidalia Bundle\Privoxy\"
"C:\Program Files (x86)\uTorrent\"
Should be changed to where you currently have each program installed.

Quick reference for people interested in understanding batch file code:
Commands Used:
tasklist
find
start
if
Operators Used:
is a pipe. The way I've used it is that the "find" command will use the output of the "tasklist" command as search data.
2>nul and >nul are used to ignore the output of commands.
%1 is a parameter that has been passed to the batch file. In a file association call, it will be the full path + filename of the file that was opened.

So, at this point you should have the batch file made (or downloaded and changed to have correct file paths). It's time to set up a file association so that the batch file runs when a .torrent file is opened.

On Windows XP:
My Computer > Tools > Folder Options > File Types > Select .torrent in list > Click "Advanced" Button > Change the "Application used to perform action" textbox so that it says (with quotes) "" "%1" replace . Example: "C:\Program Files\Vidalia Bundle\torrentaction.bat" "%1" > press OK

On Windows Vista:
Control Panel > Default Programs > Associate a file type or protocol with a program > Select the .torrent file type > Click "Change program..." Button > Browse... > Find and select your batch file and click "OK"

Alternately you can get to the "Change Program..." step by right clicking on any .torrent file and going to Open As > Choose Default Program...

HOPEFULLY IT WORKS NOW. It works for me, so if you are having problems, check your file paths in the batch file and if you are on xp make sure the "%1" is at the end of your file association. Let me know of any problems / suggestions.

Tuesday, June 1, 2010

Mutant Crobot Inspired


This is a thing I made, much as the blog suggests.