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 Across DOS Sessions

Keywords: 	 DOS environment variables

Question:

I am having problems with enviroment varibles. I am creating a winbatch file to run during our NT logonscipts which works fine. The program is doing a ping and redirecting the output to a file and parsing out the "time=" part to see how fast of a connection you have. If the connection is over 50ms I would like to set an enviroment varible for the loginscript to read and exit the the loginscript so it doesn't try to load the SMS. The problem I have is when I set the enviroment varible it doesn't stay set in the logonscript DOS window. Here is my code:
RunWait("cmd.exe","/c ping -n 1 Eueud034226 >c:\pt.txt")
handle = FileOpen("c:\pt.txt","READ")
while @TRUE
	x = FileRead(handle)
	if x == "*EOF*"
		Break
	endif
	start=0
	ptime=strIndexNC(x, "time=", start, @FWDSCAN)
	If ptime == 0
		;I will put code here later
	else
		a=StrSub(x, ptime, 11)
		b=StrTrim(a)
		ns=strindexnc(b, "time=", 0, @FWDSCAN)
		ne=strindexnc(b, "ms", 0, @FWDSCAN)
		sl=StrLen(b)
		pn=strsub(b, ns+5, -1)
		pn2=strsub(pn, 1, strlen(pn)-2)
		If pn2 > 50
			Runwait("c:\s.bat", 2)
		endif
	endif
endwhile
I am sure this can be done my brain is just not working right.

Answer:

The environment variables are difficult to move across DOS sessions like that. Mostly the various DOS bat files get a copy of the environment when they start up. It need to be set by then.

I recommend a flag file.

C:\NORUNSMS.TXT
If you want to squelch SMS, just create the file, otherwise make sure it is deleted.

THen in your LOGIN.BAT file you can do an:

IF EXIST C:\NORUNSMS goto SKIPSMS
or something like that.

The environment variable does not persist across those DOS sessions.


Article ID:   W14585
Filename:   Environment Variables Across DOS Sessions.txt
File Created: 2000:07:28:14:27:42
Last Updated: 2000:07:28:14:27:42