THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Peter DeBetta's SQL Programming Blog

Peter DeBetta's blog about programming in SQL Server using technologies such as T-SQL, .NET, CLR, C#, VB, Visual Studio, and SQL Server Management Studio.

Manage Visual Studio Auto Connect to Team Foundation Server

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:

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 objShellRegLocation

' Instantiate the WSH Shell
Set objShell WScript.CreateObject("WScript.Shell")

' This is the value that affects the auto connect feature

' 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
' Otherwise, update the Registry Value
objShell.RegWrite RegLocationid"REG_DWORD"
End If

' Exit Gracefully

Quick Update: Changed default to existing value in Registry (and blank if it doesn't exist)

Published Thursday, July 19, 2007 10:42 AM by Peter W. DeBetta


No Comments
New Comments to this post are disabled

About Peter W. DeBetta

Peter DeBetta works for Microsoft as an Application Platform Technology Strategist, specializing in strategies, design, implementation, and deployment of Microsoft SQL Server and .NET solutions. Peter writes courseware, articles, and books – most recently the title Introducing SQL Server 2008 from Microsoft Press. Peter speaks at conferences around the world, including TechEd, SQL PASS Community Summit, DevTeach, SQL Connections, DevWeek, and VSLive!

When Peter isn’t working, you can find him singing and playing guitar (click here to hear an original song by Peter), taking pictures, or simply enjoying life with his wife, son, and daughter.
Privacy Statement