New
#1
bizarre and inconsistent behavior in batch script
I have a file called tokens.txt. It is a utf-8 text file that contains a number for lines with name=value
It is used extensively in a script I have written and works 99 times out of 100. Every now and then I come across an issue I haven't been able to solve in the last 3 years.
values are like;
The vpn line I have just added. It won't work. I get no result. The batch code isCode:tanya=123456 tanya_vpn=au657 tanya_cache=f:\users\tanya\firefox test=abcdef fred=12345-12345-12345-12345
%tfile% = Tokens.txt.Code:for /F "Usebackq Tokens=1* delims==" %%a in ("%BasePath%\%tfile%") do IF /I "%%a"=="%USERNAME%_vpn" set VPNserv=%%b
%basepath%=I:\PostInstall
It's clearly finding the file because it's cycling through each line of the file.
Yet, this line works;
as does this;Code:for /F "Usebackq Tokens=1* delims==" %%a in ("%BasePath%\%tFile%") do IF /I "%%a"=="%USERNAME%" set uWord=%%b
As I watch the execution of the script I see this line;Code:for /F "Usebackq Tokens=1* delims==" %%a in ("%BasePath%\%tFile%") do IF /I "%%a"=="%USERNAME%_cache" set MozCache=%%b
Windows does not consider this a match and does not set the VPNServ variable.Code:IF /I "Tanya_vpn" == "Tanya_vpn" set VPNserv=au657
I've deleted the line and retyped it, in case there was some obscure non-printable character in there. I've tried using a dash instead of an underscore, but the cache entry works. I've put it as the first line and the last line in the file. Nothing works.
It's bizarre. I can't figure out what's causing the problem.