3
1
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?
3
1
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?
3
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 – RickMeasham – 2009-08-06T11:12:52.013
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. – David Spillett – 2009-08-06T11:19:31.983
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. – David Spillett – 2009-08-06T13:10:52.210
1
Check out this SU thread. That might work for you.
That might be even easier ;-) – Ivo Flipse – 2009-08-06T09:11:08.470
0
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 - bill@billsway.com
' 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.
1-1 , this answer essentially restates the problem with "and you could automate this with a shell" , 0 value add. – Kent Fredric – 2009-08-06T08:12:18.733
Fair enough, though I haven't given up searching ;-) – Ivo Flipse – 2009-08-06T08:14:36.233
But hey! It's community wiki anyway! – Ivo Flipse – 2009-08-06T08:18:58.267
Thats a lot of effort to find an IP address – Ciaran – 2009-08-06T08:43:46.757
0
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.
http://www.computing.net/answers/programming/batch-file-finding-the-ip-address/13900.html
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
http://www.computing.net/answers/programming/batch-to-change-desktop-wallpaper/15105.html
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
Why Community Wiki? – Ciaran – 2009-08-06T10:31:51.333
Figured as the question was short, it might be better to leave it open to be extended if the community wanted to. – RickMeasham – 2009-08-06T11:15:30.917