联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@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
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 '保存转换后的图片
@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
The modifiers can be combined to get compound results: %~dpI - expands %I to a drive letter and path only %~nxI - expands %I to a file name and extension only %~fsI - expands %I to a full path name with short names only %~dp$PATH:I - searches the directories listed in the PATH environment variable for %I and expands to the drive letter and path of the first one found. %~ftzaI - expands %I to a DIR like output line In the above examples %I and PATH can be replaced by other valid values. The %~ syntax is terminated by a valid FOR variable name. Picking upper case variable names like %I makes it more readable and avoids confusion with the modifiers, which are not case sensitive.
@echo off echo %0