/build/static/layout/Breadcrumb_cap_w.png

MSI - remove Environment value at install

Hi All,
I have an Environment value than needs to be removed at the install of another piece of software, call it an upgrade.
I have not yet been able to find enough information to successfully remove the required Environment Path
my Environment Table looks like this

Environment : NewEnvironment1
Name : !-*C:\ProgramData\Oracle\Java\javapath
Value : [~]
Component : NewComponent1

Has anybody performed an Environment removal before that was not put there by the installing MSI? What have I got wrong?

Thanks
Lee
Edit: I have also tried with the placement set to Replace (blank Value field)
Edit Edit : I just tried to set a Path Variable
Name : NewCustomPathVariable
Defined Value : C:\ProgramData\Oracle\Java\javapath
Current Value :
Type : Environment
and then used the Name field (Path Variable) in Name field (Environment table) - still didn't work

0 Comments   [ + ] Show comments

Answers (6)

Answer Summary:
Posted by: dunnpy 8 years ago
Red Belt
3
I would persevere using the Environment table, it's the in-built method of controlling environment variables and should always be used instead of a custom action.
Any package that came my way for QA would fail if a CA was used instead of an internal mechanism - unless there was a very good reason!

On your first example the value is empty, so nothing will be set.
The basic layout is as follows:

Environment - 'friendly' name for your environment setting

Name - Name of the environment variable being set, with prefixes if required

Value
- The path being set in the variable

See this link and this link for further details and examples.

Hope that helps,

Dunnpy

Comments:
  • Thanks Dunnpy for your response. I had read these links before, but I can't seem to remove a previously VB scripted Environment "Path".
    (I am asking about the command prompt 'path' command)
    The MSI at install has to delete the scripted value.
    To test this, I created an empty MSI as described above with nothing other than the details to remove an Environment, the MSI is 412Kb in size, but the example does not remove, even after a reboot.
    I don't understand how to remove an Environment path when the Value field clears itself.
    The log files says -
    MSI (s) (08:18) [11:38:35:642]: Executing op: UpdateEnvironmentStrings(Name=JavaPath,,Delimiter=[~],Action=536870916,)
    WriteEnvironmentStrings: Name: JavaPath, Value: , Action 536870916

    I think your described 'basic layout' is how I have configured it.
    With your comments about a package failing QA if it had a CA without a good reason, I can understand that. I spoke with a good packager some time ago, and they said "An MSI can do most of what you want - don't use CA's, unless it is asking the installer to make you a coffee"
    Sorry about that Vigneshwaran4264.
    However, if I can't get this working using the Environment table, I will have to use a CA.
    Thanks - Tempril 8 years ago
Posted by: Badger 8 years ago
Red Belt
2

Top Answer

Okey dokey..

PfM is the answer. It works!!

I have just made an MSI with the chosen modes required. I logged into a test machine, I modified the PATH to include :
    "C:\ProgramData\Oracle\Java\javapath;".

I also added another folder after that, THEN I rebooted, checked the PATH statement, it was 'wrong'.

I then installed my MSI which was set to remove "C:\ProgramData\Oracle\Java\javapath;" from the path statement when installed...

then I rebooted again... (Path statement in the System context)

the MSI had nicely removed exactly the text I wanted.

Here is what the table entries looked like.

 

Hope it helps


Comments:
  • Thanks Badger, that worked. With the Value field being deleted in the GUI of IS and trial of Advanced Installer, and with not been able to find enough information about how to do this, I had thought the Value field stayed blank.

    Thanks all for your contributions.

    Now I will experiment with how else to use this, if I have to use the [~], or if I can [~];VALUE;[~] to remove the environment if something else has been put in front. - Tempril 8 years ago
    • Get a copy of the MSI,chm file learn about the tables. there are two settings to do with the [~]. They relate to append, and prepend.
      Append = [~]value,
      means it will add the value AFTER the existing information.
      Prepend = value[~]
      this means it will write the value BEFORE the existing information.
      Have fun.
      Oh, remember, don't fix bad things in MSI, make sure they are right to start with. Test, test test - Badger 8 years ago
      • Thanks Badger. I have been packaging for a while (you might have seen some of my posts here on ITN) but recently been engaging myself more with MSI's learning as much as I can.
        I should have thrown some more path strings in front of my original test VM to get "c:\anotherapplication;C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;etc..." and get my MSI to remove the javapath. That is why I was going to test a few changes to the setup. Turns out the example you posted originally worked even with another application path in front. - Tempril 8 years ago
      • if you download the sdk you will have the msi.chm. that is awesome. if you go through the exercise on it, it really goes into all of the tables and will show you how it all comes together. - Badger 8 years ago
Posted by: anonymous_9363 8 years ago
Red Belt
1

>Does it matter how it got there in the first place?
Consider this scenario. Here's the PATH:

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Oracle

The unwanted part of the PATH is "C:\ProgramData\Oracle\Java\javapath;".

How can the environment table be used to remove just that part which, as I understand it, is what the OP wants to do?

Posted by: apptopack 8 years ago
Red Belt
0
Why not create a custom action to remove this during Install (via script) using NOT Installed condition?
Posted by: Badger 8 years ago
Red Belt
0

I answered this lastnight, but it didn't save...

Environment : NewEnvironment1
Name : !-*PATH
Value : [~]C:\ProgramData\Oracle\Java\javapath
Component : NewComponent1

Name = the name of the Env Variable, you mentioned Path, (be careful with this, glad to hear you are testing). If you ran a verbose log on your install, you should have seen that in your eg, it found no env var called "C:\ProgramData\Oracle\Java\javapath".

the above bit i have modified should:
remove at install and uninstall, the system variable PATH.
by appending the C:\ProgramData\Oracle\Java\javapath info.

This should leave your PATH statement intact but remove the text you don't want.

Posted by: anonymous_9363 8 years ago
Red Belt
0

Maybe I'm reading this wrong but to me the OP is asking how to remove an entry from the PATH that was added by a Custom Action not by the Environment table. He says:

 I can't seem to remove a previously VB scripted Environment "Path".

To me, the only way to do that would be to either use the table to set the PATH again from scratch - sub-optimal, obviously - or use another CA to parse the PATH and remove the erroneous entry if present.


Comments:
  • Does it matter how it got there in the first place? The Environment table should be able to manipulate the variable information however it got there, shouldn't it? - dunnpy 8 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