0

I'm looking to write some code to open the visual studio command prompt and move to a specific line number. Here's what I've gotten so far:

Process.Start("C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\Developer Command Prompt for VS2013.lnk", "/K devenv /edit FileLocation /command ""edit.goto LineNumber""")

Command prompt opens up but I've having trouble making an argument. The command:

devenv /edit FileLocation /command "edit.goto LineNumber"

works on the command prompt, but I'm not sure how to input this command into vb.net using process.start()

  • Possible duplicate of [Open a file in Visual Studio at a specific line number](http://stackoverflow.com/questions/350323/open-a-file-in-visual-studio-at-a-specific-line-number) – T.S. Feb 15 '17 at 01:47
  • @T.S. Ive used the command from that page, nothing about using command through a vb.net application. – user2823955 Feb 15 '17 at 13:37

1 Answers1

1

First of all, don't use shortcuts to locate programs.

You should find Visual Studio's directory, instead, then execute it from there. For example, mine is located in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE.

For example:

Process.Start("C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe", "/edit ""FileLocation"" /command ""edit.goto LineNumber""")

This way you don't have to rely on the existence of the shortcut.

Ally
  • 467
  • 5
  • 24
  • I've got code checking to make sure that the file exists beforehand. It needs to be able to run on any machine with visual studio installed, so the location needs to be standard. – user2823955 Feb 15 '17 at 13:38
  • 1
    So rather than determining the location of the shortcut, which, I will add, doesn't exist on my machine, determine the installation path of Visual Studio. That way you can run it on any machine and execute VS directly. There are several methods that exist that allow you to do this. – Ally Feb 15 '17 at 21:44
  • I want to remove my last comment. This is the correct way to go about this. I'd recommend using double "" around the file location as if it has spaces in it can issues. – user2823955 Mar 23 '17 at 13:34
  • @user2823955 you are correct, let me edit that now. -- Edited. – Ally Mar 23 '17 at 21:59