BradleyB's WebLog

How to open a website in Visual Studio 2005 from the command line

I’ve seen several queries asking how to launch Visual Studio 2005 opening a specific folder as a website from the command line.  Unfortunately Visual Studio 2005 does not support this by default but you can enable the scenario by writing a macro.

 

To do this, create a new macro either in an existing module or in a new module.  For this example I’m going to add a module call Website to the MyMacros project.

 

If you’re new to macros in Visual Studio 2005, select menu Tools/Macros/Macros IDE, then select the MyMacros project and add a module.

 

Before you can use the new Website extensibility objects within VS you’ll need to add a reference to VsWebSite.Interop.dll. 

 

Once added you can add the following code:

 

Public Module Website

    Sub OpenWebsite(Optional ByVal path As String = "")

        If (String.Compare(path, String.Empty) = 0) Then

            MsgBox("Must supply a folder path to the OpenWebsite macro", MsgBoxStyle.OkOnly)

        Else

            Dim webPkg As VsWebSite.VSWebPackage

            webPkg = DTE.GetObject("WebPackage")

            webPkg.OpenWebSite(path, VsWebSite.OpenWebsiteOptions.OpenWebsiteOption_None, False)

        End If

    End Sub

End Module

 

 

After this code is added you’ll be able to run the macro.  You can test it out in the command window.

 

From the Command Window in VS:

 

>Macros.MyMacros.Website.OpenWebsite C:\MyProjects\MyCompany\CompanySite

 

From the Command Line:

 

devenv /command "Macros.MyMacros.Website.OpenWebsite C:\MyProjects\MyCompany\CompanySite"

 

After its working you can register a shell command enabling an “Open as Visual Studio Website” command on any folder in windows explorer.

 

To do this copy the following into a OpenWebsite.reg file and run it.

 

Windows Registry Editor Version 5.00

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OpenVSWeb]

@="Open as Visual Studio Website"

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OpenVSWeb\command]

@="devenv.exe /command \\\"Macros.MyMacros.Website.OpenWebsite %1\\\""

 

 

Now you should be able to right click on a folder in Windows Explorer and select “Open as Website”.

 

Hope this helps,

Brad.

Comments

Brian said:

This is awesome! Thanks!!!
# December 9, 2005 10:28 PM

Zubair.NET! said:

Awesome, it works!
# December 11, 2005 12:11 AM

MaheshKumar.R said:

Really usefull and good work..
thanks brad..
# December 12, 2005 4:42 AM

vFramer said:

COOOOOOOOOOOOOOOOOOOOOOOOOOL!
# December 14, 2005 9:47 AM

oVan said:

Thank you for this great tip!
# December 19, 2005 9:36 AM

Zubair.NET! said:

Any ideas on how to implement it in VS2003/2002 given that the website is already configured in IIS.

Zubair.NET!
http://zubairdotnet.blogspot.com
# December 21, 2005 11:19 PM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# July 26, 2006 6:39 AM

.net DEvHammer said:

Ever wanted to be able to simply right-click a folder in Windows Explorer and open it as a web site in...

# August 14, 2006 9:02 PM

Tech Guru said:

# August 14, 2006 10:45 PM

Йордан Димитров said:

Вече има и SP 1 за Microsoft® Visual Studio® .NET™ 2003 download. CTP на нoватаверсия на ADO.NET...

# August 17, 2006 1:09 AM

Frederic said:

I Love You :-)

# September 8, 2006 11:21 AM

johnagrandy said:

My VS05 does not have a Tools/Macros menu ...

Any ideas ?

# October 6, 2006 12:50 PM

az said:

My cat's breath smells like cat food

# April 24, 2007 5:28 PM

Suraj Kumar said:

This is helpfull.

Thanks,

# July 29, 2007 5:08 PM

James Reid said:

I'm new to adding references in VS. How do you add a reference to VsWebSite.Interop.dll?

# November 12, 2007 1:13 PM

