You are here

FileWrite not working in launcher

15 posts / 0 new
Last post
Gamemaster77
Offline
Last seen: 11 years 9 months ago
Joined: 2013-02-13 00:31
FileWrite not working in launcher

For the Portable App I'm making, I need to write a registry key that has the directory of the app. So, I tried using FileWrite to change the .reg file before its added; however, nothing seems to be happening. To test it, I made a file in \Data\Settings called test.txt with D:\CivilizationIIIPortable as what's in it. I then set the last drive to D. In my launcher, I have:

[FileWrite3]
type=Replace
File=%PAL:DataDrive%\Settings\test.txt
find=%PAL:LastDrive%
replace:%PAL:Drive%

So, after running it from the G: drive, it's not updated. What could I be doing wrong here?

Ken Herbert
Ken Herbert's picture
Online
Last seen: 7 min 19 sec ago
DeveloperModerator
Joined: 2010-05-25 18:19
Environment variables

%PAL:DataDrive% is not a real env var. You want %PAL:DataDir%.

Gamemaster77
Offline
Last seen: 11 years 9 months ago
Joined: 2013-02-13 00:31
Thanks. I fixed that but it

Thanks. I fixed that but it still doesn't seem to be working. Now the launcher just says:

[FileWrite3]
Type=Replace
File=%PAL:DataDir%\Settings\test.txt
Find=replace
Replace:replaced

and text.txt just contains the word replace. When I run the launcher it does not change.

Ken Herbert
Ken Herbert's picture
Online
Last seen: 7 min 19 sec ago
DeveloperModerator
Joined: 2010-05-25 18:19
Also your Replace should be

Also your Replace should be an equals sign, not a colon, so you should have:
[FileWrite3]
Type=Replace
File=%PAL:DataDir%\Settings\test.txt
Find=replace
Replace=replaced

Also make sure you are not doubling up or skipping numbers in your [FileWriteX]

Gamemaster77
Offline
Last seen: 11 years 9 months ago
Joined: 2013-02-13 00:31
Okay, now it's being really

Okay, now it's being really weird. Here is my launcher.ini:
[Launch]
ProgramExecutable=CivilizationIII\Civilization3.exe
RunAsAdmin=force
WorkingDirectory=%PAL:AppDir%\CivilizationIII
SinglePortableAppInstance=true
SplashTime=5000
LaunchAppAfterSplash=true
WaitForOtherInstances=true
SupportsUNC=yes

[Activate]
Registry=true

[FileWrite1]
Type=Replace
File=%PAL:DataDir%\Settings\test.txt
Find=replace
Replace=replaced

[RegistryKeys]
Infogrames=HKLM\Software\Infogrames
Infogrames Interactive=HKLM\Software\Infogrames Interactive

[RegistryCleanupForce]
1=HKCU\Software\Infogrames
1=HKCU\Software\Infogrames Interactive

For some reason, with the ini file configured like that, the launcher refuses to launch the exe at all. Yet, when I get rid of the filewrite1 section, it launches fine. I'm still trying to figure this out.

John T. Haller
John T. Haller's picture
Offline
Last seen: 1 hour 26 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Infinite Replace

I think you just configured it to do an infinite replace, since what you're finding is a part of the replace string. If you want an example, set Find=FindThisString and Replace=ReplaceThisString

Sometimes, the impossible can become possible, if you're awesome!

Gamemaster77
Offline
Last seen: 11 years 9 months ago
Joined: 2013-02-13 00:31
Just tried that and it still

Just tried that and it still won't open when the filewrite is in there. If I look in task manager the launcher exe shows up for a few seconds and then disappears, before even opening the exe it is supposed to. Could it be a problem with the launcher itself? Maybe try it with a new one?

tapsklaps
Offline
Last seen: 6 years 1 month ago
Developer
Joined: 2010-10-17 08:11
two different hives

In the section [RegistryKeys] you have used the hive HKLM, while you have used in the section [RegistryCleanupForce] the hive HKCU. That seems to be somehow contradictory. Which of the both hives is now correct?

Gamemaster77
Offline
Last seen: 11 years 9 months ago
Joined: 2013-02-13 00:31
Just got from help from

Just got from help from AluisioASG, thanks for that. In the meantime, I've actually got the file writing to work. For some reason, the launcher was just having trouble changing my text.txt file. But when I changed it to work on the actual .reg file with the right encoding, it worked. Not sure why the text file didn't work, but I don't need that so I'm good. Now I just need to move on to some file moving. Wish me luck.

Ken Herbert
Ken Herbert's picture
Online
Last seen: 7 min 19 sec ago
DeveloperModerator
Joined: 2010-05-25 18:19
Glad to hear you got it

Glad to hear you got it working.

On a side note, where you are using [RegistryCleanupForce] above, you should instead use [RegistryCleanupIfEmpty].

This will prevent you from screwing up a local install of that game, or any others that use HKCU\Software\Infogrames or HKCU\Software\Infogrames Interactive.

Also, the number preceding your actual entry should be incremented, so you should have
1=HKCU\Software\Infogrames
2=HKCU\Software\Infogrames Interactive

where you have 1= and 1=.

tapsklaps
Offline
Last seen: 6 years 1 month ago
Developer
Joined: 2010-10-17 08:11
incorrect argumentation

Your argument of using sequential numbers is incorrect in this case. This will only be used if it is a single more complex registry key. But here you have two different registry keys.

For a better understanding let me construct the following situation:

HKCU\Software\Infogrames\settings1
HKCU\Software\Infogrames Interactive\settings2

Suppose that after saving of settings1 and settings2 both "Infogrames" and "Infogrames Interactive" will be left empty. Then of course is the following code necessary, where the key names are not consecutive integers:

1=HKCU\Software\Infogrames
1=HKCU\Software\Infogrames Interactive
Ken Herbert
Ken Herbert's picture
Online
Last seen: 7 min 19 sec ago
DeveloperModerator
Joined: 2010-05-25 18:19
Before you jump to

Before you jump to conclusions please read the documentation on what you are commenting on:

From the documentation for both [RegistryCleanupIfEmpty] and [RegistryCleanupForce] (in fact, the very first line of both)

Key names are consecutive integers, starting at 1 (i.e. 1, 2, 3, etc.)

Whether it works with non-sequential numbers or not, the documentation written by the people who coded the Launcher states consecutive numbers should be used.

tapsklaps
Offline
Last seen: 6 years 1 month ago
Developer
Joined: 2010-10-17 08:11
Once again

I've already read through this documentation, and probably a little more accurate than you. You have recommended to use the section [RegistryCleanupIfEmpty] instead of the section [RegistryCleanupForce]. That's correct so far.

In connection with the use of the section [RegistryCleanupIfEmpty] you have then proposed to use sequential numbers. And exactly this suggestion from you in this case is definitely wrong. For a correct usage of the section [RegistryCleanupIfEmpty] please read through the documentation.

EDIT: Or does your recommendation refer to the non sequential numbers in the code of the section [RegistryCleanupForce], which has been written by the member of Gamemaster77 himself? Then your proposal would be applicable.

Ken Herbert
Ken Herbert's picture
Online
Last seen: 7 min 19 sec ago
DeveloperModerator
Joined: 2010-05-25 18:19
Yes, I am talking about his

Yes, I am talking about his [RegistryCleanupForce] section, and also the [RegistryCleanupIfEmpty] section he should be using instead.

What you link to also adds nothing to your argument for using the same numbers for [RegistryCleanupIfEmpty] - it only states that order is important if cleaning up more than one member of the same path, nowhere there does it indicate you should use the same number for different paths.

The link I posted above however indicates numbers should be incremental (and says nothing of doing it one way for multiple entries in the same path, or another for entries on different paths).

And apologies for any potential aggression in anything I have said here - a bad day of family issues plus lack of sleep has put me on edge, and I'm notorious for talking/typing before I think in these situations.

tapsklaps
Offline
Last seen: 6 years 1 month ago
Developer
Joined: 2010-10-17 08:11
Deleting of more than one empty registry key

Again I've thought about the usage of the section [RegistryCleanupIfEmpty]. And probably is it in every case necessary, where still left more than one empty registry key, that I must use for the key names consecutive integers. Accordingly it isn't important, if it's just a registry key with several subkeys or whether these are completely different registry keys. Apparently only the exact choice of the consecutive numbers is in certain cases significant, how it is described in the example case in the documentation.

Log in or register to post comments