Old 24th July 2011, 07:11   #1
anandharaja
Member
 
Join Date: Mar 2009
Posts: 50
Uninstall Files from different location

hi,
i want to create installer for my program, but i install the files in different location for example $PROGRAMFILES\My program1 and some files in $PROGRAMFILES\My program2 and so on. but the installer fail to uninstall files from different location.

if i write uninstaller in my Program1 folder means it uninstall all files in my program1, failes to uninstall files in other locations.

How can i create installer to uninstall all files.
anandharaja is offline   Reply With Quote
Old 24th July 2011, 07:52   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
In the uninstaller the value of $INSTDIR is actually $EXEDIR. So while themost straight-forward way may seem to be just making two uninstallers, you'll run into the same problem when you're trying to execute the second one. :P

So what you need to do is save the exact path that you installed to, either in the uninstaller using FileWriteByte etc, or in the registry or an ini file.
MSG is offline   Reply With Quote
Old 24th July 2011, 10:12   #3
anandharaja
Member
 
Join Date: Mar 2009
Posts: 50
Thanks for the reply,
iam not write these type of installer before, can you provide example script.
Thanks.
anandharaja is offline   Reply With Quote
Old 24th July 2011, 14:00   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
The manual has all the information you'll need. Simply use the INI commands to write the paths to an ini file. Then in un.onInit, read the paths from the INI file and you'll know what paths to delete your files from.

http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2
MSG is offline   Reply With Quote
Old 24th July 2011, 14:33   #5
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
If, during install, you ignore $INSTDIR (the install path selected by user) and instead install to some "fixed" paths, such as "$PROGRAMFILES\My program1" and "$PROGRAMFILES\My program2", then I think the uninstaller should also un-install (remove) files from the "fixed" paths "$PROGRAMFILES\My program1" and "$PROGRAMFILES\My program2". This won't work if the install folders were moved/renamed in the meantime, but in that case storing the original paths in some INI file or in the Registry doesn't help either...

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 24th July 2011, 15:35   #6
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Of course, you should always verify that the path is correct. If for example it has the wrong files, then it's probably not safe to go deleting stuff...
MSG is offline   Reply With Quote
Old 24th July 2011, 16:27   #7
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Quote:
Originally Posted by MSG View Post
Of course, you should always verify that the path is correct. If for example it has the wrong files, then it's probably not safe to go deleting stuff...
Sure. But my point was: He ignored the user-selected $INSTDIR and installed to a fixed path, such as "$PROGRAMFILES\My program1" instead. Of course the path is not "fixed" in the sense that it will be identical on every computer (because of $PROGRAMFILES), but it is fixed for a specific computer. So at un-install time it is safe to uninstall from the same fixed path that we installed to at install time. There is no need to remember a fixed path in an INI file or the Regsitry, because... well... it is fixed.

(Assuming that the suffix "My program1" is unique to his program, of course! Not something commonly used by another product. But if the suffix wasn't unique, then installing to fixed path "$PROGRAMFILES\<suffix>" wouldn't be safe, in the first place)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI

Last edited by LoRd_MuldeR; 24th July 2011 at 18:11.
LoRd_MuldeR is offline   Reply With Quote
Old 30th August 2011, 09:21   #8
anandharaja
Member
 
Join Date: Mar 2009
Posts: 50
Thanks to MSG and LoRd_MuldeR for your replies.
but i still in confusion, where to i use WriteINI Str in Section or i need to create Function.
please can you provide example script with two sections.
anandharaja is offline   Reply With Quote
Old 30th August 2011, 11:51   #9
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
I suggest you create a hidden final section in your installer: Section "-LastSection" LastSection
In that section you use the INI instructions to write the path of 'My program2' to an ini file in the 'my program1' directory. The uninstaller, also created in the 'my program1' directory, can read the ini file using ReadINIStr (you can do this in the Uninstall section, or in the un.onInit function).

I'm not going to write example code here, because it's extremely simple to do and it's a worthwhile exercise for you to figure it out on your own. Look at the INI command examples in the link I provided earlier, they'll show you how to use the commands.
MSG is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump