在 Windows 10 中更改墙纸的脚本? [英] Script to change wallpaper in windows 10?

查看:44
本文介绍了在 Windows 10 中更改墙纸的脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用一个脚本来更改 Windows 10 的默认墙纸,因为我将向所有客户端部署 Win10.当我运行下面的批处理代码时,它不会更改默认墙纸.我看到 img0 文件位于正确的目录 C:\Windows\Web\Wallpaper\Windows 中,但它没有改变背景.下面的代码是我正在使用的.尝试删除 C:\Windows\Web\4K\Wallpaper\Windows\img0_1366x768.jpg 访问被拒绝时,我确实遇到了一些访问被拒绝的错误.

I am trying to get a script to work that will change the default wallpaper for windows 10 because I will be deploying Win10 to all clients. When I run the batch code below, it is not changing the default wall paper. I see that the img0 file is in the correct directory C:\Windows\Web\Wallpaper\Windows but it is not changing the background. The code below is what I am using. I do get some access denied errors when trying to del C:\Windows\Web\4K\Wallpaper\Windows\img0_1366x768.jpg Access is denied.

takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
takeown /f C:\Windows\Web\4K\Wallpaper\Windows\*.*
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant System:(F)
icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant System:(F)
del c:\windows\WEB\wallpaper\Windows\img0.jpg
del /q C:\Windows\Web\4K\Wallpaper\Windows\*.*
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\Web\4K\Wallpaper\Windows

任何想法我做错了什么?TIA

Any ideas what I am doing wrong? TIA

推荐答案

使用 Powershell 更改墙纸.首先,创建一个这样的函数:

Use Powershell to change the wallpaper. First, create a function like this:

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"

这篇关于在 Windows 10 中更改墙纸的脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