THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - 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:

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 objShellRegLocation

' 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 RegLocationid"REG_DWORD"
End If

' Exit Gracefully
WScript.Quit 

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

Comments

No Comments
New Comments to this post are disabled

About Peter W. DeBetta

Peter DeBetta works as a Data and Cloud Solution Manager at DB Best, a Microsoft gold partner company. Peter has written courseware, articles, and books on topics such as development and SQL Server. Peter has spoken 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, taking pictures, working on DIY projects, woodworking, or simply enjoying life with his kids.
Privacy Statement