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

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(required) 
Submit

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.
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement