environment variable is blank
Moderator: DosItHelp
-
- Posts: 15
- Joined: 14 Jun 2010 06:50
environment variable is blank
Hi All,
I created one environment variable from My computer->properties->advanced->Environment variables->system variables.
Problem is: This compute is used for running bat files to process feeds and never shuts down. I just added this new variable in the bat file. When this bat file is called, this variable is appearing as <blank>. No values in it . But when I log on to this machine and echo the same variable...the value is shown correctly.
Do I have to restart/log off the machine? Please help.
Thanks,
Meet
I created one environment variable from My computer->properties->advanced->Environment variables->system variables.
Problem is: This compute is used for running bat files to process feeds and never shuts down. I just added this new variable in the bat file. When this bat file is called, this variable is appearing as <blank>. No values in it . But when I log on to this machine and echo the same variable...the value is shown correctly.
Do I have to restart/log off the machine? Please help.
Thanks,
Meet
Re: environment variable is blank
your must restart CMD session (not computer) or use SETX instead SET/Registry
-
- Posts: 15
- Joined: 14 Jun 2010 06:50
Re: environment variable is blank
How to restart cmd. There is no cmd running on that computer. A scheduler job calls .bat file at specific times. That's all. I am not setting this variable in bat file only using it.
Thanks,
Meet
Thanks,
Meet
Re: environment variable is blank
all .bat jobs, that started after change var may use this variable
-
- Posts: 15
- Joined: 14 Jun 2010 06:50
Re: environment variable is blank
Sorry for my ignorance but how do I restart .bat file (double click on it manually?)? It's production environment so I have to be careful.
Re: environment variable is blank
wait next call according to time schedule...
I cannot recommend kill BAT box in production environment
I cannot recommend kill BAT box in production environment
Re: environment variable is blank
agrawal.meet
If you start a batch file, it gets the current environment as a "mirror image". This "mirror image" is valid as long as your batch process runs. You can change it "inside" the process, but never from "outside". That means, regardless what you would do with the parent environment, it would never touch the child environment of your batch process.
To that extent I've understood correctly, your batch file will never end or start new. In this case you can't work with a global variable which would change during the run time of your batch file. The only thing you can do with such a variable is to read the registry key where it is saved.
Otherwise you could try a different way, e.g. read a value from a file.
Regards
aGerman
If you start a batch file, it gets the current environment as a "mirror image". This "mirror image" is valid as long as your batch process runs. You can change it "inside" the process, but never from "outside". That means, regardless what you would do with the parent environment, it would never touch the child environment of your batch process.
To that extent I've understood correctly, your batch file will never end or start new. In this case you can't work with a global variable which would change during the run time of your batch file. The only thing you can do with such a variable is to read the registry key where it is saved.
Otherwise you could try a different way, e.g. read a value from a file.
Regards
aGerman
-
- Posts: 15
- Joined: 14 Jun 2010 06:50
Re: environment variable is blank
wait next call according to time schedule...
It already ran 3 times (3 days) but the variable is still showing up as <blank> in log files
To that extent I've understood correctly, your batch file will never end or start new. In this case you can't work with a global variable which would change during the run time of your batch file.
I am not sure if I got it properly, but I am not changing the variable. Only using it. Below is the sample code.
System variable: GLOBENV_CAT_OUTDIR_ARCHIVE_GV
Value: \\<folder share>\CAT\Out Archive\GLOBAL VISION BACKUP
Use is the bat file:
Code: Select all
move "%GLOBENV_CAT_OUTDIR_ARCHIVE%\catgvf01.dat" "%GLOBENV_CAT_OUTDIR_ARCHIVE_GV%\catgvf01_D_%newDate%_%TIME%.dat"
move "%GLOBENV_CAT_OUTDIR_ARCHIVE%\catgvf02.dat" "%GLOBENV_CAT_OUTDIR_ARCHIVE_GV%\catgvf02_D_%newDate%_%TIME%.dat"
move "%GLOBENV_CAT_OUTDIR_ARCHIVE%\catgvf03.dat" "%GLOBENV_CAT_OUTDIR_ARCHIVE_GV%\catgvf03_D_%newDate%_%TIME%.dat"
move "%GLOBENV_CAT_OUTDIR_ARCHIVE%\catgvf04.dat" "%GLOBENV_CAT_OUTDIR_ARCHIVE_GV%\catgvf04_D_%newDate%_%TIME%.dat"
%GLOBENV_CAT_OUTDIR_ARCHIVE% variable which was already there from the start is working correctly.
Below is the log:
Code: Select all
D:\Apps\CAT\com>move "\\<folder share>\CAT\Out Archive\catgvf01.dat" "\catgvf01_D_20100624_00741.dat"
1 file(s) moved.
D:\Apps\CAT\com>move "\\<folder share>\CAT\Out Archive\catgvf02.dat" "\catgvf02_D_20100624_00741.dat"
1 file(s) moved.
D:\Apps\CAT\com>move "\\<folder share>\CAT\Out Archive\catgvf03.dat" "\catgvf03_D_20100624_00741.dat"
1 file(s) moved.
D:\Apps\CAT\com>move "\\<folder share>\CAT\Out Archive\catgvf04.dat" "\catgvf04_D_20100624_00741.dat"
1 file(s) moved.
Re: environment variable is blank
Stange.
-press keys [Windows]+[R]
-type CMD
-click OK
to open the command prompt
-type SET
-hit [Enter]
to display all global variables and their values
Can you find GLOBENV_CAT_OUTDIR_ARCHIVE_GV in this list?
Btw: Is there a command line in your batch file similar to this?:
Such command would destroy the variable for the code below that line.
Regards
aGerman
-press keys [Windows]+[R]
-type CMD
-click OK
to open the command prompt
-type SET
-hit [Enter]
to display all global variables and their values
Can you find GLOBENV_CAT_OUTDIR_ARCHIVE_GV in this list?
Btw: Is there a command line in your batch file similar to this?:
Code: Select all
set GLOBENV_CAT_OUTDIR_ARCHIVE_GV=
Such command would destroy the variable for the code below that line.
Regards
aGerman
-
- Posts: 15
- Joined: 14 Jun 2010 06:50
Re: environment variable is blank
Hello aGerman,
Indeed it's strange. I ran set command in cmd and I can see the variable and it's value.
Nope, not setting this variable anywhere in the file
However, it's production system and I can't have this same problem repeating everyday. So, below is the fix I used.
Let me know if you are able to investigate this any further.
Thanks,
Meet
Indeed it's strange. I ran set command in cmd and I can see the variable and it's value.
Btw: Is there a command line in your batch file similar to this?:Code: Select all
set GLOBENV_CAT_OUTDIR_ARCHIVE_GV=
Nope, not setting this variable anywhere in the file
However, it's production system and I can't have this same problem repeating everyday. So, below is the fix I used.
Code: Select all
move "%GLOBENV_CAT_OUTDIR_ARCHIVE%\catgvf01.dat" "%GLOBENV_CAT_OUTDIR_ARCHIVE%\GLOBAL VISION BACKUP\catgvf01_D_%newDate%_%TIME%.dat"
Let me know if you are able to investigate this any further.
Thanks,
Meet