Usage of %username% in registry?

0

I am trying to make windows run a file through registry and it all works great but when i change the path for the entry, it does not work and nothing happens upon startup. The path that works is this: "C:\Users\tetme\Documents\LoadWOW.exe" but whenever i replace this with the following, nothing happens: "C:\Users\%username%\Documents\LoadWOW.exe" Why is this and what could i do to achieve the username? It works in explorer, cmd etc. but not this?

Thanks!

step

Posted 2016-12-20T14:32:14.867

Reputation: 23

Answers

1

The registry has 2 places where the RUN key is located. Current User and Local Machine.

The current User subkey only applies to your user. When another user logs in, and you open the registry key, you'll find that the run key you set is not there. This is normal.

The Local Machine key is run as SYSTEM user and as such %username% does not point to your a valid username either.

I'm not entirely sure if the registry actually supports environmental variables. It is not the way to achieve this, anyway.

For this to work properly, you need to use a login script which can be done using GPEDIT.msc, User configuration, Windows Settings, Scripts, login.

The script in question can be a .cmd file with %username% in it.

LPChip

Posted 2016-12-20T14:32:14.867

Reputation: 42 190

If you want to use environment variables in the registry, you can do it by creating values of type REG_EXPAND_SZ – Richard – 2016-12-20T21:39:34.797