Wednesday, April 27, 2011

BTConvert v7

BTConvert, my currency converter that includes BTC in the available currencies, has reached version 7. This version was made with the help of Andrzej. It now supports many more currencies as you can see:

Specifically it supports:
  • Bitcoin
  • US dollar
  • Euro
  • Pound sterling
  • Australian dollar
  • Linden dollar (that's Second Life's currency)
  • Pecunix
  • Russian ruble
  • Canadian dollar
  • Polish złoty
A detailed changelog can be found inside the source code which is included in the zipfile.

Download BTConvert v7 from here.

Remember there is a forum thread about BTConvert here.

How to create portable applications (also introducing PAL)

It seems that the most popular article on this blog is "How to make portable applications" written back in 2007. Reading it again, I believe it is somewhat outdated and it covers mostly how to reduce the size of an app and not how to make it actually portable (meaning leaving no traces and carrying the registry settings along to other computers).
In this article I will include some more methods to make portable apps and I will also introduce PAL, the Portable Application Launcher: a small program I made to wrap applications and turn them into portable ones. Obviously everything here is for Windows users. Also do not forget that it's almost impossible to make an app portable if it uses its own drivers.

Legal stuff
Do not forget that it might be against the license terms of a program to fiddle with its installation. And keep in mind that redistributing some apps in portable form could be infringing copyrights and thus illegal. Blah blah blah you know this stuff... In order to be safe you either have to respect the law, or to make sure they won't get you...
Method 1: Plain old UPXing and manual file removal
This is the method I described in the older article. It will work with some programs, specifically those that don't use the registry to store settings or any directories like %appdata%. If you want to try this method, then the first thing you should do is install the program you want to make portable using the authors instructions and run/exit it at least once. Don't forget that if you install the 64bit version of an application, it will only work on 64bit Windows.
Now we should see whether your app stores anything in %appdata% (%appdata% is a directory in your hard drive where applications store files like save-games or settings files). My %appdata% is at C:\Users\Tritonio\AppData\Roaming. To see where is yours, press Win+R (Win is the Windows key on your keyboard) to bring up the Run dialog. Then type %appdata% and press enter. A folder should pop up. There you can find subfolders made by different programs that you have installed or ran in the past on your computer. If the program you are trying to make portable has a subfolder here, then you should probably skip this method. Don't forget that the program doesn't necessarily use its name for the subfolder, it could be its company's name for example, so look thoroughly!
After you've made sure that there is no subfolder there you should also take a look in the %localappdata% and %userprofile% folders, just like you did for %appdata%. Fewer applications store data there usually, but you shouldn't risk it, so please check those places thoroughly. Again, if you find a subfolder there, then this method is not for you.
Now you have to make sure that the app doesn't store anything in the registry. Again bring up the Run dialog by pressing Win+R and then type regedit and press enter to open the registry editor. There, navigate to HKEY_CURRENT_USER\Software and then to HKEY_LOCAL_MACHINE\SOFTWARE and look for any subfolder that could belong to the program. If you find one, then your program stores settings in the registry and this method won't work.
Now that you've made sure there are no stray settings you can start packing your application. Go to program files (I guess that's where you installed it) and find the folder that contains it. If you are on a 64bit OS, then you should probably look at c:\Program Files (x86). After you find that directory, copy it somewhere (like a flash drive) and take that copy to a different computer (it could be a virtual machine) with the same OS as you computer.
On the second computer run the main executable. It could complain about dll's missing. If that's the case, then search for them in your first computer (Where could help) and copy them right next to the main executable of the program. You might need to do this many times (bringing the flash drive back and forth) so using Dropbox to sync those files easily would be a good idea.
After the program stop complaining about missing files you are pretty much finished. Now you will just have to compress every executable in it. I suggest you use ArcThemAll for that. Install it, run it, go to settings, UPX tab, select LZMA and click OK. Then drag and drop the whole copied folder on ArcThemAll main window. After it adds all files in the list, select UPX from the bottom left drop-down list, click Extract and then START. This will decompress all executables in case they were already compressed so when it finishes, click Compress and then START again to recompress everything using LZMA (which usually compresses better).
That's it. Your copy should contain a portable version of the app you wanted. If you fell lucky and want to further reduce the size of it, you can start erasing files from the copy. For example many apps keep different language files while you only need one. Still feeling lucky? Why don't you try removing unecessary resources form the executable files using Resource Hacker? You can even replace image resources with lower resolution ones to save a few more KB.  Just remember that Resource Hacker will not work on compressed executables so use ArcThemAll to extract everything first.

