I usually change the text below the “This Computer” icon to reflect the current username and servername:

UserOnComputer

This is an ancient trick, just set the the LocalizedString Value of the following key:

to “%USERNAME% on %COMPUTERNAME%”.

It get’s a little more complicated if you want to set this from a script, because the environment variables are replaced with the actual value BEFORE they are entered in the Registry.

So I always did this with a small VBScript but I figured we should be able to do it with a simple oneliner.

I first tried the Reg command because the help describes that you can use the caret sign (^) and even gives an example:

It actually works if we do this:

But it fails if we try this:

My next try was to do it in PowerShell but if using the “& {<command>}” syntax it fails because of the same reason.

So I came up with the following code:

Basically I use an environment var to set a readable string where the % sign is replaced by the @ sign.

And in the PowerShell statement I use the -replace operator to replace the @ with a % again.

I used [char]0x25 (0x25 is the Hex value of the ASCII code for %) because a single % sign is removed in a bat file.

Basically I use an environment var to set a readable string where the % sign is replaced by the @ sign.

And in the PowerShell statement I use the -replace operator to replace the @ with a % again.

I used [char]0x25 (0x25 is the Hex value of the ASCII code for %) because a single % sign is removed in a bat file.