Passing a Variable not as a Variable

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
zero_snowman
Posts: 2
Joined: 17 Feb 2012 11:37

Passing a Variable not as a Variable

#1 Post by zero_snowman » 17 Feb 2012 11:41

Okay, hopefully this is stupid simple for someone. It's been a long time since I've scripted. I have a batch file to change some registry settings around and I'm having trouble with one.

REG ADD "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg /f

So the problem here is the %USERNAME%. When it writes this into the registry it actually pulls the username into the registry.

Example

C:\Users\TestUser\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg

I want the registry entry to say, I just can't figure out how to get the text to just pass as this below. I've tried surrounding it all in quotes, but that didn't help.

C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Passing a Variable not as a Variable

#2 Post by foxidrive » 17 Feb 2012 11:45

try using this:

"C:\Users\%%USERNAME%%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg"

zero_snowman
Posts: 2
Joined: 17 Feb 2012 11:37

Re: Passing a Variable not as a Variable

#3 Post by zero_snowman » 17 Feb 2012 11:58

F*** YEAH!!!! that's what it was!!!!! thank you, and now that I see that I kinda remember that now. God it's been tooooo long. Awesome!

aGerman
Expert
Posts: 4740
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Passing a Variable not as a Variable

#4 Post by aGerman » 17 Feb 2012 14:06

One additional note ...
zero_snowman wrote:/t REG_SZ

... should be REG_EXPAND_SZ in this case.

Regards
aGerman

Post Reply