Method 2: Portable Application Launcher
If you are reading my blog you might have noticed some portable versions of some apps that I have made. I am using a "homemade" wrapper for them called PAL. I originally made it to pack Angry IP Scanner for personal usage (I haven't published it anywhere, yet) but it should work for many apps that use the registry to store settings or in some folder like %appdata%.
PAL uses an INI file, which you will have to manually edit. A typical file will look like this:
The first line is always the same.
The second line is the main executable of your portable app. This is what PAL will execute. In this case it is called ares.exe and should be in a folder named App next to PAL's executable.
The third line is the registry path where the portable application is storing it's settings. When you exit the portable application, PAL will copy the settings in that registry path to a file called PortableRegistry.dat (placed right next to PAL's executable). When you start the portable app again (by launching PAL of course as it will act as a wrapper for it), PAL will copy the settings in PortableRegistry.dat back to the registry, so that the program won't know that they were even missing.
The fourth line is a path in the filesystem where the portable app stores any kind of files (for example savegames). Just like before PAL will move these files into a folder named \PortableData when you exit the portable app and back to the filesystem when you rerun it.

So just like in the first method, install the program you want to make portable. Then download PAL from here, unzip it somewhere and copy the program's directory from the place it was installed right next to PAL.exe. You may rename that directory to App if you want (just like in the sample INI file above).
Then run and exit it once and start searching as described in the first method for places in the registry or in the filesystem where the installed program might be storing settings. Currently PAL can only handle one registry path and one filesystem path. This is adequate for most apps I've seen. If you app uses, for example, two folders in the filesystem to store settings, PAL will not be able to completely handle that app, meaning it will leave traces or not even work.
After finding where this app stores its settings, open and edit PAL.ini. Edit the Executable= line so that it points to the main executable of your application. The RegistryPath= line should point to the registry path where you application stores its settings. If your app doesn't use the registry just delete this line completelly. The FilesPath= should point to the place in the filesystem where your app stores files or settings. As you can see in the sample INI above, you may use enviroment variables like %appdata% etc. If your app doesn't use a directory in the filesystem to store data, then just delete this line completelly. When you are done editing it, save PAL.ini. You may also rename PAL.exe to whatever you want but do not rename PAL.ini.
Now take that portable version to another computer (again, it can be just a virtual machine) to test it by running PAL.exe.
In case you wondered what happens if you try to run the portable version of an app on a computer that already has that app installed, PAL can handle that just fine. It will first backup the local version settings to appropriate files, copy the portable settings to the registry and/or the filesystem (replacing the local settings), run the program and when the program exits it will save the settings back to the portable files and then bring back the old local settings that it has backed up.
The only thing that PAL might not be able to handle is a shutdown before closing the portable app. In cases like these it might not have time to cleanup the portable settings or bring back the local settings (if any) from the backup. If this happens to you just rerun PAL on the same computer and it will probably fix everything.
Keep in mind that PAL is still in beta so there might be bugs. So if you find any, leave a comment! Oh and since many people asked, you can change PAL's icon either by recompiling it with a different icon (AutoIt3 source code is included in the zipfile) or you could use ResHacker to change the icon.

Method 3: Using ThinApp
First of all ThinApp is proprietary software and is really, I mean REAAAAAAAALY, expensive. Like $5000-expensive... It wasn't made just for making portable apps but I bet more than 80% of the people that use it, have torrented a cracked version and are using it to make portable apps. There is a trial version too which you can get from their site. The general procedure is this:
  1. Get ThinApp. Get VirtualBox.
  2. Install VirtualBox.
  3. Create a new virtual machine and install a copy of Windows on it. Prefer the same version as the one you are running. For more detailed instruction look here.
  4. Install the Guest Additions.
  5. Transfer ThinApp's setup files in the virtual machine. You can use the Shared Folders functionality to tranfer files into the VM and back.
  6. Install ThinApp.
  7. Take a snapshot of the virtual machine.
  8. Transfer the installer of the app you want to make portable to the virtual machine.
  9. Start ThinApp Setup Capture inside the virtual machine (it's somewhere in the start menu).
  10. Following the instructions there, ThinApp will create a snapshot of your OS inside the VM.
  11. When the snapshot is ready, ThinApp will tell you to install the application. Don't worry if the installation requires restarts.
  12. Complete the installation of the app
  13. At this point you may also customize the app if you want. Just run it and change any settings you want.
  14. When the installation is finished open ThinApp's window and click next until you get to screen where it tells you to select the main data container. You should select the main executable of the application. For example if you were making VLC portable you will have to select vlc.exe. All captured data will be packed inside that executable. If you have checked any other applications in the list they will merelly be shortcuts to the main data container. For the inventory name use something containing the name and version of the app.
  15. When you are asked for a Sandbox Location select USB Flash.
  16. When you are asked for compression choose Fast Compression.
  17. Leave other options to their defaults.
  18. Finally build the project by clicking Build Now.
  19. Click Browser Project and navigate to the bin folder where you will find the portable executable(s). Transfer them back to your computer and run them there to test them.
  20. Shutdown the virtual machine.
  21. To make another application portable restore the saved snapshot of the virtual machine (which contained a clean state where only ThinApp was installed on the VM) and continue from step 8.
ThinApp creates very compact portable apps that will leave no traces in the registry or the filesystem. But it will have problems creating portable apps that will work on different versions of Windows. If you only need to run your portable apps in Windows 7, then that's what you should install inside the virtual machine. If you want them to run on XP and 7, then your best bet is to install windows XP inside the virtual machine but it's possible that your application will only run on XP.
Oh and one more thing: Do not compress executables with UPX before packing them with ThinApp, that will break some apps (like 7zip).

Method 4: Using Mojopack
I recently found out Mojopac. It's an app that will allow you to carry around a virtual machine in your flash drive. You can install any application on your flash drive and it will run portably without affecting the host operating system. The major drawback is that it requires XP and doesn't yet support Vista or 7 so I won't write more about it because I currently use Windows 7. In addition to that, Mojopack doesn't actually create portable applications that can be distributed to other users, it just allows you to carry applications in a virtual container, essentially sandboxing them from the host OS.

Method 5: Using Cameyo
I also recently discovered Cameyo. It's a program that works like ThinApp. You'll have to install it on a virtual machine and then it will capture the installation of a program and turn it into a portable executable. It differs from Thinapp in some ways though.
First of all its free of charge!
Secondly you don't necessarily need to setup a virtual machine as they provide an online service (called Cameyo Cloud Packager) where you upload an installer and it automatically creates a virtual image for it. That online service has some limitations though. The installer of the program should be silent or at least have a command line option to make the installation silent. For many installers that option is -silent. Another limitation is that it will only allow you to use the online service for 6 portable apps every month.
Finally Cameyo first creates the portable executable and then you can customize its options while Thinapp required you to decide for all options before building the project to create the portable executables.
When you use the Cameyo Cloud Packager I suggest that you select a 32bit baseline environment and don't use the default which is a 64bit OS.
I tried the online with the setup of Image Analyzer and it recognized that the installer wasn't silent so it prompted me for command line options that would make it silent. I tried -silent and it worked. After some minutes an email arrived at my inbox with a link for the online image. For some reason the image was named image without having any extension at all. I renamed it to image.virtual.exe and ran it. It worked just fine. Then I edited with Cameyo and at the first tab of the package editor I selected Under the executable's directory in the Data storage setting so that the application actually stores the settings next to it. So if can't or don't want to use the online service then you'll have to use a virtual machine just like with Thinapp.
  1. Get Cameyo. Get VirtualBox.
  2. Install VirtualBox.
  3. Create a new virtual machine and install a copy of Windows on it. Prefer the same version as the one you are running. For more detailed instruction look here.
  4. Install the Guest Additions.
  5. Transfer Cameyo in the virtual machine. You can use the Shared Folders functionality to tranfer files into the VM and back.
  6. Take a snapshot of the virtual machine.
  7. Transfer the installer of the application you want to make portable in the virtual machine.
  8. Follow the steps shown in this video:
  9. To make another application portable restore the save snapshot of the virtual machine (which contained a clean state where only Thinapp was installed on the VM) and continue from step 7.
Method 1, the one I had already described in the past, will only work for a few programs. In fact I just rewrote about it because I didn't want this article to include anything less than the older one. Method 2 is something new and I've used it for quite a few apps. For example BOINC Portable and Bitcoin Portable (defunct) both use modified versions of PAL. Method 3, using ThinApp, is the most expensive and I really don't see how someone could follow it without downloading a cracked ThinApp version. Method 4, using Mojopac, will not work on Windows 7 and looks more like a portable virtual machine rather than a way to make portable applications. Method 5, using Cameyo is a probably a very good bet for most applications and their online service will free you from the burden of setting up and running a virtual machine.

Still not satisfied? Take a look at this list in wikipedia.

Got questions? Just leave a comment.

Wednesday, April 13, 2011

Quick note: Why I use Firefox

Although Chrome is a very pretty and fast browser I still preffer Firefox for the following reasons: (obviously I will not try to explain why I don't use IE)
  1. Loading custom spell-checking dictionaries to Firefox allows me to spell-check both Greek and English at the same time, without even switching dictionaries (someone has already made a combined dictionary for that).
  2. There is a master password to protect the passwords in the password manager of Firefox. The Chrome guys for some reason refuse to implement that giving some ridiculous explanation on why they don't want to do it. (I can explain why it's ridiculous if someone disagrees)
    BTW that makes Firefox Portable a great choice in portable browsers.
  3. Firefox can change proxies easily while Chrome depends mostly on the system wide proxy settings (like IE) or some, not so practical, tricks.
  4. TorButton is only for Firefox.
  5. When I am making a webpage, the first browser on which it works as expected is Firefox. I've had some minor problems with Chrome when, for example, I was trying to implement a CSS sticky footer. Chrome would make the page a little bigger than the window thus showing a vertical scrollbar although there was no reason. Maybe it was some mistake I did but I had no problems in Firefox.
    For some reason Firefox, usually, is the one that shows things as I expected them to be rendered, despite Chrome being more standards compliant.
  6. Nothing compares to FireBug when you develop stuff... NOTHING.
  7. Although I still haven't done some serious tests, by my personal experience I find Firefox more responsive, compared to Chrome, when many tabs are open. But, usually, people don't work with 25+ tabs open at the same time like I do, so Chrome will be more responsive for normal usage.
Why not Opera? They stick to the standards more than anyone. These guys are good programmers, I can't deny that. But I really like having open source software when I'm using it to communicate with banks etc. Also some of the points above apply to Opera too.

Hey this note wasn't that quick after all...

Tuesday, April 12, 2011

IP filter for uTorrent

uTorrent and many other torrent clients and P2P programs support IP filters in Emule's ipfilter.dat format. That way you can protect yourself from some dishonest users that try either to spy on what you share, or just over-leech data to make seeders' ratios go up fast and make them leave the swarm thinking they gave what they took. Of course there is a chance that you are blocking honest users from downloading or uploading to you but I hope this isn't that common. There are some IP filter lists on the Internet already but I am combining specific parts of other lists using BlueTack's Blocklist Manager in order to make custom one that doesn't block LAN users etc. I will update the IP filter list every now and then (I don't know if I should post here about it every time it's updated... Should I?).

The IP filter list can always be found here.

Instruction on how to use it with uTorrent are inside the zipfile.

Friday, April 1, 2011

BOINC Portable v2

I just updated BOINC Portable. I consider it out of beta although I didn't change any code in the launcher. So read the REAME.txt and you should be fine. The new versions contains the binaries of BOINC 6.10.60 32bit.

For more information read the previous post about BOINC Portable.

Get the new version from here.

Popular Posts