environment variable question

V

Vic

I have an old (1991) DOS 'EXE' program witch works in conjunction with batch files. The EXE puts certain information into an
environment variable, the BAT file executes the variable.

This setup does not work in W2K4 (or XP1). I'm wondering why. It appears the OS will not allow the EXE to write a variable to the
environment (all in a 'dos' window), but I am not SURE this is the case. Oddly, BAT files CAN write to the environment within the
session. I am wondering if the problem is the WAY the EXE wants to write a variable into the environment or something else.

Can someone enlighten me as to what is actually going on?

Thanks
Vic
 
P

Pegasus \(MVP\)

Vic said:
I have an old (1991) DOS 'EXE' program witch works in conjunction with
batch files. The EXE puts certain information into an
environment variable, the BAT file executes the variable.

This setup does not work in W2K4 (or XP1). I'm wondering why. It appears
the OS will not allow the EXE to write a variable to the
environment (all in a 'dos' window), but I am not SURE this is the case.
Oddly, BAT files CAN write to the environment within the
session. I am wondering if the problem is the WAY the EXE wants to write a
variable into the environment or something else.
Can someone enlighten me as to what is actually going on?

Thanks
Vic

When you launch an .exe file, that file inherits its
environment from the process it is launched from.
It can then modify any variable it likes. When it
terminates then these modifications are lost.

Under DOS it was possible to modify the master
environment table so that modifications were not
lost on termination of the .exe file. It was a "dirty"
and undocumented way. This is no longer possible
under Windows.
 
V

Vic

Pegasus, thanks for your reply. I figured something like that was going on but what confused me is, the EXE program (actually part
of a nifty menu system which allowed one to quickly run DOS programs) runs in Win 95 & 98.

I guess when you say the variables terminate when the EXE does in Windows you mean a TRUE Windows OS, not Windows on top of DOS.

Well, I don't NEED this menu system but I do need some of the DOS programs. Hummm, is there ANY work around which will allow keeping
the variable once the EXE terminates (as BAT files, i.e., a set command initiated in a BAT file will stay in the environment in that
session even if the BAT file terminates)?

Any help appreciated,

Thanks again
Vic
 
P

Pegasus \(MVP\)

I don't think there is a way to do this unless you can
recompile your .exe file and get it to do things cleanly.
While the .exe file is up and running it should generate
this batch file:

@echo off
set var=xxxx

This would allow you to perform this two-step process:

1. Invoke the .exe file
2. Call the batch file


Vic said:
Pegasus, thanks for your reply. I figured something like that was going on
but what confused me is, the EXE program (actually part
of a nifty menu system which allowed one to quickly run DOS programs) runs in Win 95 & 98.

I guess when you say the variables terminate when the EXE does in Windows
you mean a TRUE Windows OS, not Windows on top of DOS.
Well, I don't NEED this menu system but I do need some of the DOS
programs. Hummm, is there ANY work around which will allow keeping
the variable once the EXE terminates (as BAT files, i.e., a set command
initiated in a BAT file will stay in the environment in that
 
J

Jerold Schulman

See tip 4928 » SETENV.EXE is a freeware replacement for SETX.EXE, and it has more functionality. 06-Mar-02
in the 'Tips & Tricks' at http://www.jsifaq.com


Pegasus, thanks for your reply. I figured something like that was going on but what confused me is, the EXE program (actually part
of a nifty menu system which allowed one to quickly run DOS programs) runs in Win 95 & 98.

I guess when you say the variables terminate when the EXE does in Windows you mean a TRUE Windows OS, not Windows on top of DOS.

Well, I don't NEED this menu system but I do need some of the DOS programs. Hummm, is there ANY work around which will allow keeping
the variable once the EXE terminates (as BAT files, i.e., a set command initiated in a BAT file will stay in the environment in that
session even if the BAT file terminates)?

Any help appreciated,

Thanks again
Vic

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top