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
This has been posted on the forum.
[ Last edited by wxcute on 2008-7-12 at 08:08 PM ]
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 ]
┌───────┐
├→学习→实践→┤
└───────┘
├→学习→实践→┤
└───────┘

