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:

batch Download
HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}

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:

batch Download
REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d ^%systemroot^%

It actually works if we do this:

batch Download
REG ADD HKCR\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D} /v LocalizedString /t REG_EXPAND_SZ /d ^%USERNAME^%

But it fails if we try this:

batch Download
REG ADD HKCR\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D} /v LocalizedString /t REG_EXPAND_SZ /d "^%USERNAME^% on ^%COMPUTERNAME^%"

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:

powershell Download
Set TEXT=@USERNAME@ OP @COMPUTERNAME@
powershell.exe "& {Set-ItemProperty -path 'HKLM:Software\Classes\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}' -name LocalizedString -value ('%TEXT%' -replace '@',[char]0x25)}"

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.