Visual Studio Startup Script
Sunday, June 22, 2008 – 8:35 AMGiven that occasionally I’m prone to playing the odd game on my home computer I didn’t want a lot of the services that are only used for development running all the time. Solution… use the Services tab in the Computer Management console and configure them to start manually. Then use a PowerShell script to start them all along with DEVENV.EXE when you want to use VS.
Here’s a PowerShell script to start/stop Visual Studio and associated services …
# Change this line to add or remove services... $services = "w3svc", "aspnet_state", "SQLBrowser", "MSSQL`$SQLEXPRESS", "msdtc", "MDM", "VisualSVNServer" $verb = $args[0] if ($verb -eq "") { $verb = "-start" } foreach ($service in $services) { $action = $verb + $service + " ..." echo $action if ($verb -eq "-stop") { stop-service $service } else { start-service $service } } if ($verb -ne "-stop") { & devenv }
5 Responses to “Visual Studio Startup Script”
Thanks for this… sql server developer and express both allocate memory when you start using them and this is a good way to keep the computer running lean when not developing
By Craig on Jun 22, 2008
It’s working, I did have to change a couple of things for my configuration. I didn’t have DevEnv.Exe in my path, so I added $devenvExecutable. Also, I got a message when trying to do Stop-Service from MSSQL`$SQL2005 that it failed because it has dependent services (even though they were all stopped). So I added the -Force to Stop-Service. Code below. Thanks again!
$services = “aspnet_state”, “MSSQL`$SQL2005”, “msdtc”
$verb = $args[0]
$devenvExecutable = “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe”
if ($verb -eq [System.String]::Empty)
{
$verb = “-start”
}
foreach ($service in $services) {
$action = $verb + $service + ” …”
echo $action
if ($verb -eq “-stop”)
{
stop-service -Force $service
}
else
{
start-service $service
}
}
if ($verb -ne “-stop”)
{
& $devenvExecutable
}
By Craig on Jun 22, 2008
Thanks for doing some cleanup on it. I just added CCTray to mine
& “C:\Program Files\CCTray\cctray.exe”
By Ade Miller on Jun 28, 2008