سؤال

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.

هل كانت مفيدة؟

المحلول

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!

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top