#3964 closed Feature Request (Works For Me)
Allow EnvGet to support whole strings like _WinAPI_ExpandEnvironmentStrings
| Reported by: | lwc | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | environment | Cc: |
Description
While _WinAPI_ExpandEnvironmentStrings supports whole strings (but requires an include), EnvGet only allows to input a specific environment variable and even then without percents.
I don't presume to retroactively change that, but what about accepting a secondary optional parameter called $full? That is, Func EnvGet($envvariable, $full=False) whereas $full is optional and by default False.
But if $full is True then just do something like (only internally):
If $Full Then
return Execute("'" & StringRegExpReplace($envvariable, "%(\w+)%", "' & EnvGet('$1') & '" ) & "'")
EndIf
This will allow to support commands like ConsoleWrite(EnvGet("My temp variables are %temp% and %tmp%", true)).
Attachments (0)
Change History (7)
comment:1 by , 3 years ago
comment:3 by , 3 years ago
I thing you just need touse the OPt("ExpandEnvStrings", 1)) which allow such expansion
comment:4 by , 3 years ago
| Milestone: | → 3.3.16.1 |
|---|
comment:7 by , 2 years ago
Please don't close like that. In some cases one may want to preserve % in strings and only sometimes convert them. For example, when saving your script's settings you might want to save a parameter called $path as literally %appdata% instead of hardcoding it due to Opt(), so it will fail in another computer.
Why not just supporting the aforementioned $full variable?

Please change to the latest version (currently v3.3.16.1).