Archive: Run script during uninstall


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!


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


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.


read the target path for shortcuts
This plugin might help:

http://nsis.sourceforge.net/wiki/ShellLink_plugin

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...


You will probably need to use ExecShell open "file.vb"

-Stu


Would I put the ExecShell command within the uninstaller section or elsewhere?


Thanks...


Well, yes.

-Stu


ok, I guess that was a stupid question - I'll give it a try and get back if I have problems.

Thanks again....


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....


Exec '"$SYSDIR\wscript.exe" "$INSTDIR\killDesktopIcons.vbs"'

-Stu


Thanks Stu, I'll give that a try.