Remove CMD.EXE part, it's totally redundant.
[EDIT]
Thank you for clarification. Now, not only getting rid of CMD.EXE mean removing redundant tool, it's also critical.
Visual Studio Prompt is interactive, something you don't want. It really is executed via
%comspec%
which is the same vary CMD.EXE already. You need to get rid of it, too. So what Visual Studio Prompt does? It simply sets up environment and working directory the way some utilities work correctly. Lame thing, by they way; I really hope Microsoft will be able to get rid of such approach in future.
So, all you need is to carry out the environment and then execute your command line, without CMD.EXE. Here is how:
Go to main menu and copy the Visual Studio Command Prompt .lnk file in some directory. Open its properties window (Alt+Enter) and copy two strings: a full name of the batch file from the field "Target" and a working directory from "Start in". The result depends on how you installed Visual Studio. It will be something like:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\
You really want to unify then so write just the directory and file name:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\
vcvarsall.bat
Modify these strings according to what you have.
Now, here is what you can do in your batch file:
set workingDir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\
set vs=vcvarsall.bat
cd %workingDir%
call %vs%
:: your commands go here, such as:
makecert -sv SignRoot.pvk -cy authority -r sha1 -a -n \"CN=Certificate\" -ss my -sr localmachine certificate.cer
I've shown these
def
parts to help you to unify the batch for other commands and Visual Studio installations. You can also pass parameters to batch files to abstract our file names, for example:
:: ...
makecert -sv %1 -cy authority -r sha1 -a -n \"CN=Certificate\" -ss my -sr localmachine %2
This way, you can call your batch file with file parameters. This can be important, because you don't want to copy your files to working directory of Visual Studio Common Prompt, so you would need to copy their full path names:
yourBatchFile.bat /path/to/SignRoot.pvk /path/to/certificate.cer
And you can put this line in other batch file, for example. Be careful with path names containing blank spaces; they should come in ""; or avoid them.
—SA