Skip to main content
ImageGlass provides command-line tools to set images as your Windows desktop wallpaper or lock screen background.

set-wallpaper

Set an image as the Windows desktop wallpaper with a specified display style.

Syntax

Parameters

string
required
Full path to the image file to set as wallpaperExamples:
  • "C:\Photos\landscape.jpg"
  • "D:\Images\nature.png"
  • "%USERPROFILE%\Pictures\photo.jpg"
enum
required
Wallpaper display styleOptions:
  • Centered (or 0) - Center the image on screen without scaling
  • Stretched (or 1) - Stretch to fill the entire screen
  • Tiled (or 2) - Tile the image across the screen
  • Current (or -1) - Use the current Windows wallpaper style

Exit Codes

Examples

Set Centered Wallpaper

Centers the image on the desktop without stretching or scaling.

Set Stretched Wallpaper

Stretches the image to fill the entire screen.

Set Tiled Wallpaper

Tiles the image repeatedly across the screen (useful for patterns).

Use Current Style

Applies the image using whatever wallpaper style is currently set in Windows.

Using Numeric Style Values

Wallpaper Styles Explained

Centered (0)

  • Image displayed at original size
  • Positioned in the center of the screen
  • No scaling or distortion
  • Background color visible if image is smaller than screen
  • Best for: Icons, logos, or images you want to preserve exactly

Stretched (1)

  • Image scaled to fill entire screen
  • Maintains aspect ratio (may crop sides)
  • No background color visible
  • May distort if aspect ratios don’t match
  • Best for: Photos, wallpapers designed for your screen resolution

Tiled (2)

  • Image repeated across the screen
  • No scaling applied
  • Creates a pattern effect
  • Best for: Small patterns, textures, or repeating designs

Current (-1)

  • Uses the existing Windows wallpaper setting
  • Useful when you want to change the image but keep the same display style
  • Best for: Scripts that rotate wallpapers without changing user preferences

Advanced Usage

Random Wallpaper Script

Wallpaper Rotation Schedule

PowerShell Wallpaper Changer

Error Handling

Check for Invalid Files

Handle Administrator Requirements


set-lock-screen

Set an image as the Windows lock screen background.

Syntax

Parameters

string
required
Full path to the image file to set as lock screen background

Exit Codes

Examples

Basic Usage

With Error Checking

PowerShell Example

Automated Lock Screen Changes

Daily Lock Screen Update

Random Lock Screen

Requirements and Limitations

Windows Permissions

  • May require administrator privileges depending on system configuration
  • Uses Windows Runtime (WinRT) APIs
  • Requires Windows 10 or later

Image Requirements

  • Supported formats: JPG, PNG, BMP, and other standard image formats
  • Recommended resolution: Match or exceed your screen resolution
  • File size: No strict limit, but smaller files load faster

Lock Screen Behavior

  • Immediately applies the new background
  • Overrides Windows Spotlight if enabled
  • Persists until changed again
  • Synchronized across user sessions

Security Considerations

Administrator Privileges

If exit code 1 is returned:

File Access

  • Ensure the image file is accessible to the SYSTEM account
  • Avoid using network paths or removable drives
  • Use local, permanently available paths

Combined Script Example

Set both wallpaper and lock screen:

See Also