LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

setting a system environment variable

Does anyone know of a way to set a system environment variable (e.g. path) from either a CVI application or as part of a distribution kit install?

I'd like to simply add a folder to the Windows search path established by the "path" environment variable.

It's apparent how to set the process' copy of an envirnomental variable from a CVI app.  But I want to set the system's enmvironment.

Thanks.

Menchar
0 Kudos
Message 1 of 6
(5,427 Views)
Hi.

I have attached a simple Visual Basic script which will modify the registry, appending the folder "c:\menchar" to the Path environment variable.

The script is executed by WSH (windows Scripting Host) via the following system command:
cscript AppendPath.vbs

You can invoke the script automatically after your application is installed (see the Advanced Distribution Kit Options).

Regards,
Colin.

Note: I am sure it is possible to have the script check the value of the Path variable before modifying it, but I don't know how. I found the relevant info here.

Message Edited by cdk52 on 08-31-2006 05:12 PM

Message Edited by cdk52 on 08-31-2006 05:15 PM

0 Kudos
Message 2 of 6
(5,412 Views)
Colin -

Thanks for the info, I appreciate it.

I was looking for something built into the distribution kit.  I could launch the script after the install, the distribution kit provides for running an executable at the end.

Non-CVI applications fix up the path as part of their installation - that's what made me think there should be a way to do it as part of the distribution kit.  Even the reworked distribution tool in CVI 8.0 doesn't directly provide for setting environment variables.

I couldn't find a Win32 API function that would set the system environment - just calls to manipulate the process environment.

I did find where the system environment is maintained in the registry, but if I alter that without a reboot then I would think the path wouldn't update.

Thanks again, Colin

Menchar
0 Kudos
Message 3 of 6
(5,382 Views)
Here's some good info on setting environment variables in WindowsXP.
 
 
 
0 Kudos
Message 4 of 6
(5,368 Views)
You're welcome, Menchar.

The new path value takes effect immediately; any command window or other app started after the change inherits the updated environment.

I initially looked to the IniFile instrument for a solution, but it cannot handle values of type REG_EXPAND_SZ.
0 Kudos
Message 5 of 6
(5,361 Views)
The new path value takes effect immediately

...at least on my PC (running WinXP Pro SP2). This differs from what Microsoft says, so don't rely on it.
0 Kudos
Message 6 of 6
(5,344 Views)