如何使用批处理更改墙纸 [英] How to change wallpaper using batch
问题描述
我需要制作一个批处理文件,将墙纸更改为与蝙蝠文件位于同一位置的图片,
I need to make a batch file that changes the wallpaper to a picture that is in the same location as the bat file I currently have this code:
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /f /t REG_SZ /d c:\images\wallpaper.bmp
问题是它的图片需要放在文件夹c:\ images \中,而我需要将它放在与bat文件相同的位置.有谁知道我该怎么做.
the problem with this is that it the pictures need to be in the folder c:\images\ and I need it to be in the same place as the bat file. does any one know how I could do it.
推荐答案
您可以使用%~dp0wallpaper.bmp
%~dp0
返回正在执行的批处理文件的完整路径,并以反斜杠结尾.
%~dp0
returns the full path of the batch file that is being executed with a backslash at end.
在批处理文件目录包含空格的情况下,您可能希望将文件名括在双引号中:"%~dp0wallpaper.bmp"
You probably might want to enclose the filename in double quotes in case the batch file's directory contains spaces: "%~dp0wallpaper.bmp"
这篇关于如何使用批处理更改墙纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!