
CODE: [Copy to clipboard]2、convert-bmp.vbs@echo off
rem 使用变量延迟扩展的语句
rem setlocal EnableDelayedExpansion
copy nul %~dp0list.txt > nul
for /f "usebackq delims=" %%i in ('dir/a-d/b/s %1') do call set $%%random%%$%%i=$
for /f "tokens=1,2* delims=$=" %%i in ('set $') do echo %%i/%%j >> %~dp0list.txt
for /f "tokens=1,* delims==" %%i in ('set $') do call set %%i=
set /a n=1
rem 使用变量延迟扩展的语句
rem for /f "tokens=1,2* delims=/" %%i in ('sort /R %~dp0list.txt') do if !n! equ 1 ( set bgfile=%%j && set /a n=!n!+1 ) else ( goto end )
for /f "tokens=1,2* delims=/" %%i in ('sort /R %~dp0list.txt') do if %n% equ 1 ( set bgfile=%%j && goto STARTCONVERT )
goto :end
:STARTCONVERT
if not exist %~dp0wallpaper1.bmp goto SETBG
del /f /q %~dp0wallpaper1.bmp
:SETBG
cscript %~dp0convert-bmp.vbs %bgfile% "%~dp0wallpaper1.bmp" > nul
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /d "%~dp0Wallpaper1.bmp" /f > nul
reg add "HKCU\Control Panel\Desktop" /v WallpaperStyle /d "0" /f > nul
reg add "HKCU\Control Panel\Desktop" /v TileWallpaper /d "0" /f > nul
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters > nul
:end
del /f /q %~dp0list.txt
rem 使用变量延迟扩展的语句
rem endlocal
CODE: [Copy to clipboard]使用的时候将两个文件保存在同一个目录,运行setmybg.cmd并提供保存JPG文件的目录作为参数,例如:Dim oImg '图片文件
Dim oIP '图片处理
Set objArgs = WScript.Arguments
sOrgImg = objArgs(0)
sDesImg = objArgs(1)
Set oImg = CreateObject("WIA.ImageFile")
Set oIP = CreateObject("WIA.ImageProcess")
oImg.LoadFile sOrgImg '载入原始图片
oIP.Filters.Add oIP.FilterInfos("Convert").FilterID
oIP.Filters(1).Properties("FormatID").Value = "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" '这里的格式可以自行设定,见附表
'oIP.Filters(1).Properties("Quality").Value = 5 '图片质量
Set oNewImg = oIP.Apply(oImg) '应用
oNewImg.SaveFile sDesImg '保存转换后的图片
CODE: [Copy to clipboard]jpg2bmp下载@echo off
::下面设置墙纸的路径
set WallPaper_Path=F:\My Documents\My Pictures\cartoon\Lucky WallPaper\
setlocal ENABLEDELAYEDEXPANSION
del "%APPDATA%\Microsoft\Wallpaper1.bmp"
for /f %%i in ('dir "%WallPaper_Path%" /b^|find /C ".jpg"') do set file_num=%%i
set /a skip_line=%random%%%%file_num%
for /f "skip=%skip_line% tokens=*" %%i in ('dir "%WallPaper_Path%*.jpg" /b') do jpg2bmp "%WallPaper_Path%%%i" "%APPDATA%\Microsoft\Wallpaper1.bmp" && call :apply
goto :eof
:apply
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /d "%APPDATA%\Microsoft\Wallpaper1.bmp" /f
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
exit
| Quote: | |
|
CODE: [Copy to clipboard]@echo off
echo %0
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |