WISE Uninstaller 不会自行删除

发布于 2024-10-12 14:56:55 字数 626 浏览 6 评论 0原文

我知道,我知道...停止使用 WISE。现在这对我来说并不是一个真正的选择。我们有太多的事情要做,无法编写一个全新的安装程序并更改整个构建过程,这是必须要做的。

无论如何,问题是我们的卸载 EXE 在卸载时不会删除自身。它位于安装我们的应用程序的 Program Files 文件夹中。卸载程序完成后,我们希望删除所有文件并删除应用程序文件夹。相反,卸载程序与应用程序文件夹一起保留,因为它在运行时似乎无法自行删除。

这似乎是一个基本任务,因为我的计算机上安装的所有其他程序的卸载程序也位于其 Program Files 文件夹中,并且卸载后它们被删除,但我似乎无法通过 Google 找到其他有相同问题的人。对我来说,该文件无法删除是有道理的,因为它当前已加载到内存中,但是*抱怨声*其他人都这样做......为什么我不能?

编辑:如果有帮助,我正在运行 Wise Installation Studio 7.0 并在 WiseScript 包编辑器中修改卸载脚本。删除 Program Files 文件夹的部分类似于 Delete File(s) %MAINDIR%\*.*,其中 %MAINDIR% 是 Program Files 中的应用文件夹。该命令有两个可用选项(两个选项均打开)——包括子目录和删除包含文件的目录。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴意少年 2024-10-19 14:56:55

所以我最终所做的就是重新创建更好的安装程序所做的事情。我让卸载程序检查它是否从 %TEMP% 目录运行,如果不是,我告诉它将自身复制到临时文件夹并从那里运行。然后,我将临时文件夹中的一个标记为在重新启动时删除,方法是将其添加到注册表项:

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

@altie: 你的解决方案可能也会有效,但我想我更喜欢这个解决方案。它看起来更干净、更坚固。但是非常感谢您提供示例代码...我有时会编写批处理文件,并且不了解循环或“tasklist”命令。这在将来可能会很有用!

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!

梦一生花开无言 2024-10-19 14:56:55

如果你找不到其他方法来做到这一点,这里有一个肮脏的技巧:在安装程序中进行最后一步,启动一个 cmd.exe,等待你的 Wise 进程结束,然后将其删除。

如何在带有任务列表的批处理脚本中执行此操作的示例:

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

我尚未测试此代码或检查其语法错误,但它很接近。命令行中的 for /?tasklist /? 可以帮助您了解如何根据您的需求进行调整。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文