简体   繁体   中英

Editing Deployment.properties file using bat file

My application needs to set Use TLS1.2 and Use TLS1.1 properties in Java Control Panel --->Advanced tab--->Advanced Settings to false .

It can be acheived by editing deployment.properties file , how to edit this using a bat file , since this has to be performed in each and every client machine.

Not completely tested:

@echo off

:: disabled strings
::deployment.security.TLSv1.2=false
::deployment.security.TLSv1.1=false
::deployment.security.TLSv1=false


set "deplProps=%userprofile%\AppData\LocalLow\Sun\Java\Deployment\security\deployment.properties"


:TLSv1
rem if if the property is disabled and the line needs to be stripped
find /i "deployment.security.TLSv1=false" "%deplProps%" >nul 2>nul && (
    findstr /i /v "deployment.security.TLSv1=false" "%deplProps%" > "%temp%\deployment.properties"
    (echo(deployment.security.TLSv1=true)>>"%temp%\deployment.properties"
    move /y "%temp%\deployment.properties" "%deplProps%"
)
rem if there's no explicit disable property  
find /i "deployment.security.TLSv1=false" "%deplProps%" >nul 2>nul || (
    (echo(deployment.security.TLSv1=true)>>"%deplProps%"
)


:TLSv1.2

find /i "deployment.security.TLSv1.2=false" "%deplProps%" >nul 2>nul && (
    findstr /i /v "deployment.security.TLSv1.2=false" "%deplProps%" > "%temp%\deployment.properties"
    (echo(deployment.security.TLSv1.2=true)>>"%temp%\deployment.properties"
    move /y "%temp%\deployment.properties" "%deplProps%"
)

find /i "deployment.security.TLSv1.2=false" "%deplProps%" >nul 2>nul || (
    (echo(deployment.security.TLSv1.2=true)>>"%deplProps%"
)


:TLSv1.1
find /i "deployment.security.TLSv1.1=false" "%deplProps%" >nul 2>nul && (
    findstr /i /v "deployment.security.TLSv1.1=false" "%deplProps%" > "%temp%\deployment.properties"
    (echo(deployment.security.TLSv1.1=true)>>"%temp%\deployment.properties"
    move /y "%temp%\deployment.properties" "%deplProps%"
)

find /i "deployment.security.TLSv1.1=false" "%deplProps%" >nul 2>nul || (
    (echo(deployment.security.TLSv1.1=true)>>"%deplProps%"
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM