开发者

NSIS: Deleting a folder upon uninstall

I want to delete the Startmenu\XXX folder and Program Files\XXX menu upon uninstall for the application.

Tried RMDir /r but this does not w开发者_如何学Goork for me. (Windows 7)


RMDir is the correct instruction, your path is probably wrong.

A common issue with startmenu removal is forgetting to use RequestExecutionLevel, see this page on the NSIS wiki

Process Monitor can help you detect path and privilege issues...


Occasionally Windows won't let you remove a folder when it's still in use. The solution is to mark the folder (and/or files) for deletion on next system reboot. For this, use the flag /REBOOTOK

For files:

Delete /REBOOTOK "<filename>"

For folders

RMDir /R /REBOOTOK directoryname

After next reboot, the files/folders will be removed.

See also: http://nsis.sourceforge.net/Reference/RMDir


Here's your solution: add "SetShellVarContext all"

http://nsis.sourceforge.net/Shortcuts_removal_fails_on_Windows_Vista

Example code:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