在 windows 10 中更改壁纸的脚本?
Script to change wallpaper in windows 10?
我正在尝试让一个脚本工作,该脚本将更改 windows 10 的默认墙纸,因为我将向所有客户端部署 Win10。当我运行下面的批处理代码时,它并没有改变默认墙纸。我看到 img0 文件位于正确的目录 C:\Windows\Web\Wallpaper\Windows 中,但它没有更改背景。下面的代码是我正在使用的。尝试 del C:\Windows\WebK\Wallpaper\Windows\img0_1366x768.jpg Access is denied.
时,我确实遇到了一些访问被拒绝的错误
takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
takeown /f C:\Windows\WebK\Wallpaper\Windows\*.*
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant System:(F)
icacls C:\Windows\WebK\Wallpaper\Windows\*.* /Grant System:(F)
del c:\windows\WEB\wallpaper\Windows\img0.jpg
del /q C:\Windows\WebK\Wallpaper\Windows\*.*
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\WebK\Wallpaper\Windows
知道我做错了什么吗? TIA
使用 Powershell 更换壁纸。首先,创建一个这样的函数:
Function Set-WallPaper($Value)
{
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
rundll32.exe user32.dll, UpdatePerUserSystemParameters
}
现在调用函数:
Set-WallPaper -value "path to wallpaper"
我知道这已经得到解答,但如果有人想在批处理文件中执行此操作,icacls 行需要使用 /reset 而不是 /grant ... 类似于:
takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /reset
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\WebK\Wallpaper\Windows
应该可以工作(只要它是由管理帐户运行)。
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys("^ ")
WshShell.SendKeys("+{F10}")
WshShell.SendKeys("N")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{ENTER}")
我正在尝试让一个脚本工作,该脚本将更改 windows 10 的默认墙纸,因为我将向所有客户端部署 Win10。当我运行下面的批处理代码时,它并没有改变默认墙纸。我看到 img0 文件位于正确的目录 C:\Windows\Web\Wallpaper\Windows 中,但它没有更改背景。下面的代码是我正在使用的。尝试 del C:\Windows\WebK\Wallpaper\Windows\img0_1366x768.jpg Access is denied.
时,我确实遇到了一些访问被拒绝的错误takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
takeown /f C:\Windows\WebK\Wallpaper\Windows\*.*
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant System:(F)
icacls C:\Windows\WebK\Wallpaper\Windows\*.* /Grant System:(F)
del c:\windows\WEB\wallpaper\Windows\img0.jpg
del /q C:\Windows\WebK\Wallpaper\Windows\*.*
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\WebK\Wallpaper\Windows
知道我做错了什么吗? TIA
使用 Powershell 更换壁纸。首先,创建一个这样的函数:
Function Set-WallPaper($Value)
{
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
rundll32.exe user32.dll, UpdatePerUserSystemParameters
}
现在调用函数:
Set-WallPaper -value "path to wallpaper"
我知道这已经得到解答,但如果有人想在批处理文件中执行此操作,icacls 行需要使用 /reset 而不是 /grant ... 类似于:
takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /reset
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\WebK\Wallpaper\Windows
应该可以工作(只要它是由管理帐户运行)。
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys("^ ")
WshShell.SendKeys("+{F10}")
WshShell.SendKeys("N")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{DOWN}")
WshShell.SendKeys("{ENTER}")