- NSIS Discussion
- Run script during uninstall
Archive: Run script during uninstall
ewallig
15th September 2005 15:49 UTC
Run script during uninstall
Hi,
Using NSIS to package a home-grown app. This app allows users to add different "profiles" after the initial installation. The process of creating the profiles is not NSIS-related (homespun, HTA-based "profile creator" that can be run at any time) and creates a different desktop icon for each profile.
During an uninstall, I need to be able to remove all of the desktop icons that are created by the use of the profile creator but since the icons are not referenced in the uninstaller, the NSIS uninstall process leaves them behind (as expected).
I'd like to run a script during uninstall that searches for and deletes the desktop icons for this app - looking for some guidance on this idea...
Thanks, killer product by the way!
Afrow UK
15th September 2005 18:26 UTC
Use Exec if you already have a script.
You can only delete the shortcuts if they have a fixed prefix or name style. There are no API's that I am aware of that allow you to read the target path for shortcuts.
-Stu
iceman_k
15th September 2005 18:38 UTC
You can probably do it using the System dll.
Here is a MSDN example for working with shortcuts.
If you known in which directory the shortcuts are being created, you can use the FindFirst and FindNext functions to find all files with the .lnk extension. Then you can use the API to check the path of the shortcut target.
pengyou
15th September 2005 23:23 UTC
read the target path for shortcuts
This plugin might help:
http://nsis.sourceforge.net/wiki/ShellLink_plugin
ewallig
16th September 2005 12:36 UTC
Thanks for all of the responses -
I have a simple script to remove the desktop shortcuts (vbs) as they follow a standard naming pattern. I just need an example on how to run the script during an uninstall.
Thanks...
Afrow UK
16th September 2005 14:20 UTC
You will probably need to use ExecShell open "file.vb"
-Stu
ewallig
16th September 2005 14:29 UTC
Would I put the ExecShell command within the uninstaller section or elsewhere?
Thanks...
Afrow UK
16th September 2005 16:18 UTC
Well, yes.
-Stu
ewallig
16th September 2005 16:35 UTC
ok, I guess that was a stupid question - I'll give it a try and get back if I have problems.
Thanks again....
ewallig
16th September 2005 20:02 UTC
Hi again,
Ok, I tried to run the script using ExecShell - didn't have any luck running a .vbs file. I tried both directly running the file:
ExecShell open "$INSTDIR\killDesktopIcons.vbs"
- nothing happens
...and tried calling the scripting host like this...
ExecShell open "$SYSDIR\wscript.exe" "$INSTDIR\killDesktopIcons.vbs"
- nothing happens
...and this..
ExecShell open "$SYSDIR\wscript.exe" """$INSTDIR\killDesktopIcons.vbs"""
- error during compliation.
It's not a real big problem at the moment as I was able to wrap the script in an .exe file (runs fine now) but I may have to run scripts in the future so if you have some insight on this it would be helpful.
Thanks again....
Afrow UK
17th September 2005 10:08 UTC
Exec '"$SYSDIR\wscript.exe" "$INSTDIR\killDesktopIcons.vbs"'
-Stu
ewallig
17th September 2005 19:04 UTC
Thanks Stu, I'll give that a try.