# How to change desktop background of a specific user in a batch file [duplicate]

Possible Duplicate:
Schedule Windows XP wallpaper change without additional apps I think this is not a duplicate because I asked how to change the background of a different user not the current one logged on. I already know how to do that. Please vote to reopen my question.

I was wondering how to change the desktop background of a specific user. I understand that you have to look into HKEY_USERS but I don't know where to go from there. I need to do this in a batch file too. This is for windows xp.

-

## marked as duplicate by Sathya♦May 30 '12 at 12:02

Thanks :) That does help too :) and I don't think my question is a duplicate... It has a difference in that I want to change the background of a user that is not currently logged on. Just saying :) –  Nicholas May 30 '12 at 12:06
I agree, this isn't an exact duplicate. I've voted to re-open the question. –  Indrek May 30 '12 at 12:18

This can be done with PowerShell:

$user = Get-WMIObject -Query "select * from Win32_UserAccount where Name='<username>'"$path = 'Registry::HKEY_USERS\' + $user.SID + '\Control Panel\Desktop\' Set-ItemProperty -path$path -name Wallpaper -value 'C:\path\to\wallpaper.jpg'
rundll32.exe user32.dll UpdatePerUserSystemParameters


Explanation:

• The first line gets the given user's information using WMI. Specifically, you need the SID that identifies this user under the HKEY_USERS registry hive. For more information, see Get-WMIObject, Win32_UserAccount class and Querying with WQL.
• The second line simply builds the path to the correct registry key.
• The third line sets the value of the given entry under the given registry key. See Set-ItemProperty for more information.
• The fourth line forces a refresh of the wallpaper. This is only needed if the specified user is logged in and you need the change to take effect immediately.
-
Cheers man :) just what I needed! –  Nicholas May 30 '12 at 12:04