DOS/.CMD Environment Variables

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: StephenMcC (StephenMcC_at_discussions.microsoft.com)
Date: 06/15/04


Date: Tue, 15 Jun 2004 02:03:01 -0700

Hi all,

I'm having trouble getting access to envionment variables in DOS (.cmd files). I'm running scripts on a web server which download a file containing password information which I add to the SYSTEM environment object for the life of the scripts and then when I'm done I remove these.

My problem is that I can't get access to these in the same process within the DOS/.cmd script, if I terminate the script after these are added and run it again then the DOS script can read the Env variables.

Is there any way to force the DOS/.cmd script to read the Env variables in the same session/process that they were added, rather than having to use .vbs which is what I'm using at the moment via the WScript Env object.

Ideally I'd like to first call a .vbs file to download the file, process it and add the password info and then access these from the DOS scripts ie:

ECHO My AUDIT PASSWORD Env Var=%ENV_AUDIT_PASS%

'ENV_AUDIT_PASS' being the name for the Env variable added to the SYSTEM Env Collection obj.

I've tried using SETLOCAL etc which some people suggested with no joy.

Any ideas, anyone ??

Cheers,

Stephen
.



Relevant Pages

  • Re: [PHP] getting $_ENV variables
    ... Did you get that result when running the script from the CLI or via the ... All I want is to check the $_ENVwithin PHP scripts. ... there are even fewer $_ENV variables printed than the CLI ... Daniel P. Brown ...
    (php.general)
  • Help with KSH
    ... to source a generated file by a third party product. ... this script is to setup more env variables. ... When this script is run and MWJ_ROOT is not set, ... KSH: MWJ_ROOT: parameter not set ...
    (comp.unix.questions)
  • Re: DBD::ODBC fails, SQL*Plus works
    ... Basic questions: the script is running in an environment where the env variables $ORACLE_HOME and $TNS_ADMIN are available? ...
    (perl.dbi.users)
  • Re: Help with KSH
    ... this script is to setup more env variables. ... When this script is run and MWJ_ROOT is not set, ... KSH: MWJ_ROOT: parameter not set ... Though that will set MWJ_ROOT to an empty string if it was ...
    (comp.unix.questions)
  • Re: Passing values between files
    ... I have got the .wsf file calling the the ... > .vbs file OK with the following script block as you suggested; ... it is the scripting host that executes code ...
    (microsoft.public.scripting.wsh)