0

I am trying to Change Desktop wallpaper using Power shell by adding registry

reg add "HKEY_CURRENT_USER\control panel\desktop" /v wallpaper /t REG_SZ /d "" /f
reg add "HKEY_CURRENT_USER\control panel\desktop" /v wallpaper /t REG_SZ /d C:\Users\ov3\Desktop\pic\wall.jpg /f
reg add "HKEY_CURRENT_USER\control panel\desktop" /v WallpaperStyle /t REG_SZ /d 2 /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

after adding these keys wallpaper changed successfully now I want to again change the wallpaper but receiving Yes and No confirmation message

PS C:\Users\ov3> reg add "HKEY_CURRENT_USER\control panel\desktop" /v wallpaper /t REG_SZ /d "" /f
Value wallpaper exists, overwrite(Yes/No)? yes

I am using /f to force overwrite but still receiving this message Value wallpaper exists, overwrite(Yes/No) is there any way to Hide this?

Sadam
  • 107
  • 2
  • 9
  • This works for me: `reg add "HKEY_CURRENT_USER\control panel\desktop" /v wallpaper /t REG_SZ /d '""' /f` (single quotes around double quotes) – zett42 Feb 07 '21 at 11:00
  • A [comment on this GitHub issue](https://github.com/PowerShell/PowerShell/issues/1995#issuecomment-742568351) mentions this specific case, so hopefully it will be fixed in the future. – zett42 Feb 07 '21 at 11:22
  • 1
    btw, the PowerShell way would be `Set-ItemProperty 'hkcu:\control panel\desktop' wallpaper ''` -- no special quoting necessary and even less verbose than the 'reg.exe' call. – zett42 Feb 07 '21 at 12:03
  • can you tell me where z the problem `WshShell.Run("reg add 'HKEY_CURRENT_USER\control panel\desktop\' /v wallpaper /t REG_SZ /d '""' /f",0);` Error: Expected ')' – Sadam Feb 07 '21 at 12:18
  • Enclose the full command in double quotes and not just untill /f. I agree with Zett42 though, this is not the powershell way to do it. See his suggestion with `Set-ItemProperty`. – Abraham Zinala Feb 07 '21 at 13:07

0 Answers0