简体   繁体   English

如何使用.bat文件在VS2010中添加环境变量?

[英]how to add environment variables in VS2010 using .bat file?

I have a batch file with this code: 我有一个带有以下代码的批处理文件:

@echo off
set VAR=7
echo the version is %VAR%

I want to add this .bat file to my visual studio project, using pre-build event. 我想使用预构建事件将此.bat文件添加到我的Visual Studio项目中。 I wrote in the pre build event the path to the batch file, but then when I enter the : Resources ->PreProcessor definitions - I can't see the VAR How can I add it? 我在预构建事件中写了批处理文件的路径,但是当我输入:Resources-> PreProcessor definitions-我看不到VAR时如何添加它? any help would be appreciated!! 任何帮助,将不胜感激!!

Change your BAT script to be something like 将您的BAT脚本更改为类似

echo #define VER 7 > version.h

and then have your code use 然后使用你的代码

#include "version.h"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM