I created this VBScript to randomize my wallpaper. It also uses subfolders for sequential images. It chooses from one of the files or folders in the specified parent folder at random. If it chooses a file, it waits 10 minutes to change it. If it chooses a folder, it will step through the pictures in order every 5 seconds.
To use it, copy and save the code to a .vbs file and put it in your startup folder if you want it to start automatically.
[Code=VB]
Option Explicit
Dim WshShell, oFolder, intNumber, strValue, i, oFile, strFolder, intFolders, intFiles, serialIndex, sleepTime, serialFolder
strFolder = "C:\Documen ts and Settings\userna me\My Documents\My Pictures\Wallpa pers\"
Set WshShell = WScript.CreateO bject("Wscript. Shell")
Set oFolder = WScript.CreateO bject("Scriptin g.FileSystemObj ect").GetFolder (strFolder)
serialIndex = 0
Do While True
Do While True
If serialIndex > 0 Then
serialIndex = serialIndex + 1
If serialIndex > serialFolder.Fi les.Count Then serialIndex = 0
End If
If serialIndex > 0 Then
i = 0
For Each oFile In serialFolder.Fi les
i = i + 1
If i = serialIndex Then Exit For
Next
Else
intFiles = oFolder.Files.C ount
intFolders = oFolder.Subfold ers.Count
Randomize
intNumber = Int((intFiles + intFolders) * Rnd) + 1
If intNumber > intFiles Then
sleepTime = 5000
serialIndex = 1
i = intFiles
For Each serialFolder In oFolder.Subfold ers
i = i + 1
If i = intNumber Then Exit For
Next
i = 0
For Each oFile In serialFolder.Fi les
i = i + 1
If i = serialIndex Then Exit For
Next
Else
sleepTime = 600000
i = 0
For Each oFile In oFolder.Files
i = i + 1
If i = intNumber Then Exit For
Next
End If
End If
If oFile.Path <> strValue Then
strValue = oFile.Path
Exit Do
End If
Loop
Set oFile = Nothing
WshShell.RegWri te "HKCU\Contr ol Panel\Desktop\W allpaper", strValue
WshShell.Run "%windir%\Syste m32\RUNDLL32.EX E user32.dll, UpdatePerUserSy stemParameters" , 1, False
WScript.Sleep sleepTime
Loop
Set WshShell = Nothing
Set oFolder = Nothing
[/Code]
To use it, copy and save the code to a .vbs file and put it in your startup folder if you want it to start automatically.
[Code=VB]
Option Explicit
Dim WshShell, oFolder, intNumber, strValue, i, oFile, strFolder, intFolders, intFiles, serialIndex, sleepTime, serialFolder
strFolder = "C:\Documen ts and Settings\userna me\My Documents\My Pictures\Wallpa pers\"
Set WshShell = WScript.CreateO bject("Wscript. Shell")
Set oFolder = WScript.CreateO bject("Scriptin g.FileSystemObj ect").GetFolder (strFolder)
serialIndex = 0
Do While True
Do While True
If serialIndex > 0 Then
serialIndex = serialIndex + 1
If serialIndex > serialFolder.Fi les.Count Then serialIndex = 0
End If
If serialIndex > 0 Then
i = 0
For Each oFile In serialFolder.Fi les
i = i + 1
If i = serialIndex Then Exit For
Next
Else
intFiles = oFolder.Files.C ount
intFolders = oFolder.Subfold ers.Count
Randomize
intNumber = Int((intFiles + intFolders) * Rnd) + 1
If intNumber > intFiles Then
sleepTime = 5000
serialIndex = 1
i = intFiles
For Each serialFolder In oFolder.Subfold ers
i = i + 1
If i = intNumber Then Exit For
Next
i = 0
For Each oFile In serialFolder.Fi les
i = i + 1
If i = serialIndex Then Exit For
Next
Else
sleepTime = 600000
i = 0
For Each oFile In oFolder.Files
i = i + 1
If i = intNumber Then Exit For
Next
End If
End If
If oFile.Path <> strValue Then
strValue = oFile.Path
Exit Do
End If
Loop
Set oFile = Nothing
WshShell.RegWri te "HKCU\Contr ol Panel\Desktop\W allpaper", strValue
WshShell.Run "%windir%\Syste m32\RUNDLL32.EX E user32.dll, UpdatePerUserSy stemParameters" , 1, False
WScript.Sleep sleepTime
Loop
Set WshShell = Nothing
Set oFolder = Nothing
[/Code]