Do you
have to use one of the visual studio tools?
Personally I just use G++.
Code: Select all
@echo off
:main
cd %dir%
set dir=%~dp1
set name=%~n1
del "%dir%\%name%.exe"
cls
C:\MinGW\bin\g++ "%~1" -o "%dir%\%name%.exe" -static
if exist "%name%.exe" goto :program
pause
goto :main
:program
call "%name%.exe"
pause
Drag & Drop code.cpp, this will automatically:
1) Delete an existing "code.exe"
2) Compile the file dragged ontop of it (code.cpp) as "code.exe"
3) If compiling failed, it'll pause, and attempt to recompile.
4) When compiling succeeded, it'll run the code and pause at the end.
But if you need to get cl, you can use this - it doesnt run vcvarsall however, it just goes straight to the directory.
Code: Select all
::Minimize output from running the commands (compiler errors will not be silenced)
@echo off
::Temporarily change the directory to here
pushd "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"
::Use cl to compile main.cpp
cl main.cpp
::Run main.exe
main.exe
::Quit the temporary changes.
popd