Archive: Can I use NSIS for this?


Can I use NSIS for this?
I currently have a .bat file I use for an unistaller that simply unregisters some dlls, deletes some files, removes directories, then calls to an external .reg file to remove registry keys. It works, but it's ugly.

I was wandering around online last night and stumbled upon NSIS. After spending some time in the documentation, examples, and this forum I was beginning to wonder if I could make an executable with NSIS that would perform these 'uninstall' steps.

So I guess my question is:

Can NSIS be used to just perform 'batch' functions like this?

I just want to make sure I am in the ballpark before I begin studying up and trying to drive a nail with a screwdriver.

Thanks!

Z


Yeah, you should be able to do everyting with NSIS, won't need that .reg file either.

Right out of the Help file:

4.9.3.14 UnRegDLL
dllfile
Loads the specified DLL and calls DllUnregisterServer. The error flag is set if an error occurs (i.e. it can't load the DLL, initialize OLE, find the entry point, or the function returned anything other than ERROR_SUCCESS (=0)).


4.9.1.1 Delete
[/REBOOTOK] file
Delete file (which can be a file or wildcard, but should be specified with a full path) from the target system. If /REBOOTOK is specified and the file cannot be deleted then the file is deleted when the system reboots -- if the file will be deleted on a reboot, the reboot flag will be set. The error flag is set if files are found and cannot be deleted. The error flag is not set from trying to delete a file that does not exist.

Delete $INSTDIR\somefile.dat



4.9.1.8 RMDir
[/r] [/REBOOTOK] directory_name
Remove the specified directory (which should be a full path). Without /r, the directory will only be removed if it is completely empty. If /r is specified, the directory will be removed recursively, so all directories and files in the specified directory will be removed. If /REBOOTOK is specified, any file or directory which could not have been removed during the process will be removed on reboot -- if any file or directory will be removed on a reboot, the reboot flag will be set. The error flag is set if any file or directory cannot be removed.

RMDir $INSTDIR
RMDir $INSTDIR\data
RMDir /r /REBOOTOK $INSTIDR
RMDir /REBOOTOK $INSTDIR\DLLs



4.9.2.3 DeleteRegKey
[/ifempty] root_key subkey
Deletes a registry key. If /ifempty is specified, the registry key will only be deleted if it has no subkeys (otherwise, the whole registry tree will be removed). Valid values for root_key are listed under WriteRegStr. The error flag is set if the key could not be removed from the registry (or if it didn't exist to begin with).

DeleteRegKey HKLM "Software\My Company\My Software"
DeleteRegKey /ifempty HKLM "Software\A key that might have subkeys"


I got all of the commands down. I think where I am having a hard time is with the actual uninstaller bit. From what I am reading, you have your installer, then the option to install an Uninstaller along with the install.

Since I am simply executing an Uninstall routine, should I use the calls for the installer, but use all of the commands listed above to remove the components from the machine?

I think what I am asking is:

Should I just make a basic installer, but use commands that delete the necessary files, and then it finishes?

thanks again....this NSIS is something else.

(/me dives back into the books)


After some thinking....

Where would I be able to see the source (.nsi) for the uninstaller that is normally compiled with an installer?

I am sure this would point me in the right direction. I am digging through the forums and manual now to see if I can find what I am looking for, but figured I would drop a hook here as well.

Thanks


The uninstall code would go in:
Section "Uninstall"
...
SectionEnd

Though like you said, you can just make an installer to do the 'uninstall' routine.

-Stu