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?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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.
Check out this SU thread. That might work for you.
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 - firstname.lastname@example.org ' rev 15 Jan 2002 ' Now works with Windows NT, 2K, XP Option Explicit Dim IP_Address : IP_Address = GetIP() If IP_Address = "0.0.0.0" OR IP_Address = "" Then MsgBox "No IP Address found." Else 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 Else 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) Loop .Close 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 fso.GetFile(TmpFile).Delete 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.
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.
IPCONFIG |FIND "IP" > %temp%\TEMPIP.txt 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