You could 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 be referenced with immediate expansion, i.e. with %installjava%
to really work as command line for execution.
See the answer on Why is no string output with 'echo %var%' after using 'set var = text' on command line? why using the syntax set "variable=value"
which is necessary here because of the operators ||
and >>
to be interpreted as literal characters on assigning the command line to the environment variable.
The ECHO is without double quotes as these double quotes would be also written into the error log file. Also there is no space left of redirection operator >>
to get the error message written into the error log file without a trailing space character.