趁今天有点空,发点实用的P
我知道这个有人发过,全部搜索了一遍,我的还是有不同点的。
我的
能设置jpg图片为背景,前面也有人发过能设jpg图片的,不过要DLL文件支持,而我的不用。
其中好像涉及到系统自动将jpg转化为bmp格式的问题,希望有识之士能研究出来系统怎么个自动转换的原理。
"%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::
::::::::::::::::::::::::
这个在论坛有人发过。
::一般更换墙纸.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桌面
或
::jpg、bmp、gif
-------------------------
其他两个位置
-------------------------
你指定的图片位置
::jpg、bmp、gif
"%userProfile%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp"
::无特殊情况即为当前桌面背景
=========================
Last edited by wxcute on 2008-7-12 at 08:08 PM ]
Take advantage of today's free time, post some practical P
I know this has been posted by someone else, but I have something different.
Mine
can set jpg images as background, someone else has posted before that can set jpg images, but it requires DLL file support, but mine doesn't.
It seems to involve the problem that the system automatically converts jpg to bmp format. I hope those with knowledge can study out how the system automatically converts it.
"%userProfile%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp"
This is the complete path of the current desktop background.
Test environment: XP SP2
::Copy to change desktop background.bat::
::Drag a BMP format image into P
@echo off
title Change desktop background
cd/d %~dp0
if /i %~x1==.BMP copy %1 "%userProfile%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp"
echo Changing desktop background
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
goto :eof
::Copy to change desktop background.bat::
::::::::::::::::::::::::
This has been posted on the forum.
::General change wallpaper.bat::
::The image is in BMP format
::Drag a BMP format image to set it as background.
::Directly double-click to run. If there is a BMP format image in the current directory, it will set the last one as wallpaper
@echo off
title Change wallpaper
setlocal enableDelayedExpansion
set pic=%1
if "!pic!"=="" call :search
if "!pic!"=="" set pic="%userProfile%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp"
echo Adding registry items...
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 Changing desktop background
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
::General change wallpaper.bat::
::::::::::::::::::::::::
::Force change wallpaper.bat::
::Some systems can't succeed
::The image is in BMP or JPG format
::If the image format is JPG, there will be a background color for the desktop icon text (after successfully setting, run the following restore wallpaper once to remove the background color)
::Drag the image to run
::Double-click to run directly, and the last one is set as background
::At the same time, it can prohibit changing wallpaper through desktop properties (software changes cannot be prohibited)
@echo off
title Change wallpaper
setlocal enableDelayedExpansion
set pic=%1
if "!pic!"=="" call :search
if "!pic!"=="" set pic="%userProfile%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp"
echo Adding registry items...
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 Changing desktop background
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
::Force change wallpaper.bat::
::::::::::::::::::::::::
::Restore wallpaper.bat::
::Make sure there is "%userProfile%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp"
@echo off
title Restore wallpaper
set pic="%userProfile%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp"
echo Adding registry items...
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 Restoring desktop background
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
goto :eof
::Restore wallpaper.bat::
::::::::::::::::::::::::::
Explanation document
Several paths to store desktop background
-------------------------
C:\WINDOWS\Web\Wallpaper
::jpg desktop (there is also Bliss.bmp)
C:\WINDOWS
::bmp desktop
or
::jpg, bmp, gif
-------------------------
Other two positions
-------------------------
The location of the image you specified
::jpg, bmp, gif
"%userProfile%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp"
::No special circumstances are the current desktop background
=========================
Last edited by wxcute on 2008-7-12 at 08:08 PM ]