Launch of .bat files out of Visual Studio 2010

Or how to hang a voluntary action to the context to any item in the Project Explorer.

As already mentioned in the title, this step will be to rotate. Bat files since they are widely used in our daily activities, and constantly open Explorer or FAR is not very convenient. Much better to have effect until the pile and hang it on the key combination to achieve complete nirvana

So, given: a project that uses a batch file

Required: run a batch file from the context menu in the Project Explorer.

Create a link to an external application

In the main menu, select studio Tools -> External Tools …

After that, a window appears where you can specify which application and what parameters to run. In this environment variables are available, such as the path to the file to the project, the file name, the root of the decision, and others.

In the resulting window click on the Add button and fill in the fields according to the screenshot.

Give the name to the action, so that we ourselves can determine what will happen in the end. Prescribes the name of the application to run. In this case the command line C: \ Windows \ System32 \ cmd.exe

The command line arguments. For us, it will be the path to the file. In the variables it is listed as $(ItemPath). I think you have noticed that before this variable is still “/ C”, it says the command line, that is to close immediately after the operation.

Another important thing is to point the working directory for the command line. In my case this is solution folder.

Note in daw Use Output window , to see everything at once in the studio and on stage this customization tool is completed. Click OK and proceed to the next stage of setup.

Adding context menu

Before you add a context menu, you need to do a very important step, without which, success is not guaranteed.

So, you need to open the main menu in the studio Tools, and calculate how the order is necessary to you external tool.

Required item is the sixth. Remember this and move on to the setting in the context menu for files in the Project Explorer.

Open the Tools > Customize…, go to the tab Commands, select the item Context menu and in the dropdown list search for the line Project and Solution Context Menus | Item

After you have selected a row in the drop-down list, you will be all the possible commands that can be displayed for the item.

We need to add a new team that we are doing. Click on the appropriate menu item and look for the category Tools and you want us to command. Team we are looking at its sequence number in the list, which was in the beginning of this section. Now do you understand why it was necessary to find the serial number of the menu item?

After pressing OK, to be like the following on the previous dialog box.

Close this window and you can try to start .bat in the Project Explorer.

That’s all, hope this helps you in your work and allow more productive use of your time.


Tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>