mensah kelvin said:

this website will bring lost friends together

# February 1, 2008 3:06 PM

anupama reddy said:

Dear sir,

        I want to open my website. How to proceed? Can u help me?

Thanks & Regards

Anupama Reddy

# March 21, 2008 7:55 AM

David Demus said:

Excellent tool.  I tried to add some more cleverness to this by putting all my commonly used VS projects as shortcuts in one directory.  To my surprise, it works!  (I was a little surprised you could even make a shortcut to a directory.)  One small, odd drawback: this blows up the explorer window with the projects directory in it.  No other damage I've seen.

# July 25, 2008 5:46 PM

Giaskhan said:

Education is the back bone of a nation.

# September 10, 2008 6:53 PM

Giaskhan said:

How to open website.Can u help me? Thank.

# September 10, 2008 6:56 PM

Josh said:

what about for VS 2008?

# October 7, 2008 12:45 PM

Jaisonktm said:

Hi...,

useful article, but tell me how we can add a reference - VsWebSite.Interop.dll.  ?

Add reference menu by right click project? after that what i should do?

pls answer..

# October 13, 2008 5:13 AM

jaman said:

dear sir, help me how to open  awebsite

# October 13, 2008 9:14 AM

youthrenaissance said:

open a new website

# October 16, 2008 12:39 PM

Open VS2008 WebSite from Windows Explorer by JohnnyCoder said:

Pingback from  Open VS2008 WebSite from Windows Explorer by JohnnyCoder

# October 20, 2008 1:56 PM

anisa said:

i think that is posible to open this web site but i want open

# October 21, 2008 5:08 AM

mustafa said:

to write my life history

# November 12, 2008 3:42 PM

my company said:

pla i will like to have a wedsite of my own and i dont know how to get to the wedsite and have my own site. pls help me and tell me what to do about it.

form christian peter.

my email is chibueze2003@yahoo.com

# November 17, 2008 6:18 AM

evemnthave said:

Задумался, как найти важную информацию. По-моему, вот там все можно найти <a href=www.nlight.ru/.../> на халяву</a>, с удовольствием попользовался - все так и есть.

# November 26, 2008 10:09 AM

evemnthave said:

Задался вопросом найти нужную информацию. Очень здесь все можно найти <a href=www.nlight.ru/.../> даром</a>, с удовольствием проверял: все так и есть.

# November 26, 2008 5:48 PM

unsudgeBups said:

Медицинская справка , компьютерное заполнение -  в ГАИ,  Вы можете получить за 800 р. и 20 минут  :  психиатр, нарколог и фото на месте.  А также медсправки для судоводителей маломерных судов.

# December 1, 2008 6:14 PM

unsudgeBups said:

водительская медсправка установленного образца в ГИБДД,  Вы можете получить за 800 р. и 20 минут   -  психиатр, нарколог и фото на месте.  А также осмотр врача и справка для судоводителей.

# December 2, 2008 1:14 AM

Zachary V said:

To add reference right click on macro and select Add Reference... then scroll to the bottom and doubleclick VsWebSite.Interop.dll... Click OK...

# December 4, 2008 6:07 PM

Nasir uddin shah said:

I wants open a website.But i don't know "How to open a website". please help me this matter

# January 2, 2009 6:40 AM

Babatunde Agboola said:

Kindly help we that are not familiar with web services

# January 9, 2009 4:19 PM

Babatunde Agboola said:

This website will let us be known through out the world.regards tunde

# January 9, 2009 4:24 PM

howells obiorah said:

i just want u to tell me or teach me how to creat a web , site, i learnt u are the best in web site creating. hope to hear 4rm u

# January 13, 2009 6:23 AM

fran said:

you suck can u show examples

# January 27, 2009 5:58 PM

habeeb_salau said:

just to know more on open website .thanks for listenig

# January 28, 2009 3:52 PM

habeeb_salau said:

jsut to what is happen in world.to become a proffessional

