NSIS:卸载时删除文件夹

时间:2011-02-16 08:23:14

标签: installer nsis

我想在卸载应用程序时删除Startmenu\XXX文件夹和Program Files\XXX菜单。

尝试RMDir /r,但这对我不起作用。 (Windows 7)

3 个答案:

答案 0 :(得分:5)

RMDir是正确的指令,你的路径可能是错误的。

startmenu删除的一个常见问题是忘记使用RequestExecutionLevel,请参阅this page on the NSIS wiki

Process Monitor可以帮助您检测路径和权限问题......

答案 1 :(得分:3)

这是您的解决方案: 添加“SetShellVarContext all”

http://nsis.sourceforge.net/Shortcuts_removal_fails_on_Windows_Vista

示例代码:

OutFile Win7.exe
Name Win7

Section
  SetShellVarContext all
  CreateDirectory "$SMPROGRAMS\Win7 Testing"
  CreateShortcut  "$SMPROGRAMS\Win7 Testing\win7test.lnk" "$WINDIR\notepad.exe"
  WriteUninstaller "$EXEDIR\uninst.exe"
SectionEnd

Section uninstall
  SetShellVarContext all
  Delete "$SMPROGRAMS\Win7 Testing\win7test.lnk"
  RMDir "$SMPROGRAMS\Win7 Testing"
SectionEnd

-joedf

答案 2 :(得分:3)

有时,Windows仍然不允许您在文件夹仍处于使用状态时将其删除。解决方案是在下次系统重启时将文件夹(和/或文件)标记为删除。为此,请使用标志/ REBOOTOK

对于文件:

Delete /REBOOTOK "<filename>"

对于文件夹

RMDir /R /REBOOTOK directoryname

下次重启后,文件/文件夹将被删除。

另请参阅:http://nsis.sourceforge.net/Reference/RMDir