Uop3n Smart Apps

Tag: making u3 apps

How to make (almost) ANY application U3 Smart

by qwertymodo on May.09, 2009, under Uncategorized

Update: I am now including OliverK’s Guerrilla Field Guide for creating portable applications here instead of linking to it. I have edited it only to remove references to submitting the app for testing at portableapps.com.

Ok, first off, let me just say this. PackageFactory does not, I repeat DOES NOT make applications U3 compliant. Sure, it might kinda seem to work, but just to shed a little light on this “wonder program” that is hyped by every other post I’ve ever seen on making U3 programs (which is actually the whole reason I am writing this now), let me explain what PackageFactory really does.

Based on information that you enter into the program, it generates an xml file known as the U3 manifest. You can do this with the official U3 Manifest Creater found here. This is simply a text file in xml format that contains information about the program.

It then takes all of the files that you drag-and-drop into the program and puts them into a .zip file along with the previously-mentioned manifest file.

THAT’S IT

Now, anyone who’s ever heard of the Windows registry is probably wondering “Hey, what about my settings? Or my personal information? How does that get captured to the U3 drive if that’s all I’ve done to the program?”

The answer, IT DOESN’T.

Now, I am going to show you how to actually make an application U3 compliant, saving all of your settings, data, etc to the U3 drive so that your program is truly portable. Note that, this is “doing it right” so it takes a fair bit of work. If you want a quick and easy solution, realize that you are only going to get results of the same quality as the work you put into it.

Starting out:
You will need to download and install NSIS. This is a compiler for a programming language known as the Nullsoft Scriptable Installer System. Yes, you will be writing code. That’s how it’s done, this isn’t magic. If you want a more robust GUI, you can also install the HM NSIS Editor or, if you are familiar with the Eclipse IDE you can download the NSIS Eclipse plugin.

Now that you have your compiler, here is what you are going to be doing. You are going to write a program launcher executable that acts as if it is “installing” your program onto the host machine, then configuring it with your settings, then launching the actual program. After the program closes, your launcher will back up your settings to your flash drive and clean up the host computer, restoring it back to its original state.

To start off, go into the directory where you are going to be working and create the following 4 directories:

Data
Device
Host
Manifest

Let me explain the purpose of these 4 directories:

Data: This is where your application should store its settings files. If you can control the directory where these settings are stored using your launcher, put them here. This will be the folder represented by the U3_APP_DATA_PATH environment variable.

Device: This folder will end up on the flash drive itself, and is represented by the U3_DEVICE_EXEC_PATH environment variable. Any files placed into this folder will be extracted to the flash drive at installation time. The downside to using this folder is that anything in this folder is essentially on the drive twice, taking up twice the space. The upside is that it doesn’t have to be extracted at runtime, speeding up the process, as well as the fact that these files stay on the flash drive and never get copied to the host machine, which is good for portability.

Host: This folder will be extracted to the host computer’s AppData folder at runtime (and deleted when the drive is ejected). It is represented by the U3_HOST_EXEC_PATH environment variable. Files in this folder are compressed, so they take up less space, but must be extracted to the host computer at runtime.

Manifest: This folder contains two files, manifest.u3i and appicon.ico. Appicon.ico is simply a windows icon file that will represent your program. To extract this icon from the original application, you can use ResHacker (Note: you want the “Icon Group” not just the icon). Manifest.u3i is just a renamed xml file. This can be generated using the official U3 Manifest Creator.

Device vs. Host
Files located in the Device folder will take up twice as much space on the drive. If the application is very small this might be ok, but for most programs this should be avoided. Personally, I put my launcher into the Device folder and all of the application’s files into the Host folder.

Now comes the hard part

Creating A Portable App: A Guerrilla Field Guide
by OliverK (edited to remove content pertaining specifically to portableapps.com)

