You are here

Launcher's odd behavior w/ Registry

1 post / 0 new
AntiVirGear
AntiVirGear's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2017-05-08 15:44
Launcher's odd behavior w/ Registry

Hey there Smile

so I'm finally trying to "convert" some games into a portable app, at least creating an environment so people may just copy the game files over, adjust the registry and here we go.

I paste my .INI files below here, there is only ONE .REG file available and it (unfortunately) writes to HKLM only but also somewhere which is mandatory for this specific game... (and some else maybe)

I'm also so sorry for the dirty code, I always clean them up at the end, I hope nobody get hurt by this Sad

So what do I encounter?
I'm running this launcher in DEBUG_ALL because I realized that it doesn't clean-up the registry after launch NOR it does backup any previously written registry but instead overwrites them completely!

When I turned enabled debug, I see that it FIRST loads the registry and THEN makes a backup to HKCU/Software/PortableApps/... and then after closing the Test.exe from the template, it restores them ... those who aren't there because they were overwritten before the backup...

Also what I realized is that my .REG file shrinks down from 7k to 1k size and throws out almost every line except the last one...
While on debug I saw, that after saving any potential changes line by line, it overwrites the only .REG file I'm using over and over therefore the only last line get saved and the other ones discarded...

Are there any solutions for these problems I'm facing with, is my .INI wrong or do I have to create seperate .REG files for every hive/folder I want to write into?

- Pascal

[Launch]
ProgramExecutable=CnCGZH\Command and Conquer Generals\generals.exe
;ProgramExecutable64=AppName\AppName64.exe
;CommandLineArguments=-settings=%PAL:DataDir%\
;WorkingDirectory is the directory that will be used when launching which other items will be relative to. Use should be avoided when possible as it will prevent passing multiple relative file locations via command line
;WorkingDirectory=%PAL:AppDir%\AppName
;DirectoryMoveOK indicates whether a directory can be moved to a different path rather than just supporting drive letter changes
DirectoryMoveOK=yes
;SupportsUNC indicates whether an app can run from a Windows UNC path, often referred to as a network path
SupportsUNC=yes
;RunAsAdmin indicates whether an app requires admin rights to run. This should generally be avoided when possible
RunAsAdmin=try

[Activate]
;Registry indicates whether we will be reading or writing to the registry. If not, setting to false will make the launcher slightly smaller and cause it to start slightly faster.
Registry=true
;Java indicates whether the app needs Java to run
;Java=find
;XML indicates whether the launcher will need to read or write to XML paths within settings files of the app. If not, setting to false will make the launcher slightly smaller and cause it to start slightly faster.
XML=false

[Environment]
;This section lets the launcher know what environment variables need to be set. If not needed, this can be removed.
CnCGZH=%PAL:AppDir%\CnCGZH

[RegistryKeys]
;This section allows you to backup and restore a given key and the keys below it within the registry.  Any existing data in the same location will be backed up before the app is run and restored on exit.  The portable app's data will be stored in a .reg key with the name at the beginning of each line within the Data directory.  It's best to take as little of the registry as possible.  In our example, taking the whole ExamplePublisher section isn't necessary because all our app's data is stored within AppName.  If we took ExamplePublisher, we might run into problems with other apps from the same publisher.
CnCGZH=HKLM\SOFTWARE\EA Games\Command and Conquer Generals Zero Hour
CnCGZH=HKLM\SOFTWARE\Electronic Arts\EA Games\Generals
CnCGZH=HKLM\SOFTWARE\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour
CnCGZH=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{155F4A0E-76ED-45A2-91FB-FF2A2133C31A}
CnCGZH=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F3E9C243-122E-4D6B-ACC1-E1FEC02F6CA1}
;If there is some data in the registry that the app creates but does not need to be saved between sessions of the portable app, it can be handled using a - instead of a name for a .reg file as follows:


[RegistryCleanupIfEmpty]
;This section allows you to remove sections of the registry if they are empty when the app exits. In this example, we're removing the app publisher's section if no local apps from the same publisher exit after our portable app exits so we don't leave behind an empty bit of registry.
;1=HKCU\Software\ExamplePublisher

;ENVIRONMENT VARIABLES FOR USE WITH DIRECTORIES AND FILES
;These next sections deal with directory and file handling.  For these, environment variable substitutions will apply
;Environment variables: http://portableapps.com/manuals/PortableApps.comLauncher/ref/envsub.html#ref-envsub

[DirectoriesMove]
;This section allows you to configure directories that need to be moved from the Data directory to either the app's directory or to the local machine.  Many standard environment variables are supported here including things like APPDATA.

;This first entry will move the contents of AppNamePortable\Data\AppNameConfig to C:\Users\[user]\AppData\Roaming\ExamplePublisher\AppName while the app is running and back when complete.  Any existing data will be backed up and restored.
;AppNameConfig=%APPDATA%\ExamplePublisher\AppName

;This second entry will move the contents of AppNamePortable\Data\AppNamePortableConfig to AppNamePortable\App\AppName while the app is running and back when complete.
;AppNamePortableConfig=%PAL:AppDir%\AppName\Config

;This entry indicates that the contents of C:\Users\[user]\AppData\Roaming\ExamplePublisher\GarbageData should be disposed of when the app is done running.  Any existing data will be backed up and restored when complete.
;-=%APPDATA%\ExamplePublisher\GarbageData

[FilesMove]
;This section allows you to configure directories that need to be moved from the Data directory to either the app's directory or to the local machine.  Many standard environment variables are supported here including things like APPDATA.

;This first entry will move the file AppNamePortable\Data\appnameexample.config to C:\Users\[user]\AppData\Roaming\ExamplePublisher while the app is running and back when complete.  Any existing data will be backed up and restored.
;appnameexample.config=%APPDATA%\ExamplePublisher

;This second entry will move the file of AppNamePortable\Data\appnameportableexample.config to AppNamePortable\App\AppName while the app is running and back when complete.
;appnameportableexample.config=%PAL:AppDir%\AppName

[DirectoriesCleanupIfEmpty]
;This section allows you to remove directories if they are empty when the app exits. In this example, we are removing the ExamplePublisher directory if it is empty so we don't leave a blank directory behind from the app.
;1=%APPDATA%\ExamplePublisher


;FILEWRITE
;These entries allow you to update the paths within configuration and registry files
;The entries use the standard environment variables along with some additional modifiers
;Environment variables: http://portableapps.com/manuals/PortableApps.comLauncher/ref/envsub.html#ref-envsub

;For these examples, we'll update the relative paths in both a standard config file and a .reg file

;FileWrite1 to 3 will update the drive letter, relative path, and full path in a config file
;Note the order from most specific path to least, ensuring we don't change a drive letter alone before a full path
[FileWrite1]
Type=Replace
File=%PAL:DataDir%\settings\CnCGZH.reg
Find=PATH_CNC
Replace=%PAL:AppDir:DoubleBackslash%\\CnCGZH




;Language switching is a bit beyond an example package such as this.  The PortableApps.com Launcher does support automatic language switching with the platform but it is not required for portable apps.
;Details: http://portableapps.com/manuals/PortableApps.comLauncher/ref/launcher.ini/language.html

;[Language]
;Base=%PortableApps.comLanguageCode%
;CheckIfExists=%PAL:AppDir%\Languages\%PAL:LanguageCustom%.locale
;DefaultIfNotExists=en

;[LanguageStrings]
;ar-sa=ar

;[LanguageFile]
;Type=INI
;File=%PAL:DataDir%\settings\appnameportableexample.config
;Section=Language
;Key=Language

;Lastly, we'd need to save our changes to the language setting back to the configuration file

;[FileWrite8]
;Type=INI
;File=%PAL:DataDir%\settings\appnameportableexample.config
;Section=Language
;Key=Language
;Value=%PAL:LanguageCustom%