I have a batch script that uses the Call function, but I'm noticing different behavior when it's ran on my Windows 7 machine vs my Windows 10 machine. I wasn't able to find much on this issue specifically for differences between Windows versions.
The script is simply:
@echo off
chdir /D "%~dp0"
call "C:\Users\username\desktop\temp\batch.bat" >Test.txt
pause
and within the batch.bat, there is a single line of java:
@echo off
cd /D "%~dp0"
java -classpath "../jars/*" com.scraper_program.cui.Main show --log="../conf/log.settings"
On Windows 7, this correctly outputs the text from the call to java into the file Test.txt; however on Windows 10, it opens the java portion in a new window and fails to re-direct to the text file.
The new window opened has a 'java' icon in the upper left corner, so it looks like Windows10 may be treating the Java portion differently for some reason.
Everything about the location of the script and variables are identical between the two machines. Is there anyway to make the script output to the text file in windows 10 like it does in windows 7?
Edit:
The problem is with the java console. This being a batch file and the code don't matter so all of the above is basically worthless information :(
The issue is reproducible by simply typing in "java -help" into the command line. On the windows 7 machine, it outputs the help text directly to the console while on my windows 10 machine it opens a new window, executes, and closes immediately. I found another post with the same issue here: Java execution pops a new window and immediately disappears
However there wasn't a resolution to it.
Drag and dropping the java.exe file directly into the console in order to provide the full path to the exe gives the same result - it flashes on screen briefly and closes.
I've also verified that the Java settings in control panel are identical between the two systems and that the same environment paths to Java.exe are the same.
Edit 2:
By request, here are my environment variables.
Output from set Path:
Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Gpg4win\..\GnuPG\bin;C:\Drivers
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Output from where Java:
C:\ProgramData\Oracle\Java\javapath\java.exe