可以更简单点。- @echo off&setlocal enabledelayedexpansion
- title 随机更换桌面背景&color 1f
- :: 获取当前目录下bmp文件的总数
- for %%a in (*.bmp) do set /a var+=1&set .!var!=%%a
- :: 提取一个随机数,范围在文件总数之内
- :loop
- set /a w=%random%%%var+1
- set wjm=!.%w%!
-
- Rem ===================操作注册表=====================
- set regadd=reg add "HKEY_CURRENT_USER\Control Panel\Desktop"
- %regadd% /v TileWallpaper /d "0" /f>nul
- %regadd% /v Wallpaper /d "%wjm%" /f>nul
- %regadd% /v WallpaperStyle /d "2" /f>nul
- Rem ====================更新==========================
- RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
-
- ping 127.1 -n 5
- goto loop
复制代码
|