Which Batch Processing experts can modify it?
Directly pass the value without writing it into the text
It feels more convenient @ echo off
For % I in (c d e f g h) Do (
DIR/S/B % I:/jdk1. *> E:/file.txt
)
For/F "delims =" % s in (E:/file.txt) Do (
@ Echo % s
If exist % S/bin/java.exe (
@ Echo JDK installation directory: % s
@ Echo java_home = % s
@ Reg Add "HKEY_LOCAL_MACHINE/system/controlset001/control/Session Manager/environment"/V java_home/T REG_SZ/D "% s"/F
@ Reg Add "HKEY_LOCAL_MACHINE/system/controlset001/control/Session Manager/environment"/V classpath/T REG_SZ/D "% S/lib/*. Jar"/F
@ Reg Add "HKEY_LOCAL_MACHINE/system/controlset001/control/Session Manager/environment"/V path/T REG_SZ/D "% S/bin"/F
@ Echo on
@ Echo Java 2 SDK environment parameters are set and exit normally.
@ Echo off
Pause
)
)
@ Del E:/file.txt
If it cannot be set automatically
Replace % java_home % with % S.