Trifle Menot
2011-08-29 08:28:40 UTC
To run my DOS programs on WinXP, I needed to set environment variables
from a DOS batch file. Problem was, they didn't stick. As soon as the
batch file ended, all the environment variables reverted to what they
were before running the batch file.
If command.com was forking another copy of itself to run the batch file,
that would explain why my changes were not sticking.
After searching but finding no advice, I was frustrated enough to hack
around just to see what I could break. I noticed in the MS-DOS shortcut
properties Program tab, Cmd line box:
F:\WINDOWS\system32\command.com
and I wondered what would happen if I changed it from \command.com to
\cmd.exe. Maybe XP would crash, burn, and explode.
But to my surprise, that was the solution. Now, when I set environment
variables from a DOS batch file, the changes remain after the batch file
ends and the command prompt returns.
Seem counterintuitive to call \cmd.exe from an MS-DOS shortcut, but it
still behaves like an MS-DOS shortcut, because config.nt and autoexec.nt
are processed, as when calling \command.com (verified by testing).
from a DOS batch file. Problem was, they didn't stick. As soon as the
batch file ended, all the environment variables reverted to what they
were before running the batch file.
If command.com was forking another copy of itself to run the batch file,
that would explain why my changes were not sticking.
After searching but finding no advice, I was frustrated enough to hack
around just to see what I could break. I noticed in the MS-DOS shortcut
properties Program tab, Cmd line box:
F:\WINDOWS\system32\command.com
and I wondered what would happen if I changed it from \command.com to
\cmd.exe. Maybe XP would crash, burn, and explode.
But to my surprise, that was the solution. Now, when I set environment
variables from a DOS batch file, the changes remain after the batch file
ends and the command prompt returns.
Seem counterintuitive to call \cmd.exe from an MS-DOS shortcut, but it
still behaves like an MS-DOS shortcut, because config.nt and autoexec.nt
are processed, as when calling \command.com (verified by testing).