2

Possible Duplicate:
How do I modify the PATH environment variable when running an Inno Setup Installer?

Currently I use this line in order to add another value to PATH variable during the install:

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: NeedsAddPath('{app}');

My questions are:

1) How to avoid adding that variable if already exists? If a user re-install the software, so the {app} path is concatenated again and again I checked and if I use that way with 'C:\foo'

 [Registry]
    Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: NeedsAddPath('C:\foo');

It works as expected. So how to use a variable instead of a constant string?

2) How to safely remove the {app} value during uninstall?

THANK YOU

Community
  • 1
  • 1
Tamir Gefen
  • 1,128
  • 2
  • 18
  • 35
  • To your first question, try to check the [`deletevalue`](http://www.jrsoftware.org/ishelp/topic_registrysection.htm) flag. That flag ensures the value is deleted before a new one is written. To your second question, do you want to remove from the value data `{olddata};{app}` only the `{app}` part and keep `{olddata}` ? – TLama Sep 20 '12 at 20:42
  • @TLama, yes I do want to keep {olddata}. Thank you – Tamir Gefen Sep 20 '12 at 20:51
  • I've just edited the question. The problem occurs when I try to use a variable with Check: NeedsAddPath Can you advice please? – Tamir Gefen Sep 21 '12 at 10:01
  • 2
    Can you provide the code for `NeedsAddPath` as you say that is incorrectly returning true? Maybe you need an `ExpandConstant()` on `{app}`. – Deanna Sep 21 '12 at 10:23
  • Thank you Deanna! I found this function and now it works fine. – Tamir Gefen Sep 21 '12 at 10:43
  • Well it works good on Windwos 2008 (64bit) but now I see that it doesn't work on Windows 7 (64 bit). Yet it concatenating existing path. What could it be? – Tamir Gefen Sep 21 '12 at 12:47

0 Answers0