标题: [系统相关] 批处理怎么换将一个文件夹内的壁纸轮流更换? [打印本页]
作者: 魅眸 时间: 2024-1-5 11:36 标题: 批处理怎么换将一个文件夹内的壁纸轮流更换?
请教大神,批处理怎么换将一个文件夹内的壁纸轮流更换
作者: Batcher 时间: 2024-1-6 10:16
回复 1# 魅眸
Win7? Win10? Win11?
作者: czjt1234 时间: 2024-1-7 16:55
本帖最后由 czjt1234 于 2024-1-7 17:02 编辑
vbs- Option Explicit
- Dim oWshShell, oFSO, oShell, WallpaperStyle, TileWallpaper, s, i
-
- Const PATH = "D:\1" '图片文件夹
- Const STYLE = "适应" '适应 居中 平铺 拉伸 填充
-
- Set oWshShell = CreateObject("WScript.Shell")
- Set oFSO = CreateObject("Scripting.FileSystemObject")
- Set oShell = CreateObject("Shell.Application")
- oWshShell.CurrentDirectory = PATH
-
- Select Case STYLE
- Case "适应"
- WallpaperStyle = "6"
- TileWallpaper = "0"
- Case "居中"
- WallpaperStyle = "0"
- TileWallpaper = "0"
- Case "平铺"
- WallpaperStyle = "0"
- TileWallpaper = "1"
- Case "拉伸"
- WallpaperStyle = "2"
- TileWallpaper = "0"
- Case "填充"
- WallpaperStyle = "10"
- TileWallpaper = "0"
- End Select
-
- s = ""
- For Each i In oFSO.GetFolder(oWshShell.CurrentDirectory).Files
- If LCase(Right(i.Name, 4)) = ".jpg" Or LCase(Right(i.Name, 4)) = ".bmp" Then
- s = s & i.Name & "|"
- End If
- Next
- If s = "" Then Wsh.Quit()
- i = Split(Left(s, Len(s) - 1), "|")
- Randomize
- s = i(Int((UBound(i) + 1) * Rnd()))
-
- oWshShell.RegWrite "HKEY_CURRENT_USER\Control Panel\Desktop\WallpaperStyle", WallpaperStyle, "REG_SZ"
- oWshShell.RegWrite "HKEY_CURRENT_USER\Control Panel\Desktop\TileWallpaper", TileWallpaper, "REG_SZ"
- For Each i In oShell.NameSpace(oWshShell.CurrentDirectory).ParseName(s).Verbs
- If i.Name = "设置为桌面背景(&B)" Then i.DoIt() : Wsh.Sleep 2000
- Next
复制代码
这是随机图片设为桌面背景的vbs
如果 PATH = "." 则表示当前文件夹
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |