Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

PowerShell – Remove Windows Wallpaper (Per User)

Posted on November 9, 2015 By David Kittell
Add-Type @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace Wallpaper
{
   public enum Style : int
   {
       Tile, Center, Stretch, NoChange
   }
   public class Setter {
      public const int SetDesktopWallpaper = 20;
      public const int UpdateIniFile = 0x01;
      public const int SendWinIniChange = 0x02;
      [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
      private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni);
      public static void SetWallpaper ( string path, Wallpaper.Style style ) {
         SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange );
         RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
         switch( style )
         {
            case Style.Stretch :
               key.SetValue(@"WallpaperStyle", "2") ; 
               key.SetValue(@"TileWallpaper", "0") ;
               break;
            case Style.Center :
               key.SetValue(@"WallpaperStyle", "1") ; 
               key.SetValue(@"TileWallpaper", "0") ; 
               break;
            case Style.Tile :
               key.SetValue(@"WallpaperStyle", "1") ; 
               key.SetValue(@"TileWallpaper", "1") ;
               break;
            case Style.NoChange :
               break;
         }
         key.Close();
      }
   }
}
"@

[Wallpaper.Setter]::SetWallpaper( '', 0 )

Reference: http://poshcode.org/491

All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code PowerShell

Post navigation

Previous post
Next post

Related Posts

Basic4Android – Compass Direction

Posted on September 15, 2017

Sub GetCompassDirection(bearing As Double) As String Dim tmp As Int ‘ Set Default Direction Dim direction As String : direction = "N" tmp = Floor(Round(bearing / 22.5)) Select Case tmp Case 1 direction = "NNE" Case 2 direction = "NE" Case 3 direction = "ENE" Case 4 direction = "E"…

Read More

Mac OSX Terminal – Xcode Reset

Posted on December 5, 2016December 13, 2016

Make sure Xcode is closed. defaults delete com.apple.dt.Xcode rm -rfv ~/Library/Application\ Support/Developer/Shared/Xcode rm -rfv ~/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState rm -rfv ~/Library/Preferences/com.apple.dt.Xcode.* rm -rfv ~/Library/Preferences/com.apple.dt.xcodebuild.plist rm -rfv ~/Library/MobileDevice/Provisioning\ Profiles/* Originally Posted on December 5, 2016Last Updated on December 13, 2016 All information on this site is shared with the intention to help….

Read More

Create / Delete SQLite Database Indexes

Posted on September 27, 2013December 30, 2015

‘Create Index Sub CreateIndex(SQL As SQL, TableName As String, IndexName As String, Fields As String, Unique As Boolean) Dim query, uni As String uni = "" If Unique=True Then uni = "UNIQUE" query = "CREATE " & uni & " INDEX IF NOT EXISTS " & IndexName & " ON…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes