Recompilation Day 192 Issue - VS Command Line Not Recognized

Good afternoon everyone,

Working on the day 192 recompilation episode and when attempting to call build.bat through CreateProcess(), the VS command line isn't initialized. How do you get the shell.bat VS command to be persistent across all windows processes? I tried calling shell.bat in one process and build.bat in a second, but as soon as the CMD console closes, it seems I lose the VS command line from the original shell.bat vcvarsall.

'cl' is not recognized as an internal or external command,
operable program or batch file.

Windows 10 64bit

Any thoughts or ideas would be greatly appreciated.

Thanks in advance,

Scott

Edited by Scott Hunt on
Afaik there is no way to call bat file and have environment persist globally on Windows. Which is probably you don't want anyway - vsvars32 bat file sets a lot of env variables that can interfere with system or other applications in strange way.

You could modify way how you launch cmd.exe, so it always executes shell.bat file first.

Create a new shortcut and set it to execute following command:
1
C:\windows\system32\cmd.exe /K path\to\shell.bat

This will make cmd.exe to execute shell.bat and keep the terminal open (afaik this is what Casey does).

Then always use this shortcut to launch the terminal where you work on code or launch the game.

If you really really want to set this globally, you could do following:
a) execute shell.bat in cmd window
b) read values of PATH, INCLUDE and LIB env variables
c) set the values PATH, INCLUDE and LIB variables globally (manually)
After that you won't have need to call shell.bat at all.

Edited by Mārtiņš Možeiko on
Hey Martins, thanks for the follow-up.

I currently launch 4coder and VS all from the cmd line with the shell batch file as you suggested and as Casey seems to do. When I run the build directly from the cmd line I have no problem and VS cl persists and the game allows self compilation. It is when I attempt to run it through the debugger in VS that I seem to lose the VS CL. From the videos it appears Casey has no problem when debugging through VS though.

Unfortunately I'm not understanding the details behind parts B and C below with respect to setting up the paths from the shell batch.

Any additional information you have would be appreciated.

Regards.
I'm wondering if it's because the simple "msdev" script he has that calls devenv doesn't seem to load up VS for me. I have to do an explicate call with full path to devenv.exe.
Don't understand it, but seemed to solve it with ensuring the CMD prompt used to run all the shell scripts and startup 4coder, etc. is in adminstrator mode. VS now seems to carry the "Cl" command through into it's debugging.
Try "devenv /useenv". I believe that by default devenv doesn't pass its environment variables to child processes. Or was it only for building? Not sure I remember correctly.

Right, Casey has disable all the UAC so he pretty much works as administrator on his machine.

b-point means to simply execute "echo %PATH%", "echo %INCLUDE%" and "echo %LIB%".
and c-point means to open env settings dialog - Start Menu -> "Edit environment variables for your account" -> create New or Edit existing ones.
But I would suggest against this. Having bunch of random dlls that cl.exe requires in global path will break something for some other application sooner or later.

"msdev" is old executable name for Visual Studio. New one (for last 12 or so years) is called "devenv". Casey created msdev.bat file (next to shell.bat) that simply calls devenv. You can call devenv directly, its fine.

Edited by Mārtiņš Možeiko on