Skip to content

Better Wallpaper Changer

I just upgraded my favorite image viewer to IrfanView 3.91, and it came to my attention that since 3.90, Irfanview now has a command-line option to set an image as wallpaper. Since Irfanview can tile or resize the image, as well as automatically converting from any format to bitmap … it seems obvious that since you should already have IrfanView installed (seeing as it’s the fastest image viewer out there for Windows), the best choice for setting wallpapers is to use that.

So, here’s a little script to randomly pick a file and have IrfanView set it as wallpaper. Throw the script into your Scheduled tasks, or your startup folder … and you’re all set [;)]

WallpaperFolder = "C:\Documents\Me\Documents\Pictures\art photos"
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.Namespace(WallpaperFolder)
set files = objFolder.Items
randomize
command = """C:\Program Files\IrfanView\i_view32.exe"" """ & files.Item(cint((files.Count - 1) * Rnd)).Path & """ /wall=0 /killmesoftly"
set WshShell = CreateObject("WScript.Shell")
WshShell.Run command, 0, true

Seems like that should do it. Of course, that assumes you have nothing but images in that folder. If you wanted to select only .jpg files from a folder that had other things in it, you could do something like:

WallpaperFolder = "C:\Documents\Me\Documents\Pictures\art photos"
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.Namespace(WallpaperFolder)
set files = objFolder.Items
i = cint((files.Count - 1) * Rnd)
while lcase(right(files.Item(i).name,3)) <> "jpg"
i = cint((files.Count - 1) * rnd)
wend
command = """C:\Program Files\IrfanView\i_view32.exe"" """ & files.Item(i).Path & """ /wall=0 /killmesoftly"
set WshShell = CreateObject("WScript.Shell")
WshShell.Run command, 0, true

As a simple note, you can change the /wall=0 to 1 or 2 if you wish:

  • /wall=0 set it as wallpaper (centered)
  • /wall=1 set it as wallpaper (tiled)
  • /wall=2 set it as wallpaper (stretched)

10 Comments

  1. Comment spamming dirty scoundrel. Go away.

    Saturday, August 7, 2004 at 11:18 pm | Permalink
  2. Andrea wrote:

    Have you tried XNView? (http://www.xnview.com/)
    It’s my favourite viewer/converter :)

    Monday, August 9, 2004 at 9:52 am | Permalink
  3. Yeah … I have that too. Honestly, I can barely tell the difference, in terms of functionality. Irfanview’s got better integration into Windows, so they win me over [:)]

    Tuesday, August 10, 2004 at 5:08 pm | Permalink
  4. Craig Hartel wrote:

    Joel,
    Thanks for the script. FYI, version 3.92 is now out, and so are the 3.92 plugins! :)

    Sunday, August 29, 2004 at 7:15 pm | Permalink
  5. Craig Hartel wrote:

    Oh, I forgot…because I’m not much of a programmer, how would I save this script? Would I save it as, say, wallpaper.cmd or .exe or something?

    Sunday, August 29, 2004 at 7:19 pm | Permalink
  6. Damn cool, thanks :)

    Monday, January 31, 2005 at 11:44 am | Permalink
  7. Jaykul wrote:

    It’s a .vbs script

    Monday, March 7, 2005 at 11:03 am | Permalink
  8. Andy wrote:

    Im trying to view this page in both IE 6 and Firefox 1.5 and the code is full of HTML tags. Anyone else? I would like to use this script as a scheduled task.

    Thanks!

    Tuesday, December 13, 2005 at 7:21 am | Permalink
  9. Jaykul wrote:

    Yep, Sorry. I fixed the post now … Apparently I was having issues with Geshi and Textile again … they don’t get along very well.

    Thursday, December 22, 2005 at 9:55 am | Permalink
  10. aapo wrote:

    I’m unable to get that script working. When I try to run it, I get error messages about illegal characters. It seems that the blog software messes up with the script changing quote chars to different characters and minus sign to dash etc. Since I don’t know anything about vbs formatting, I was unable to parse the line where the actual command is constructed.

    Saturday, May 13, 2006 at 10:54 am | Permalink