1. Determine the programing language. Why? Well, you have to be careful. Is it done in:
* .Net? Sorry. While some don’t care, alot of people here despise .Net, as its not installed on all computers. See this link For a whole discussion on the subject of .Net.
* Java? As I understand there’s the Java Portablizer, but there is not yet an Open Source JRE. So use of Java applications is somehow limited.
2. Get the tools. Load up- you’ll need them.
* I whole heartedly suggest the use of HM NIS Edit (Portable) Select either the download with NSIS included, if you don’t intend to download it separately, or without if you do. It adjusts properly in both occasions.
* Note also if you wish to use another editor, you can download a portable version of NSIS separately, from here.
* Regshot. which is used to figure out what changes a program made during the install process.
* Alternately, you can use Process Monitor to figure out what registry entries its reading.
* NirSoft RegfromApp is a small freeware utility that allows you to specify a specific process to monitor. You can even launch a process with it and monitor those specifically. It produces a nicer output of what registry entries the program has modified.
* I also suggest picking up Notepad ++ Portable. Just in case.
* To handle making the icons, use something like IcoFx
3. Download your program. If you have keyboard loggers, malware protection or anything that runs in the background, consider turning them off before taking a regshot. Now, fire up regshot and take a regshot of the computer by scanning the C drive, more on that in a minute, before installation. Go have a cup of coffee or a can of Mountain Dew. Don’t touch the computer! You’ll get extra registry entries.
4. Install your program and run it a couple of times. Make sure you do this from a clean install. If you don’t, you may have skewed results. Do NOTHING else during this time
5. Take second regshot and then compare the results. Save it a html, it produces a nicer printout then .txt
6. Figure out where the program is saving files. Check C:/Documents and Settings/UserName/Application Data for %appdata%. If you scan the entire C:\ Drive with regshot, those changes should show up.
7. What to do with registry entries:
* HKCU:Regshot will show a HCKU modification as HKU\Random Numbers\whatever. Look for those in HKCU\Software\ and handle them in NSIS as HKEY_CURRENT_USER\Software\Whatever.
o Useful Entry: HKU\S-1-5-21-1060284298-823518204-725345543-1003\Software\Texas Instruments\TI Connect\StartUp\.
o Useless: HKU\S-1-5-21-1060284298-823518204-725345543-1003\Software\Microsoft\Windows\ShellNoRoam\MUICache
* HKLM:HKLM is a branch of the registry that cannot be modified by someone with a Limited account- just an Administrator. Handle them by double checking that they are needed. Often, something like InstallDir: whatever can be ignored. Else-if those entries really really are needed, you will need to check that the launcher can do it, then launch the software. If you don’t have the rights, you’ll use a message box to say so and terminate the launcher. Handle them in NSIS as HKEY_LOCAL_MACHINE\Software\whatever
* HKU: You can ignore these.
8. Find a base launcher that deals with those issues.
9. Adjust the launcher to reflect the changes you need made
10. Compile, test, adjust, repeat

*end of the Guerrilla Field Guide

Keep at it!

When making your application portable, keep in mind that the U3 platform provides several environment variables that can be used in your launcher and will make your life much easier. The most useful ones are listed here:

U3_DEVICE_PATH drive letter to device (X:)
U3_DEVICE_DOCUMENT_PATH path to documents folder (X:\Documents)
U3_APP_DATA_PATH data folder path on device (X:\System\Apps\[AppIdString]\Data)
U3_HOST_EXEC_PATH exec folder path on host (%AppDir%\Roaming\U3\[DeviceIDString]\[AppIdString]\Exec)
U3_DEVICE_EXEC_PATH exec folder path on device (X:\System\Apps\[AppIdString]\Exec)
U3_IS_AUTORUN is this an autorun-launch? true/false

Unfortunately, these environment variables are only available when the app is actually run from the U3 Launchpad, so that makes testing difficult. I suggest creating variables within your launcher that during testing are set to paths relative to the launcher itself, then when your launcher is working, change the values out for the environment variables.

Once you have gotten your launcher working, you are ready to create a U3 Package. This is the easy part.

Using your favorite archiving software, such as 7-zip or WinRar, create a new .zip (NOT .7z or .rar or anything else) containing the four folders. (Actually, if any of the folders are empty you can simply delete them, but NOT the manifest folder, it must contain those two files so it should never be empty). Use the default compression settings. Now change the file extension from .zip to .u3p.

If you can’t see the file extension, you need to make file extensions visible. Go to Start>Control Panel>Folder Options then click on the View tab and uncheck the box next to Hide extensions for known file types.

Now you should be able to install your program to your U3 drive. Open the U3 Launchpad and click Add Programs>Install From My Computer, then browse to your new .u3p file and select it. If all is well your app should install and run.

This process is not for the faint of heart. Portablizing an application takes a lot of time, effort, and at least some knowledge of programming. Start small, with a relatively simple application. Don’t sit down and try to make Adobe Photoshop. First off, it’s illegal, second off, it’s way over your head for a first project. Also, because of the first part, asking people to help you with it will not get you received well, so don’t go to the PortableApps.com forums telling them I sent you and you want help portablizing a program that is illegal to do so.

Also, if you are still impatient, check out all of the apps that PortableApps.com has already created. If you want one of their apps on your U3 drive, check out my PortableApps U3 Launcher Wizard.

1 Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Archives

All entries, chronologically...