2

I'm using Inno Setup to make setup package and this is my registry code.

[Registry]
; Add php path to windows variable.
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{drive:c:\}\{#WwwServer}\php\php5.5"; Check: NeedsAddPath(ExpandConstant('{drive:c:\}\{#WwwServer}\php\php5.5')); Flags: preservestringtype;

The NeedsAppPath I got it from here "How do I modify the PATH environment variable when running an Inno Setup Installer?".

This can install and add path correctly, but I don't know how to remove path when uninstall.

This is the path I want to remove from Windows PATH variable.
{drive:c:\}\{#WwwServer}\php\php5.5

How to remove this path from Windows PATH when uninstall?

Community
  • 1
  • 1
vee
  • 4,506
  • 5
  • 44
  • 81
  • I don't think there's a ready made solution for this, so I guess you will need to programatically read the value, remove what you appended and save the value back. Besides, multiple installations of your setup will append multiple paths to the key value. – TLama Nov 05 '14 at 17:17
  • @TLama Sadly. I don't know Pascal. :s – vee Nov 05 '14 at 17:29
  • Possible duplicate of [Inno Setup - Remove path from PATH environment variable while uninstalling a program](http://stackoverflow.com/questions/35410421/inno-setup-remove-path-from-path-environment-variable-while-uninstalling-a-pro) – Martin Prikryl Feb 15 '16 at 14:47

2 Answers2

3

You can simply put one flag and you are ready!

Flag: uninsdeletevalue

This will delete value of the registry when you uninstall your application.

jparthj
  • 1,606
  • 3
  • 20
  • 44
  • 1
    I've tried this but it is not work. the path value was 'added' to the current path, use this flag will remove them all. I just want only added to be remove. – vee Nov 14 '14 at 07:58
  • You can remove the entire key and add the old key back if you have the value when you unistall the applcation. – jparthj Nov 14 '14 at 13:42
  • @Allan you can see the description here http://www.jrsoftware.org/ishelp/index.php?topic=registrysection – jparthj Aug 13 '15 at 05:10
  • PLEASE BE CAREFUL with this flag, I ended up deleting my entire system path. And the key deletion happens only after system reboot. – Sid Sep 02 '23 at 04:55
1

You can simply use Flags: uninsdeletekey in [Registry] section entry to delete the registry key when uninstalling application (it will only delete registry which created by Inno Setup).

For example:

[Registry]
Root: HKLM; SubKey: SOFTWARE\SEGA; Flags: uninsdeletekey

Want to know more, check Registry aren't fully deleting when uninstalling.

Community
  • 1
  • 1
Kushal
  • 605
  • 8
  • 29