views:

505

answers:

3

Is it possible to run a batch file as a menu item in studio 2008?

A: 

Use "Tools"/"External Tools..." menu item and add your bat-file to "Tools" menu

macropas
+5  A: 

Yes, go to Tools | External Tools in the menus and add your batch file as the Command. You can also pass in any arguments that you want such as the build target, project directories, etc.

Once you do this, your batch file will appear as one of the items on your tools menu. If you want, you can then add a toolbar button for it by going Tools | Customize | Tools and dragging the External Command # that matches your tool to the toolbar. You will then want to change it to an icon and select an image for it.

The tools are numbered 1 based in the order they appear in the menu.

Rob Prouse
How can you find out the number?
Chane
Sorry, missed this. They are numbered 1 based in the order they appear in the menu.
Rob Prouse
Another way of figuring out the number: While customizing the menus/toolbars you can open the Tools menu. When in that mode it will replace the name of the tools with their number in the menu. I think you can also drag directly from there onto the toolbar.
xero
A: 

As A refinement to the given answer:

Say your project/solution have several BAT that are project specific - you wouldn't want to run one from another project - that's what could happen with the above answer - because you have hard wired the path to the bat.

Just set up one external tool nameed "Run BAT", sets its Command to $(ItemPath), and set the initial directory to $(ItemDirectory), The dialog will whinge that this is not a real executable - but ignore that.

Tie the tool to a button if you want.

Now to run the BAT of choice from the project or solution - just open the .bat for editing and select the "Run BAT" external tool.

you could also set the "use output" option as well and the bats output will be in the output window.

Adrian