Python calls bat and pythonbat to set Environment Variables
A python script is used in the work to automatically run multiple vc project codes under a directory.
The commands of the compilation project code are as follows: the direct operation will fail, and the system cannot find devenv. the directory where devenv.exe is located must be added to the environment variable.
OS. system ('devev' + name + '. sln/project' + name + '. vcproj/Rebuild "debug | win32"/out' + name + '. cmp> nul ')
The project team has a self-compiled bat script for adding various temporary environment variables, which also contains the vc environment variables. So I want to directly call the existing script in python and then execute the compilation command, but it does not work. It is said that OS. system is an independent process and the modification of environment variables does not take effect for subsequent statements.
OS. system ('call ".../set_vs_env.bat "')
OS. system ('devev' + name + '. sln/project' + name + '. vcproj/Rebuild "debug | win32"/out' + name + '. cmp> nul ')
Therefore, only two cmd commands can be executed in one call, that is, multiple cmd commands can be executed at a time, and cmd commands can be connected with the & operator.
Cmd = 'call ".. /.. /set_vs_env.bat "& '+ 'venv' + name + '. sln/project' + name + '. vcproj/Rebuild "debug | win32"/out' + name + '. cmp> nul'
OS. system (cmd)