"%userProfile%/Local Settings/Application Data/Microsoft/Wallpaper1.bmp"
此为当前桌面背景完整路径。
测试环境:XP SP2
::复制更换桌面背景.bat::
::将bmp格式图片拖入P中
@echo off
title 更换桌面背景
cd/d %~dp0
if /i %~x1==.BMP copy %1 "%userProfile%/Local Settings/Application Data/Microsoft/Wallpaper1.bmp"
echo 正在更换桌面背景
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
goto :eof
::复制更换桌面背景.bat::
::::::::::::::::::::::::
::图片为bmp格式
::拖入bmp格式图片即设置它为背景。
::直接双击运行,若当前目录中有bmp格式图片,则将名称排在最后的一张设为壁纸
@echo off
title 更换墙纸
setlocal enableDelayedExpansion
set pic=%1
if "!pic!"=="" call :search
if "!pic!"=="" set pic="%userProfile%/Local Settings/Application Data/Microsoft/Wallpaper1.bmp"
echo 正在添加注册表项目...
reg add "HKCU/Control Panel/Desktop" /v Wallpaper /d !pic! /f>nul
reg add "HKCU/Control Panel/Desktop" /v WallpaperStyle /d "2" /f>nul
echo 正在更换桌面背景
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
goto :eof
:search
cd/d "%~dp0"
for /f "delims=" %%a in ('dir/b *.bmp') do (
set pic="%~dp0%%a"
)
goto :eof
::一般更换壁纸.bat::
::::::::::::::::::::
::强制更换壁纸.bat::
::有些系统不能成功
::图片为bmp或jpg格式
::如果图片格式为jpg,则桌面图标文字有背景色(成功设置后,运行一遍下面的还原壁纸可去除背景色)
::拖入图片运行
::双击直接运行,名字排后的一张设为背景
::同时可以禁止通过桌面属性来更改壁纸(用软件更改不能禁止)
@echo off
title 更换壁纸
setlocal enableDelayedExpansion
set pic=%1
if "!pic!"=="" call :search
if "!pic!"=="" set pic="%userProfile%/Local Settings/Application Data/Microsoft/Wallpaper1.bmp"
echo 正在添加注册表项目...
reg add "HKCU/Control Panel/Desktop" /v Wallpaper /d !pic! /f>nul
reg add "HKCU/Control Panel/Desktop" /v WallpaperStyle /d "2" /f>nul
reg add "HKCU/Software/Microsoft/Windows/CurrentVersion/Policies/System" /v Wallpaper /d !pic! /f>nul
reg add "HKCU/Software/Microsoft/Windows/CurrentVersion/Policies/System" /v WallpaperStyle /d "2" /f>nul
echo 正在更换桌面背景
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
goto :eof
:search
cd/d "%~dp0"
for /f "delims=" %%a in ('dir/b *.jpg *.bmp') do (
set pic="%~dp0%%a"
)
goto :eof
::强制更换壁纸.bat::
::::::::::::::::::::
::还原壁纸.bat::
::确保有"%userProfile%/Local Settings/Application Data/Microsoft/Wallpaper1.bmp"
@echo off
title 还原壁纸
set pic="%userProfile%/Local Settings/Application Data/Microsoft/Wallpaper1.bmp"
echo 正在添加注册表项目...
reg add "HKCU/Control Panel/Desktop" /v Wallpaper /d %pic% /f>nul
reg add "HKCU/Control Panel/Desktop" /v WallpaperStyle /d "2" /f>nul
reg add "HKCU/Software/Microsoft/Windows/CurrentVersion/Policies/System" /v Wallpaper /d %pic% /f>nul
reg add "HKCU/Software/Microsoft/Windows/CurrentVersion/Policies/System" /v WallpaperStyle /d "2" /f>nul
echo 正在还原桌面背景
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
goto :eof
::还原壁纸.bat::
::::::::::::::::
说明文档
存放桌面背景的几个路径
-------------------------
C:/WINDOWS/Web/Wallpaper
::jpg桌面(还有Bliss.bmp)
C:/WINDOWS
::bmp桌面
[图片收藏]或[我的图片][My Pictures]
::jpg、bmp、gif
-------------------------
其他两个位置
-------------------------
你指定的图片位置
::jpg、bmp、gif
"%userProfile%/Local Settings/Application Data/Microsoft/Wallpaper1.bmp"
::无特殊情况即为当前桌面背景
=========================