WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Environment

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Environment Variables in Windows 95

Keywords: environment variable 

RE: Dos Environment Space:

I needed an environment of 2048K to run the SMS installation batch file. I saw several suggestions in the tech db about environvars and one on increasing its size which didn't seem to be quite what I needed. I then came up with this for a Win95 box. Simple and works well.
   Runwait("command.com", "/e:2048 /c %smssrvr%%smsbatfile%")

Question:

I am running an application that needs an environment for Sybase Open Client:
SET SYBASE=C:\SYBASE SET
PATH=C:\SYBASE\BIN;C:\SYBASE\DLL; 
I would like to use Winbatch to set this environment as part of either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER. Can it be done and can someone outline the code?

Answer:

Win95 does not keep the environment in the registry. There is a nice article on how to do it for NT elsewhere in the database but...

There is a Microsoft utility that can be used to set a global DOS variable in Windows 95. The utility is called "WinSet" and it's in a self-extracting archive file named "envars.exe". It's used almost identically to the DOS Set command, except it changes the master DOS environment in Windows 95.

  1. For temporary changes affecting programs that WinBatch itself launches, you can use Environset then RunEnviron.
  2. For permanent changes you get to update the autoexec.bat file.
  3. For just PATH changes investigate the RegApp function.

Problem:

I'm using WinBatch under Win95 to run a DOS app that sets an environment variable. Later in the WinBatch program I want WinBatch to be able to reference this environment variable but it's not getting set. If I run the DOS app from DOS, it does set the environment variable, but it seems that WinBatch is not allowing that to happen.

Answer:

Windows is not allowing it to happen. The DOS app can only set environment variables for itself. Not for any other program.

As we mentioned above, there is a Microsoft utility that can be used to set a global DOS variable in Windows 95. The utility is called "WinSet" and it's in a self-extracting archive file named "envars.exe". It's used almost identically to the DOS Set command, except it changes the master DOS environment in Windows 95.

What are you trying to do? If you are trying to return an errorlevel to WinBatch, see ERRORLEVEL.* in the samples subdirectory.

Are you trying to return other info to WinBatch? To write info to a ini file like thusly...

  
      echo [MyData] > c:\temp\mydata.ini
      echo envvar=%envvar% >> c:\temp\mydata.ini

In WinBatch, do the following:

      envvar=IniReadPvt("MyData","envvar",0,"c:\temp\mydata.ini")
 
NB: The RunEnviron function CAN ONLY SET THE ENVIRONMENT AND RUN WINDOWS PROGRAMS. IT CANNOT RUN DOS PROGRAMS.


Article ID:   W12924
Filename:   Setting the Environment in Windows 95.txt
File Created: 2000:03:28:16:24:40
Last Updated: 2000:03:28:16:24:40