It is currently April 18th, 2024, 8:46 am

Escaping %Environment% variables?

Report bugs with the Rainmeter application and suggest features.
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Escaping %Environment% variables?

Post by Cariboudjan »

Any way to escape an environment variable?

Example:

!WriteKeyValue Variables Vari01 """%*USERNAME*%"""
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Re: Escaping %Environment% variables?

Post by Cariboudjan »

Before Jeff's sarcastic reply,

Use:

Code: Select all

!WriteKeyValue Variables Vari01 "[\x0025]USERNAME[\x0025]"
Thanks jeff.
User avatar
Jeff
Posts: 327
Joined: September 3rd, 2018, 11:18 am

Re: Escaping %Environment% variables?

Post by Jeff »

Welp, it should work like other variables, Rainmeter only uses #, $ and & characters in variables so it shouldn't be a problem.
So let's try [!SetVariable Username "%*USERNAME*%"]
Oh... that didn't work

Ok, you know, Rainmeter may sometime use rainmeter.exe from %AppData% for some stuff, so let's try to escape it like in CMD.
So let's try [!SetVariable Username "^%USERNAME%"]
Oh... that didn't work either... what the hell

You know what? When all hope is lost you have to add some duct tape. Let's try to make the percent signs character variables.
So let's try [!SetVariable Username "[\x0025]USERNAME[\x0025]"]
Hey, that worked! Not the best way to discover escaping enviourment variables but it's something, I think you should add [Suggestion] to the thread name so it's more understandable
Cariboudjan wrote: November 26th, 2021, 11:35 pm Before Jeff's sarcastic reply,
For reference, gave the answer a few mins ago before reply and suggested the forum post