LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can LabVIEW "read" Microsoft Windows Environment Variables?

I wrote a function that finds the value of an environment variable.
Do you think there is a better way? Sorry for the mess.

maxnoder1995_0-1732136010705.png

Same as you write in the cmd:
"echo My PC is %COMPUTERNAME% and user is %USERNAME%".

0 Kudos
Message 41 of 44
(99 Views)

@maxnoder1995 wrote:

I wrote a function that finds the value of an environment variable.
Do you think there is a better way? 


Of course there is a better solution, The windows API function ExpandEnvironmentStrings.

 

 

0 Kudos
Message 42 of 44
(87 Views)

Hi Max,

 


@maxnoder1995 wrote:

I wrote a function that finds the value of an environment variable.
Do you think there is a better way? Sorry for the mess.


Unfortunately you forgot to downconvert your VI. (I prefer LV2019, others may be happy with "LV2021 or older".)

 

In your image I don't see anything that reads the value of an environment variable. All you seem to do is to parse/format predefined strings…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 43 of 44
(66 Views)

@maxnoder1995 wrote:

I wrote a function that finds the value of an environment variable.
Do you think there is a better way? Sorry for the mess.

maxnoder1995_0-1732136010705.png

Same as you write in the cmd:
"echo My PC is %COMPUTERNAME% and user is %USERNAME%".


I will have to look at the Windows API way that was mentioned. But the .NET API that I mentioned about 10 years ago in this thread is really the easiest and cleanest way to do it.

0 Kudos
Message 44 of 44
(49 Views)