M
M
MrZed2021-08-16 03:28:36
cmd/bat
MrZed, 2021-08-16 03:28:36

Executing a command on cmd startup?

How to make a file run every time you open cmd ( For example: vcvars32.bat )? Is it possible to implement this through PATH environment variables?

PS: I use the cl.exe program to compile .cpp, and if I do not enter vcvars32.bat every time I open a new console, it gives an error:

main.cpp(1): fatal error C1034: iostream: не указан путь поиска включаемых файлов
and if you run vcvars32.bat, then everything works fine!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2021-08-16
@MrZed

vcvars32.bat is included with MSVS to set environment variables.
MSVS also installs several shortcuts in the start menu to launch the command line, where all the necessary environment variables are already set. This is done like this: The
cmd.exe /K vcvars32.bat
/K key prevents cmd.exe from closing after executing the command passed in the parameter. I gave the command schematically, you can see the exact command in the MSVS label. Other parameters are also possible, which are already passed to vcvars32.bat.
By the way, there is also vcvars64.bat.
It doesn't make sense to always run vcvars32.bat when starting cmd. Just use the shortcut from MSVS to launch the command line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question