Preface
Being proud owner of a U3 capable flash drive, I wanted to add some of the tools I use everyday but which were not U3 compatible.
Running a U3 program from the LaunchPad basically does the following things:
- unpack the
.u3p
package (which is a.zip
) to your localApplication Data\U3
directory - run the hostConfigure command from the manifest file (once per session)
- run the appStart command from the manifest file (this starts the application)
Ejecting the U3 drive does the following for all programs which were ran in that session:
- if the program is still running, run the appStop command from the manifest file
- run the hostCleanUp command from the manifest file
Most programs store their settings in a key in the Windows registry. Some others need an .ini
file in their folder. So in both cases it’s relatively easy to move them to another location and run them from there.
After I had successful runs using a batch file for hostConfigure which imported a registry file and another batch file for hostCleanUp which exported the new settings to that file, I wanted to create a tool which automates most steps neccessary for a program to run.
So the U3Helper was born.
The first version got too complicated after a while and so I started from scratch. The result it this tool.
Usage
This manual assumes you already know which registry branches and/or configuration files and/or OCXes/DLLs your application uses.
Manifest file
Make the actions
-section of your manifest.u3i
look like this (the parameters in the appStart
tag are for WebMon, not for the U3Helper):
<actions>
<hostConfigure cmd="%U3_DEVICE_EXEC_PATH%\..\..\0f90f88c-5e05-4cab-8c3a-e1c0112b06fd\Exec\U3Helper.exe">config</hostConfigure>
<appStart workingdir="%U3_APP_DATA_PATH%" cmd="%U3_HOST_EXEC_PATH%\WebMon.exe">-prefs "%U3_APP_DATA_PATH%\WebMon.ini" -pages "%U3_APP_DATA_PATH%\pages\WebPages.dat"</appStart>
<appStop cmd="%U3_HOST_EXEC_PATH%\U3Helper.exe">appstop</appStop>
<hostCleanUp cmd="%U3_HOST_EXEC_PATH%\U3Helper.exe">unconfig</hostCleanUp>
</actions>
0f90f88c-5e05-4cab-8c3a-e1c0112b06fd
is that of the U3Helper, NOT the one of the application of that manifest!If the application writes something to %USERPROFILE%\Application Data
, change the appStart
line to look like this:
<appStart cmd="%U3_HOST_EXEC_PATH%\U3Helper.exe">appstart</appStart>
This way, the U3Helper will change some environment variables for the launched application so that it stores all user-data on the flash drive instead of on the local harddisk.
U3Helper.ini
Now create a file U3Helper.ini
and put it into the host
directory in your U3 package so that it gets extracted to %U3_HOST_EXEC_PATH%
.
Here is a template:
[U3Helper]
AppName=PC OnPoint
AppExe=PConPoint.exe
; enter commandlines to run before stopping the application and before
; ejecting the device. All variables mentioned under [FileDelete] work.
RunBeforeStop=
RunBeforeEject=
; set Unattended to 1 to suppress settings-related questions
; this way, previously existing settings on the host always get
; replaced by the U3's settings and restored on eject
Unattended=0
[RegBackup]
; enter registry branches to be backed up (+deleted) on eject
; and restored on first run
; SHORTCUTS (HKCU, HKLM,...) DON'T WORK!
HKEY_CURRENT_USER\Software\PC OnPoint
[RegDelete]
; enter registry branches to be just deleted without backup
[regsvr32]
; enter filenames to be registered using regsvr32
; these files are assumed to be in %U3_HOST_EXEC_PATH%
CCListBar.ocx
[DataToExecDir]
; enter filenames or foldernames to be copied to the %U3_HOST_EXEC_PATH%
; and copied back to %U3_APP_DATA_PATH% afterwards
; ONLY SIMPLE NAMES, NO PATHS OR WHATSOEVER!
safe.dat
safe.ind
[ParseIniFiles]
; enter filenames of .ini-files to be parsed for env vars on hostConfigure
; and re-replace the paths by envvars on hostCleanUp. The files should reside
; in %U3_APP_DATA_PATH%
test.ini
[FileDelete]
; enter filenames or foldernames to be deleted on eject
; Environment variables working (case sensitive!):
; %ALLUSERSPROFILE%, %APPDATA%, %CommonProgramFiles%, %HOMEPATH%,
; %ProgramFiles%, %SystemRoot%, %TEMP%, %USERPROFILE%, %WINDIR%,
; %U3_APP_DATA_PATH%, %U3_DEVICE_DOCUMENT_PATH%, %U3_DEVICE_EXEC_PATH%
%ALLUSERSPROFILE%\Application Data\Spybot - Search & Destroy
[EnvPath]
; enter folders to be added to the PATH environment variable
; upon running the application. All variables mentioned under
; [FileDelete] get replaced.
%U3_HOST_EXEC_PATH%\lib\gtk\bin
- All registry keys listed under
[RegBackup]
are being backed up on eject of the U3-stick to sequential files (regdata1.reg
,regdata2.reg
and so on) in%U3_APP_DATA_PATH%
and afterwards, the keys are deleted from the host machine. Also those branches are inserted back into the registry upon the first launch of that app after plugging in the stick.- if you put a file
regdataX.reg
into thedata
directory in your U3 package, this file gets imported into the registry after all other files have been processed. But this file never gets overwritten by a newer dump so it’s perfectly to enforce some settings the program changes every time, like relative paths into absolute paths.
- if you put a file
- The section
[RegDelete]
just deletes those keys upon eject. - Under
[regsvr32]
you can list all.ocx
or.dll
files which should be registered before launching the app and unregistered on eject. The files are assumed to be in%U3_HOST_EXEC_PATH%
. - Finally
[DataToExecDir]
lists files which should be copied into the directory containing the application (many applications insist on their config-files lying where the.exe
lies) and back to%U3_APP_DATA_PATH%
on eject.
Download
- u3helper.zip version 2.1, April 2007, incl. sources
- u3helper.u3p version 2.4, June 2008
This sound really good! One question: What happens, if a Registry-Key is already existing, before a u3-Program sets and uses it? Will it be restored, after quitting the program, or will it be deleted?
All registry paths defined under [RegBackup] are checked before they are written. If a path already exists, it is backed up and you will get a message asking whether to use the already found settings or use those from the U3 stick. Upon ejecting the U3 stick, the original registry keys will be restored.