I've been on a project where we are using Team Foundation Server (TFS). As you may already be aware, Visual Studio (VS) automatically tries to connect to TFS. When I am onsite, this is great, but when I am offsite and not VPN-ed into the client site, VS takes a long time to time out on its attempt to connect to their TFS. When going in and out of VS throughout the day, I felt as if I was wasting a lot of time waiting for VS to time out. So I found this little nugget that showed how to modify the registry to turn off the auto connect feature:
http://blogs.conchango.com/merrickchaffer/archive/2007/01/09/Prevent-Visual-Studio-Team-Explorer-from-connecting-to-Team-Foundation-Server-at-startup.aspx
But I decided that I wanted to quickly be able to change the setting without having to plow through the registry each time, and so I wrote a quickie VBScript for WSH that would allow you to easily change the registry setting. Here is that script:
' VBScript
' The script creates and/or updates the TFS AutoLoadServer feature for Visual Studio
' By default, Visual Studio will attempt to reconnect to all Team Foundation Servers
'
' Creating a REG_DWORD value named AutoLoadServer at
' HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\TeamFoundation\
' you can manually control whether or not VS will automatically connect to TFS server(s)
' 0 means do not automatically connect
' 1 means automatically connect (default behavior when value is not present)
'
' Peter DeBetta, 2007
' Some variables
Dim objShell, RegLocation
' Instantiate the WSH Shell
Set objShell = WScript.CreateObject("WScript.Shell")
' This is the value that affects the auto connect feature
RegLocation= "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\TeamFoundation\AutoLoadServer"
' Default to existing value (blank if not present)
id = objShell.RegRead(RegLocation)
' Ask for the new value (default to "1")
id = inputbox("Type 1 to turn on, 0 to turn off","VS TFS AutoLoadServer", id)
If id <> "0" And id <> "1" Then
' Did we get a valid value? No? Then let the user know
objshell.popup "Invalid input: Only 0 or 1 are allowed" ,,"INPUT ERROR!",48
Else
' Otherwise, update the Registry Value
objShell.RegWrite RegLocation, id, "REG_DWORD"
End If
' Exit Gracefully
WScript.Quit
Quick Update: Changed default to existing value in Registry (and blank if it doesn't exist)