# January 28, 2009 3:56 PM

Noorullah Velampudukkudi said:

I am Noorullah Of Velampudukkudi Tranqubar tk Nagai Dist. Working in AL S T Coimbatore as a EDP In- Charege foe 11 Yrs.

# February 8, 2009 2:36 AM

hfghgf said:

fdsfd sfdsfsdfgreg54dfgb mj,kg.mhgnbgf gfdg

# February 17, 2009 5:03 AM

Emmanuel said:

  Hi, pla I will like to have a website of my own and

  I dont know how to get to the website and have my own site,and to write my life history.pls hel me and tell me what to do about it.

  From: Emmanuel Medard

  my email adress is:emmanuel1@live.no

# February 20, 2009 4:34 PM

scooby said:

hii there,am male from Kenya,i would really like to open my own website with my ideas and updates,please help me out,its not only one and another one for my company please hwlp out.

Thanks

# February 25, 2009 5:39 AM

mtw said:

This is awesome! Than

# April 10, 2009 6:49 AM

ganiewsheenia said:

Ну и чушь  у вас на сайте написана

# May 31, 2009 2:09 PM

maliapomiaf said:

А как на вашу рсс-ленту подписаться? что то не пойму

# June 1, 2009 12:52 PM

embareeDraild said:

Картинок бы побольше, тогда б и сайт веселей смотрелся

# June 1, 2009 3:56 PM

agonymnsoania said:

Да уж интересно Вы пишите, сайт весь такой познавательный

# June 2, 2009 2:13 AM

Icemymmereesy said:

Интересный сайтик и дизайн не навязчивый

# June 2, 2009 3:24 AM

queellhoula said:

Что то у Вас дизайн косит, сижу под ИЕ

# June 2, 2009 5:18 AM

diemdaype said:

Добавил в избранное, буду заходить почаще

# June 2, 2009 8:26 AM

HopsCodeRooTo said:

Интересно, а главное коротко. Так держать!!!

# June 2, 2009 10:19 AM

mubyreumpendy said:

Что у вас не так с каринками

# June 2, 2009 11:28 AM

gensomymmedge said:

Отличная статья Побольше бы такого в интернете

# June 2, 2009 1:04 PM

Taseenulley said:

Действительно интересный сайт, добавил в избранное, буду заходить почаще

# June 3, 2009 1:30 AM

beappease said:

Почаще что-нить новенькое на сайте размещайте и читателей станет больше

# June 3, 2009 2:46 AM

otheneenvigot said:

Поконкретнее узнать бы по теме... Буду ждать продолжения

# June 3, 2009 5:48 AM

syncenjoymn said:

Да такой информации в интернете дофига, хотелось бы чего то особенного.

# June 3, 2009 8:49 AM

TawCalliams said:

Интересный сайт, автору спасибо

# June 3, 2009 9:56 AM

Gumninguanisk said:

Очень интересно, хотя что похожее вижел на другом сайте

# June 3, 2009 11:11 AM

lasyFlarp said:

Прикольная статья, но хотелось бы поподробнее узнать о некоторых моментах... Как можно с Вами связаться?

# June 7, 2009 8:02 AM

infotsinvom said:

Да это действитеьно интересно, будем ждать продолжения

# June 7, 2009 9:13 AM

Irrilultura said:

Дизайн у Вас интересный, я вот тоже для блога искал - стала прикручивать, а все посты куда то делись. Эээх... буду писать заново

# June 7, 2009 10:28 AM

Allelpics said:

Новая смена полярников, вылетевшая 5 февраля из Санкт-Петербурга в южноафриканский Кейптаун, привезет с собой в Антарктиду спецконтейнер с комплектом “экологически чистой бани из клееного бруса с замкнутым циклом обеспечения”, сообщает сайт <a href=http://vsefakti.ru>Все научные факты</a>

