Search code examples
windowsvbscriptcmdwallpaper

How to change wallpaper picture position through command prompt?


I have a VBScript file, that change wallpaper once per hour. The picture position automatically changes to Fill, but I need to set it to Fit. I can change it manually each hour, but it is better make it by command, that I could add to the VBScript.


Solution

  • Got this code from google. See if this helps

    Set oShell = CreateObject("WScript.Shell") 
    Set oFSO = CreateObject("Scripting.FileSystemObject")
     sWinDir = oFSO.GetSpecialFolder(0)
     sWallPaper = "C:\winnt.bmp"
     ' update in registry oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper",sWallPaper 
    
    ' let the system know about the change oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,
    

    The key WallpaperStyle from HKCU\Control Panel\Desktop\Wallpaper has three values: 0 – Center; 1 – Tile; 2 - Stretch Depending on how you want the picture to be displayed, you will choose one of this options.