S
Scott McNair
Hi,
I'm trying to set an environment variable programmatically. I've added
these three lines to my code:
System.Environment.SetEnvironmentVariable("TCS", "C:\Program Files\TCS\")
InstallPath = System.Environment.GetEnvironmentVariable("TCS")
MsgBox(InstallPath)
And, as expected, the MsgBox contains "C:\Program Files\TCS\".
However the variable seems to exist only for that instance of the app. For
example, if I open a cmd window while the app is running and type "echo %
TCS%", it just returns "%TCS%". If I exit the app, remark out the first
line, and then re-run the app, the MsgBox returns an empty box.
I'm guessing that any environment variables you set using
System.Environment.SetEnvironmentVariable are volatile; that is, they don't
exist outside that currently running application.
How can I set it programmatically, and have it STAY there?
Regards,
Scott
I'm trying to set an environment variable programmatically. I've added
these three lines to my code:
System.Environment.SetEnvironmentVariable("TCS", "C:\Program Files\TCS\")
InstallPath = System.Environment.GetEnvironmentVariable("TCS")
MsgBox(InstallPath)
And, as expected, the MsgBox contains "C:\Program Files\TCS\".
However the variable seems to exist only for that instance of the app. For
example, if I open a cmd window while the app is running and type "echo %
TCS%", it just returns "%TCS%". If I exit the app, remark out the first
line, and then re-run the app, the MsgBox returns an empty box.
I'm guessing that any environment variables you set using
System.Environment.SetEnvironmentVariable are volatile; that is, they don't
exist outside that currently running application.
How can I set it programmatically, and have it STAY there?
Regards,
Scott