# Changing desktop background depending on the time of day via script Windows 8.1

Hello it is my first time using this website so I hope I am not asking the question in wrong format.

Anyways, as the title says I have a similar problem to a thread that was answered a while ago that had the answer but would not work for my computer that is running windows 8.1 when I tried to run it to test it out. I am sure I followed the instructions by changing the path to where the image is located and I was wondering what would I have to change to make it work or if the code is perfectly fine and I probably just mess up somewhere.

dim shell
Set shell = WScript.CreateObject("WScript.Shell")
wallpaper = "C:\path\to\wallpaper.jpg"
shell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", wallpaper
shell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True


I have also tried the original code but I end up getting an error saying the system cannot find the file specified on the last line of code.

Any help will be appreciated!

• This line dont have any effect on my Windows 7: shell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True. So script dont work and of course dont update background. This powershell script should works, but i cant and dont want test it since powershell disabled. Here link how activate it. And you can run it with cmd powershell "C:\powershell.ps1" – crazypotato Aug 14 '14 at 8:44

This script emulate right click on picture and press "Set as desktop background". Script usage should be clear SetWallPaper "directory to picture", "filename of picture", "name context menu to run".

'File encoding should be in ANSI
SetWallPaper "C:\icons\", "Potato-icon.png", "Set as desktop &background"

Sub SetWallPaper(WallPaperFolder, WallpaperFile,VerbName)
dim objShell, objFolder, objFolderItem, objVerb, colVerbs
Set objShell = CreateObject("Shell.Application")
set objFolder=objShell.NameSpace(WallPaperFolder)
set objFolderItem=objFolder.ParseName(WallPaperFile)
set colVerbs=objFolderItem.Verbs
for each objVerb in colVerbs
'msgbox objVerb ,0, "Press CTRL+C for copy text" 'uncomment for debug names in contextmenu
if objVerb=VerbName then
'x=msgbox(objVerb ,0, "omg found")
objVerb.DoIt
'Without the sleep command the change never takes effect on Win7.
wscript.sleep(2000)
wscript.quit
end if
next
End Sub


If your Windows have different name for "set as desktop background" when right click on picture:

• You should uncomment line(remove single quote) after for each objVerb in colVerbs
• Then run script and find(ENTER for next message) equal string "Set as desktop &background" for your language then press CTRL+C for save message.
• Open notepad and press CTRL+V so message will be pasted. Copy this name to script.

based on this

If you dont make mistake will works atleast in Windows 7.