2

I know, I know...stop using WISE. That's not really an option for me right now. We have too much on our plate to write a completely new installer and change our entire build process, which is what would have to be done.

ANYWAYS, the problem is that our uninstall EXE doesn't delete itself when uninstalling. It is located in the Program Files folder, where our app is installed. After the uninstaller is done, we want all files removed and the app folder deleted. Instead, the uninstaller remains along with the app folder, since it can't seem to remove itself while it is running.

This seems like a rudimentary task, since all the other programs installed on my computer have their uninstallers located in their Program Files folder as well and they are removed after uninstalling, yet I can't seem to find anyone else with the same problem via Google. It makes sense to me that the file can't be deleted since it is currently loaded into memory, but *whining tone* everyone else does it...why can't I?

EDIT: If it helps, I am running Wise Installation Studio 7.0 and modifying the uninstall script in the WiseScript Package Editor. The part that removes the Program Files folder looks like Delete File(s) %MAINDIR%\*.* where %MAINDIR% is the app folder in Program Files. There are two available options for this command (both of which are on)--Include Sub-Directories and Remove Directory Containing Files.

Travesty3
  • 14,351
  • 6
  • 61
  • 98
  • 1
    Interesting...when I run the uninstaller for some of those other programs and look in my task manager at the processes, I sometimes do not see the name of the EXE that I clicked on, but instead I see Au_.exe. If I kill that process, the uninstaller exits. It looks like that EXE is used by NSIS installers. Perhaps running their uninstall.exe just creates that Au_.exe call (which actually does the work) and exits the uninstall.exe process, making it able to be deleted. This is just my theory...anyone able to confirm or deny it? A search for Au_.exe on my computer found nothing. – Travesty3 Jan 18 '11 at 20:19
  • 1
    OK, I found the thread http://forums.winamp.com/showthread.php?postid=2154147 and verified its accuracy. When you run the uninstaller, it creates the file at C:\Users\\AppData\Local\Temp\~nsu.tmp\Au_.exe. It look like this is exactly how many other installers do it. I guess my question now is, is there any good way to do it with Wise? The documentation for Wise is almost non-existent and since, ironically, nobody that actually IS wise would use Wise, there is also not much on Google about it. – Travesty3 Jan 18 '11 at 20:43

2 Answers2

2

So what I ended up doing was recreating what the better installers do. I have the uninstaller check to see if it is running from the %TEMP% directory, and if it isn't I tell it to copy itself to the temp folder and run itself from there. I then mark the one in the temp folder to be deleted on reboot by adding it to the registry key:

HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations

@altie: Your solution probably would have worked as well, but I think I like this solution better. It seems cleaner and more robust. But thank you very much for giving the sample code...I do write batch files on occasion and had no knowledge of looping or the "tasklist" command. This could prove useful in the future!

Travesty3
  • 14,351
  • 6
  • 61
  • 98
  • Exactly what I was hoping for. It took me a long time to figure this kind of thing out. Sometimes you just need a batch file, and no, Powershell won't work... but idioms and example code are SO.HARD. to find. VBScript would probably work here, but oh well. – Aaron Altman Jan 20 '11 at 20:41
1

If you can't find some other way to do it, here's a dirty trick: make the last step in your installer to fire off a cmd.exe that waits for your Wise process to end, then deletes it.

An example of how to do this in a batch script with tasklist:

rem Expand variables delayed with !! syntax for for loop
setlocal EnableExtensions EnableDelayedExpansion

rem Create a loop with a label and goto
:loopstart
for /F "delims= " %%a in ('tasklist /FI "imagename eq wiseuninstaller.exe"') do (
   if not "%%a"=="INFO: No tasks are running which match the specified criteria." (
      set stillrunning=no
   ) else (
      set stillrunning=yes

      rem Add a 5 second delay with ping and throw out the output.
      ping -n 5 > NUL 2>&1
   )
)

if "!stillrunning!"=="yes" goto :loopstart

del wiseuninstaller.exe

I haven't tested this code or checked it much for syntax errors, but it's close. for /? and tasklist /? from the command line can help you figure out how to tweak this to your needs.

Aaron Altman
  • 1,705
  • 1
  • 14
  • 22
  • I will check that out as a last resort, but I would much rather figure out how everyone else seems to do it. Perhaps the problem is that Wise doesn't do it right or something? If it comes down to it, would you be able to provide an example of a command that waits for uninstall.exe to finish, then executes a del command? I'm having trouble finding an example on Google. – Travesty3 Jan 18 '11 at 18:49
  • Thanks for the help! If nobody else has a cleaner solution than running a batch file, I will mark this as my accepted answer. – Travesty3 Jan 18 '11 at 23:54