I'd like to have a different desktop background depending on which network I'm attached to (home, work, roaming, etc.).

Does anyone know of a way to accomplish this with Windows Vista?

  • Why Community Wiki?
    – frusDev
    Commented Aug 6, 2009 at 10:31
  • Figured as the question was short, it might be better to leave it open to be extended if the community wanted to. Commented Aug 6, 2009 at 11:15

4 Answers 4


You don't specify your OS, so I'm assuming Windows.

I have a script, knocked together in VBSctipt, that runs regularly (via Windows' built-in scheduled task feature) and changes my wallpaper to a random selection depending on time of day (so it picks one from the "morning" set between 0700 and 1000 and so on). Once it has decided the image to use, the following lines update the wallpaper:

Set oShell = WScript.CreateObject("Wscript.Shell")
oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sImage
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, False

You could create something similar that bases its choice purely on the IP range you appear to be on. You could detect your current public address by making a HTTP call to something like http://whatismyipaddress.com/ using the WinHTTP library (though if you use a public service like this, make sure you don't do the lookup too often). As an alternative to detecting your public IP address, you could try scan the output of ipconfig or detech other properties of the network (can I see my porn archive network drive? if so I must be at home) and so on.

You might get more help on this over on StackOverflow.
I don't know of any pre-written utilities that do this. There are no doubt some out there somehwere, but writing your own script may be quicker than searching for a pre-written one that works the way you want.

  • Sorry .. the tag said 'Vista' .. I should have put it in the body Commented Aug 6, 2009 at 11:12
  • My bad for not paying attention to the tags, sorry. The script I threw together has only been used on Win2K and XP machines - the technique should work on Vista but I've never tested it there. Commented Aug 6, 2009 at 11:19
  • I forgot to say: I'm happy to share my script if you want it as a starting point, though I don't think it would really save you much time/effort. Commented Aug 6, 2009 at 13:10

Check out this SU thread. That might work for you.

  • That might be even easier ;-)
    – Ivo Flipse
    Commented Aug 6, 2009 at 9:11

You could create a script that checks your IP address and then changes your background.

Too bad my scripting experience is so low, I would have no idea how to write this.

Here's a VBscript to find your IP Address:

'GetIPaddr.vbs - Check the IP address you are currently
'connected to the Internet with (or LAN IP).
'© Bill James - [email protected]
' rev 15 Jan 2002
'   Now works with Windows NT, 2K, XP

Option Explicit
Dim IP_Address : IP_Address = GetIP()

If IP_Address = "" OR IP_Address = "" Then
  MsgBox "No IP Address found."
  InputBox vbcrlf & "Current IP Address is " &  IP_Address & _
           vbcrlf & vbcrlf & vbcrlf & vbcrlf & _
           "(Use Ctrl + C to copy IP Address to Clipboard)", _
           "GetIPaddr.vbs © Bill James", IP_Address
End If

Function GetIP()
  Dim ws : Set ws = CreateObject("WScript.Shell")
  Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
  Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
  Dim ThisLine, IP
  If ws.Environment("SYSTEM")("OS") = "" Then
    ws.run "winipcfg /batch " & TmpFile, 0, True
    ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
  End If
  With fso.GetFile(TmpFile).OpenAsTextStream
    Do While NOT .AtEndOfStream
      ThisLine = .ReadLine
      If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
  End With
  'WinXP (NT? 2K?) leaves a carriage return at the end of line
  If IP <> "" Then
    If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
  End If
  GetIP = IP
  Set fso = Nothing
  Set ws = Nothing
End Function

Now I need a smart programmer to add something to make it change your background, when the IP has a certain range/value.

  • 1
    -1 , this answer essentially restates the problem with "and you could automate this with a shell" , 0 value add. Commented Aug 6, 2009 at 8:12
  • Fair enough, though I haven't given up searching ;-)
    – Ivo Flipse
    Commented Aug 6, 2009 at 8:14
  • But hey! It's community wiki anyway!
    – Ivo Flipse
    Commented Aug 6, 2009 at 8:18
  • Thats a lot of effort to find an IP address
    – frusDev
    Commented Aug 6, 2009 at 8:43

Just a point in [possibly] the right direction. Someone can post a new answer with the actual solution or edit this one if they choose to.

From what I gather you're going to want to go by IP. At home you'll have an IP address that isn't the same as the one in work. So the first thing you'll need to do is find out what the current IP is.

I found this batch script to do just that.


FOR /F "tokens=2 delims=:" %%a in (%temp%\TEMPIP.txt) do set IP=%%a
del %temp%\TEMPIP.txt
set IP=%IP:~1%
echo %IP% >%temp%\ip.txt
echo The current IP address is "%IP%"

Now that you've got the IP address, you'll probably need to set up an if statement of sorts.

The action of the if's will be something like the following


reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d c:\images\wallpaper.bmp 

The downside of running this as a batch file is it will have to be set up as a scheduled task or something similar

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .