batch file - Correct syntax of the variable "Set" for program execution and error log -
i creating unattended batch file programs have problems correct detection of variable run properly.
set installjava=java\jre-8u111-windows-i586.exe /s auto_update=0 web_analytics=0 reboot=0 sponsors=0 removeoutofdatejres=1 || echo "%time% java install did not complete." >> "%temp%\error.txt"
what syntax should used run installation file , error log program?
you use:
set "installjava=java\jre-8u111-windows-i586.exe /s auto_update=0 web_analytics=0 reboot=0 sponsors=0 removeoutofdatejres=1 || echo %time% java install did not complete.>> "%temp%\error.txt""
the environment variable installjava
must referenced immediate expansion, i.e. %installjava%
work command line execution.
see answer on why no string output 'echo %var%' after using 'set var = text' on command line? why using syntax set "variable=value"
necessary here because of operators ||
, >>
interpreted literal characters on assigning command line environment variable.
the echo without double quotes these double quotes written error log file. there no space left of redirection operator >>
error message written error log file without trailing space character.
Comments
Post a Comment