Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows start up wallpaper program

Status
Not open for further replies.

Jabrant

Programmer
Sep 6, 2001
2
US
I didn;t know where to post this -- but hopefully I will find help. I had an idea of writing a script that I would place in my startup folder in windows. The script would basically randomly choose a file in a cetain folder. This file would then be used as the wallpaper for the desktop. What language should I do this in? And how exactly would I go about starting to implement it? Any help would be greatly appreciated.
 
Hello, Jabrant.

This can be done by a vbs.

[1] You collect all your specially selected wallpaper files (.bmp, .jpg, or else) and put them all in a dedicated folder, say, for instance in the script hereinbelow, I set it as :

c:\windows\web\wallpaper\custom

In that directory, put those picture files and _only_ those picture files, nothing else.

[2] Make sure all your desktop display settings match the requirement of those pictures properly displayed as wallpaper.

[3] Cut and paste the script to a text file named like random_wallpaper.vbs or whatever, and store at some place to your liking.

[4] Make out a shortcut of it and place the shortcut to:
c:\windows\start menu\programs\startup

[5] Upon the _second_ restart thereafter, it would function as required.

Have fun.

regards - tsuji

'------------------------/tsuji/---------
Option Explicit

'--Edit the location wp_path to your liking ---------
Const wp_path = "c:\windows\web\wallpaper\custom"

Const reg_key = "HKCU\Control Panel\Desktop"
Const reg_name = "Wallpaper"

Dim fso, oFolder, oFiles
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(wp_path)
Set oFiles = oFolder.Files

If oFiles.count =0 Then
WScript.Echo "No custom wallpaper is available." & vbCrLf & _
"Operation Wallpaper setting is aborted."
Set oFiles = Nothing
Set oFolder = Nothing
Set fso = Nothing
WScript.Quit(1)
End If

Dim fIndex, fName, i, ic
Randomize : ic = 0
fIndex = Int(oFiles.count * Rnd +1)

For Each i in oFiles
ic = ic +1
If ic = fIndex Then
fName = i.name
Exit For
End If
Next

Dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")
wsh.RegWrite reg_key & "\" & reg_name, wp_path & "\" & fName

Set wsh = Nothing
Set oFiles = Nothing
Set oFolder = Nothing
Set fso = Nothing
WScript.Quit(0)
'------------------------/tsuji/---------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top