Microsoft KB Archive/68933

Storage of Program Text Output in the Environment PSS ID Number: Q68933 Article last modified on 02-05-1993 PSS database name: O_MSDOS

3.30 4.01

MS-DOS

Summary:

This article outlines one method by which text output from a program may be stored as an environmental variable. This method could be used to allow a batch file to change directories, execute commands in that directory, then return to the original directory.

More Information:

The following example outlines the procedure for storing the current directory in the environment. The same principles can be applied to the storage of other programs’ output, provided it does not exceed one line. Attempting to store multiple lines of text in the environment by this method will produce errors.

  Create a text file in the following manner: C:>COPY CON C: SET OLDDIR=^Z It is essential to enter the CTRL+Z BEFORE pressing ENTER.   Create the following batch file, SVCD.BAT: ECHO OFF DEL C:2.BAT COPY C: C:2.BAT CD >> C:2.BAT CALL C:2.BAT DEL C:2.BAT This procedure will store the current directory in an environment variable, OLDDIR.   The original directory can now be returned to (from within a batch file) with the line: CD %OLDDIR% 

Additional reference words: 3.30 4.01 noupd

Copyright Microsoft Corporation 1993.