I have Windows 10 laptop connected to two monitors in extended display mode. I would like to only set the second monitor wallpaper to a specific image.
Manual way of doing this would be to navigate: Desktop right click --> Personalization --> Choose the picture --> Right click and set for monitor 2
Is there any way to automate it via a script (bat/powershell) ?
I was able to get below code snippet to work, however it sets the wallpaper to both the displays
function Set-Wallpaper($MyWallpaper){
$code = @'
using System.Runtime.InteropServices;
namespace Win32{
public class Wallpaper{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
public static void SetWallpaper(string thePath){
SystemParametersInfo(20,0,thePath,3);
}
}
}
'@
add-type $code
[Win32.Wallpaper]::SetWallpaper($MyWallpaper)
}
Set-WallPaper("C:\Wallpapers\nature.jpg")