Bomzinho
Bomzinho

Reputation: 161

How to delete a directory in windows %appdata%(or %programdata%) using NSIS

I am building a setup using NSIS. In my setup, i need to delete a folder (and its contents) in the windows %appdata% (or %programdata% in win7) on uninstallation of my application.

As i am relatively new to NSIS, Kindly Requesting you for a Function or a piece of script that i can use in my setup to execute this operation.

Upvotes: 0

Views: 2940

Answers (1)

Serge Z
Serge Z

Reputation: 425

For local user only:

RMDir /r "$APPDATA\YourApp"
RMDir /r "$LOCALAPPDATA\YourApp"

For all users:

SetShellVarContext all
RMDir /r "$APPDATA\YourApp"
RMDir /r "$LOCALAPPDATA\YourApp"
SetShellVarContext current
  • Option /r - required to delete subfolders.
  • Option /REBOOTOK - required for delayed removal (after system restart).

To delete files only use:

Delete   "$APPDATA\YourApp\*.*"

Upvotes: 8

Related Questions