DEV Community

loading...

Restart Visual Studio as Admin in seconds

owainwilliams profile image Owain Williams Originally published at owain.codes on ・2 min read

blogcomputerimagelrg

Last week @HotChilliCode aka Nik shared this Scott Hanselman video with me : "Overwhelmed with Programming? Here's small things to help - Computer Stuff They Didn't Teach You #14"

During the video Scott talks about finding ways to reduce repetition. If you find yourself doing something over and over again, is there a way to speed it up? Can you automate it in some way.

Well today I found myself, for probably the 100th day in a row, needing to attach my debugger in Visual Studio to my local IIS instance. The only issue was, I wasn't running in Admin mode.

I needed to close visual studio, right click the icon, open as Admin then reload my solution. Not a massive issue but I had noticed I've been doing this a lot recently as Visual Studio for me doesn't automatically run in Admin mode. I know, I could set it up to run in Admin mode straight away but then if I am doing screen shares, the person I'm sharing with can't interact with my VS screen so then I need to shutdown VS, remove the setting to start as Admin. It's just a pain.

Anyway, I found an Visual Studio Extension called Visual Studio Restart and all it does is, it adds a Link in your File menu that will shutdown VS, restart it in Admin mode and also reload the solution you are working on. Brilliant!

Note: I am using VS2019 Community Edition, I've not tested this in any other versions.

The next thing I did was I assigned a shortcut key to the restart command. The key combo I used is Ctrl+ '

So now, if I am working on a project that I haven't loaded as Admin, I tap Ctrl + ' and boom, I'm up and running in Admin mode in seconds.

Discussion

pic
Editor guide