Сорок два полярника, припасы, научное оборудование и баню на прибрежную антарктическую станцию “Новолазаревская” привезет флагман полярного флота “Академик Федоров”.

Планируется, что “банный комплекс” будет построен на специально подготовленном участке вблизи одного из антарктических озер.

# June 7, 2009 11:58 AM

sportmasterrr said:

Скажите а могу я статьи с вашего сайта у себя на блоге публиковать? Е сли да - то ссылку ставить или просто источник указывать?

# June 8, 2009 7:35 AM

WhammajeptDam said:

Действительно интересно написано. Добавил в избранное, буду заходить почаще.

# June 8, 2009 1:48 PM

VibObsedsdomb said:

Бывший вратарь сборной Германии по футболу Йенс Леманн прилетел на одну из тренировок своего клуба “Штутгарт” на вертолете, заплатив за перелет тысячу евро. Голкипер проживает в 250 километрах от тренировочной базы команды, расположенной в городе Берг (неподалеку от Штутгарта), сообщает <a href=http://sportnewsmag.ru>Журнал спортивных новостей</a>. Фотографии Леманна, выходящего из вертолета, появились 19 сентября в немецких газетах. Мэр Берга Руперт Манн рассказал, что он получил несколько жалоб от жителей города, и пообещал поговорить с футболистом, если он вновь прилетит на тренировку на вертолете. В Берге проживают около 8200 человек.

# June 8, 2009 5:16 PM

Quommaimpoppy said:

Хорошо что еще кто-то делает оригинальные сайты. Спасибо за информацию, очень интересно.

# June 8, 2009 10:38 PM

GuepPreense said:

Интересный блог, побольше бы таких

# June 9, 2009 1:26 AM

Inissokjank said:

Побольше бы и таких сайтов

# June 9, 2009 6:59 AM

trellalak said:

Надеюсь ваш сайт будет дальше развиваться

# June 9, 2009 11:19 AM

Irrilultura said:

Дизайн у Вас интересный, я вот тоже для блога искал - стала прикручивать, а все посты куда то делись. Эээх... буду писать заново

# June 16, 2009 2:59 AM

queellhoula said:

Что то у Вас дизайн косит, сижу под ИЕ

# June 23, 2009 9:04 PM

samuel said:

please teach me how to open and manage my own website my email is ejeba4real@yahoo.com

# June 25, 2009 6:37 AM

maliapomiaf said:

А как на вашу рсс-ленту подписаться? что то не пойму

# July 1, 2009 6:59 AM

Mitypetuddy said:

Это не спам. Тестовое сообщение. Извините за беспокойство. http://teeesstt.com

# July 14, 2009 5:46 AM

Mitypetuddy said:

Sorry, its no spam. Извините за беспокойство. http://tecsstt.com

# July 15, 2009 3:30 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 4:37 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 4:41 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 4:55 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 5:57 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 6:04 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 6:16 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 6:25 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 7:08 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 7:13 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 7:21 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 7:35 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 9:34 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 10:01 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 10:20 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 10:31 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 11:13 AM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 12:30 PM

Mitypetuddy said:

yeee, baby, its the best choise http://treemarlin.rbcmail.ru

# July 20, 2009 12:51 PM

Mitypetuddy said:

статистика для данного ролика еще в обработке http://devitzy.by.ru

# July 20, 2009 4:10 PM

sabsSleette said:

dsfgsdfg dfssdfgf fdsgsdfgsd

# August 1, 2009 6:33 PM

Baby names search - Search for Ovan said:

Pingback from  Baby names search - Search for Ovan

# September 9, 2009 12:38 AM

ebere said said:

teach me how to open a web and how to manage it my email is eberechigbo@yahoo.com

# October 12, 2009 8:52 AM

ebere said said:

teach me how to open a website and how to manage it my email is eberechigbo@yahoo.com

# October 12, 2009 8:56 AM

Mr Stanley Morgan said:

how do i open a bussiness website

# October 16, 2009 4:13 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)