You are here

Some help with NSIS please.

12 posts / 0 new
Last post
Jacob Mastel
Offline
Last seen: 1 week 2 days ago
Developer
Joined: 2007-06-13 19:36
Some help with NSIS please.

I've been working on a launcher for a program called stickies. Yes I know it's not open source, but I use it a lot and it's legal so I'm just making a launcher for myself. Anyways I was wondering how you check the system to see if a program is installed. In the cleanup section of my program I have it move files from the App data folder if they're accidentally put there, then delete them. Well if stickies is installed I don't want to do that I just want to make new ones. Can anybody help me? And if you want I can email you the launcher.

powerjuce
powerjuce's picture
Offline
Last seen: 13 years 9 months ago
Developer
Joined: 2007-09-20 21:34
try not to copy things from

try not to copy things from the appdata instead do this

StrCpy $SETTINGSDIRECTORY "$EXEDIR\Data"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("APPDATA", "$SETTINGSDIRECTORY").r0'

and for registry entries check out the 7-zip launcher

post if you need anything else

Please search before posting. ~Thanks

Jacob Mastel
Offline
Last seen: 1 week 2 days ago
Developer
Joined: 2007-06-13 19:36
The reason I've copied from App Data is

because if the files are missing out of the Data folder then it makes them in the AppData folder. Or reads the onese that are there. And what would I do with the settings directory thing?

Release Team Member

Patrick Patience
Offline
Last seen: 4 years 11 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Try It

Just try popping in the code he posted before the launch, it may re-direct the settings to the settings directory if you're lucky.

rab040ma
Offline
Last seen: 5 months 5 days ago
Joined: 2007-08-27 13:35
If you know what directory

If you know what directory stickies is likely to write to, you can check for the existence of that directory. It doesn't matter whether the program is currently installed. As a general rule if the folder exists already, after the portable app is finished running, the folder should be back the way it was before is started running.

If powerjuce's trick works, and you can tame stickies into thinking that $EXEDIR\Data is the user's %appdata% directory, that may get rid of the problem completely. But some programs look in the registry (e.g. HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders) to find appdata, and ignore the environment variable.

Otherwise, if you've tried everything and stickies insists on writing to that directory used by the installed version, you have to check some combinations. For example,

  • if the installed version is running, can you run the portable version without messing up or even changing the installed version's settings? If not, you should probably check to make sure the installed version is not running before you launch the portable version.
  • Can your launcher rename the installed version's appdata directory to something else before you launch stickies, wait around while stickies is working, and rename it back again when you are finished? If the installed version is launched while the portable version is running, does it create a train wreck? What happens if the power fails while the installed version's appdata folder is renamed to something else?

If there is a simple (as in KISS) way to keep the application from writing to appdata or the registry, that is far better than renaming, moving, remembering, or putting things back.

MC

Jacob Mastel
Offline
Last seen: 1 week 2 days ago
Developer
Joined: 2007-06-13 19:36
It doesn't look into the registry as far as I can tell

How do you do powerjuice's trick into making it think that the Data folder is AppData? That should be the easiest way to do it.

Release Team Member

rab040ma
Offline
Last seen: 5 months 5 days ago
Joined: 2007-08-27 13:35
Did you try adding those two

Did you try adding those two lines to your program, somewhere before where anything uses APPDATA or you launch the app?

About the only thing that would make that complicated is if the $SETTINGSDIRECTORY is not defined with VAR before that, but that is usually the case.

Again, it's not guaranteed. Some programs ignore the environment variable. You need to experiment to see if it works -- both to see if powerjuce's trick changes the environment inherited by the app you are launching, and if having that environment makes it stop putting a folder in the "real" APPDATA.

MC

Jacob Mastel
Offline
Last seen: 1 week 2 days ago
Developer
Joined: 2007-06-13 19:36
Alright I will try that.

Thanks for your help.

Release Team Member

powerjuce
powerjuce's picture
Offline
Last seen: 13 years 9 months ago
Developer
Joined: 2007-09-20 21:34
lol

you know u taught me that trick right? Blum
and did not add the define the variable part of the code because it was at the beginning of my program and i did not feel like copying it.

Please search before posting. ~Thanks

Jacob Mastel
Offline
Last seen: 1 week 2 days ago
Developer
Joined: 2007-06-13 19:36
That didn't work

It still writes to the AppData folder if it doesn't find it's files in the Data folder.

Edit
I know there is a way to check if a file exists and then if it does do something else. But is there a way to check if a file exists and then do something if it doesn't?

Release Team Member

rab040ma
Offline
Last seen: 5 months 5 days ago
Joined: 2007-08-27 13:35
When you use IfFileExists,

When you use IfFileExists, you there are two labels you can use. The first is for if the file exists, and the second is if the file doesn't. You can put "" for the "exists" option, and it will just go on to the next line.

MC

powerjuce
powerjuce's picture
Offline
Last seen: 13 years 9 months ago
Developer
Joined: 2007-09-20 21:34
default data

shouldn't the default data copy all the files that you need anyway?

Please search before posting. ~Thanks

Log in or register to post comments