I have the following batch file that will check and compare two variables, however, it fails when one of the variables are blank.. any ideas how to handle a case where LocalVersion can be blank aka the file version.txt does not exist.
test.bat:
for /f "tokens=1 " %%a in ('%Tools%\cat.exe version.txt') do set LocalVersion=%%a
for /f "tokens=1 " %%a in ('%Tools%\cat.exe \\UNC_Share\version.txt') do set RemoteVersion=%%a
echo LocalVersion %LocalVersion%
echo RemoteVersion %RemoteVersion%
if %LocalVersion% LSS %RemoteVersion% ( goto :skip )
if %LocalVersion% GTR %RemoteVersion% ( goto :Update)
Results:
c:\test.bat
No such file or directory
LocalVersion
RemoteVersion 4.0.1
4.0.1 was unexpected at this time.
Aucun commentaire:
Enregistrer un commentaire