Applications that only use files in their folder are naturally portable, but most of them use registry, files and folders on host computer (local). Prepare portableGet program filesFirst of all you have to extract files from setup with a program such as Universal Extractor and if you can't you have to install. In this case monitor setup with Total Uninstall (doing so you will be able to clean your computer and know what need program). Monitor running and/or setupLaunch Total Uninstall, click Install, Browse to CCleanerPortable\App\CCleaner\CCleaner.exe Prepare launcherIn this case launcher is useless but it can do some settings and move them in Data. [Options] Language=1036 BackupDir=L:\PortableApps\CCleanerPortable\Backups 1036 is the decimal id of french and can be returned by GetUserDefaultLangID of kernel32, we will use it to fix automatically language. Launch appLauncher is a small exe in *Portable folder compiled with NSIS. Download and install NSIS. Minimal launcherCopy-paste the script below in Notepad++ and save as CCleanerPortable.nsi in CCleanerPortable folder. WindowIcon Off SilentInstall Silent AutoCloseWindow True OutFile CCleanerPortable.exe Section ExecWait "$EXEDIR\App\CCleaner\CCleaner.exe" SectionEnd
Code executed must be in Section: Execute CCleaner.exe and wait to quit ($EXEDIR is the path of the launcher) Structured launcherDownload and extract CCleanerPortableSources in your CCleanerPortable folder. Complete launcherOpen in Notepad++ CCleanerPortable_2.nsi. Final launcherOpen in Notepad++ CCleanerPortable_3.nsi. Backup and restore registry keysRegistry plug-inYou will need this NSIS plug-in for registry to compile. Target: Audacity 1.2.6Download audacity-win-1.2.6.zip and unzip in AudacityPortable\App\Audacity REGEDIT4 [HKEY_CURRENT_USER\Software\Audacity\Audacity] "WantAssociateFiles"=dword:00000000 [HKEY_CURRENT_USER\Software\Audacity\Audacity\Directories] "TempDir"="C:\\DOCUME~1\\Admin\\LOCALS~1\\Temp\\AudacityPortableTemp\\" [HKEY_CURRENT_USER\Software\Audacity\Audacity\MP3] "MP3LibPath"="L:\\PortableApps\\AudacityPortable\\App\\LAME\\lame_enc.dll" Only the above registry entries have to be done by launcher (others are user settings that have to be kept in Data). WriteRegDWORD HKEY_CURRENT_USER "Software\Audacity\Audacity" "WantAssociateFiles" 0x0 WriteRegStr HKEY_CURRENT_USER "Software\Audacity\Audacity\Directories" "TempDir" \ "C:\DOCUME~1\Admin\LOCALS~1\Temp\AudacityPortableTemp\" WriteRegStr HKEY_CURRENT_USER "Software\Audacity\Audacity\MP3" "MP3LibPath" \ "L:\PortableApps\AudacityPortable\App\LAME\lame_enc.dll" C:\DOCUME~1\Admin\LOCALS~1\Temp is the system temporary directory: $TEMP BackupLocalKeysHKEY_CURRENT_USER\Software\Audacity is renamed in HKEY_CURRENT_USER\Software\Audacity-BackupByAudacityPortable. RestorePortableKeysSettings saved in Data\Audacity.reg (when closing a previous run of portable) are merged to registry. InitThis function force settings needed to be portable, update paths and overwrite those previously restored. CloseAudacity is closed: delete temp folder. BackupPortableKeysSettings saved in Data\Audacity.reg. RestoreLocalKeysOpposite of backup. Backup and restore foldersTarget: Instant Color PickerDownload icp_setup.exe and extract files with Universal Extractor or Inno Setup Unpacker BackupLocalDirsIn Application Data, Young Smart Software folder is renamed in Young Smart Software--BackupByInstantColorPickerPortable RestorePortableDirsPortable settings in Data\InstantColorPicker are copied in Application Data\Young Smart Software. BackupPortableDirsICP is closed, we do reverse of RestorePortableDirs. RestoreLocalDirsReverse of BackupLocalDirs Backup and restore filesSame way than for folders. Download this template where you will foud actions on registry, folders and files. !define REGKEY1 "HKEY_LOCAL_MACHINE\SOFTWARE\MyProg" !define REGKEY2 "HKEY_CURRENT_USER\Software\MyProg" ;... ${registry::DeleteKey} "${REGKEY1}-BackupBy${APP}Portable" $R0 ${registry::MoveKey} "${REGKEY1}" "${REGKEY1}-BackupBy${APP}Portable" $R0 ${registry::DeleteKey} "${REGKEY2}-BackupBy${APP}Portable" $R0 ${registry::MoveKey} "${REGKEY2}" "${REGKEY2}-BackupBy${APP}Portable" $R0 ;... Deletion of backup not needed in normal use, but if there was a crash not recovered, old backup prevent MoveKey. ComplementsRead NSIS User Manual Chapter 4: Scripting Reference to learn more about Functions, Instructions, Variables, Constants... NSIS ConstantsMany constants ($APPDATA, $SYSDIR...) are defined in NSIS and their values depends of Windows version and localization. |