Hi
I’m deploying a package via SCCM, which basically checks to see if it’s been X number of days since the last reboot. If that’s true, I need to set a custom wallpaper with a warning. That wallpaper should then revert to our original after e reboot (scheduled task).
But the script bit where the wallpaper and refresh part takes place, does not apply when deploynig the package via SCCM. It works if I execute the code in Powershell ISE, though. So is it something to do with in which context it’s run?
The snippet of code that doesn’t apply is:
param($path)
if(!$path)
{
$path = “c:<path to jpg locally on pc>”
}
$setwallpapersrc = @"
using System.Runtime.InteropServices;
public class wallpaper
{
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 )
{
SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange );
}
}
"@
Add-Type -TypeDefinition $setwallpapersrc
[wallpaper]::SetWallpaper($path)