如何使用powershell更换墙纸
How to change wall paper by using powershell
有谁知道如何在不注销的情况下使用powershell更换壁纸?
我想在 运行 编写脚本后立即看到更改。
我可以更改注册表
set-ItemProperty -path $reg_pic -Name wallpaper -Value path_to_pic
但我需要注销并重新登录。然后我发现如果我 运行
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
它会在不注销的情况下进行更改,但经过几次测试后,它不再有效...
这样的事情可以帮助:
我用 BMP 和 JPG 文件对其进行了测试,不需要 logoff/logon。
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Params
{
[DllImport("User32.dll",CharSet=CharSet.Unicode)]
public static extern int SystemParametersInfo (Int32 uAction,
Int32 uParam,
String lpvParam,
Int32 fuWinIni);
}
"@
$SPI_SETDESKWALLPAPER = 0x0014
$UpdateIniFile = 0x01
$SendChangeEvent = 0x02
$fWinIni = $UpdateIniFile -bor $SendChangeEvent
$path = "C:\TEMP\MyImage.bmp"
$ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $path, $fWinIni)
有谁知道如何在不注销的情况下使用powershell更换壁纸?
我想在 运行 编写脚本后立即看到更改。
我可以更改注册表
set-ItemProperty -path $reg_pic -Name wallpaper -Value path_to_pic
但我需要注销并重新登录。然后我发现如果我 运行
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
它会在不注销的情况下进行更改,但经过几次测试后,它不再有效...
这样的事情可以帮助:
我用 BMP 和 JPG 文件对其进行了测试,不需要 logoff/logon。
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Params
{
[DllImport("User32.dll",CharSet=CharSet.Unicode)]
public static extern int SystemParametersInfo (Int32 uAction,
Int32 uParam,
String lpvParam,
Int32 fuWinIni);
}
"@
$SPI_SETDESKWALLPAPER = 0x0014
$UpdateIniFile = 0x01
$SendChangeEvent = 0x02
$fWinIni = $UpdateIniFile -bor $SendChangeEvent
$path = "C:\TEMP\MyImage.bmp"
$ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $path, $fWinIni)