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.
try not to copy things from the appdata instead do this
and for registry entries check out the 7-zip launcher
post if you need anything else
Please search before posting. ~Thanks
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
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.
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 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
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
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
Thanks for your help.
Release Team Member
you know u taught me that trick right?
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
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
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
shouldn't the default data copy all the files that you need anyway?
Please search before posting. ~Thanks