java - 使用 bat 文件编辑 Deployment.properties 文件

标签 java batch-file ssl control-panel

我的应用程序需要在 Java 控制面板--->高级选项卡--->高级设置中将 Use TLS1.2 和 Use TLS1.1 属性设置为 false。

它可以通过编辑 deployment.properties 文件来实现,如何使用 bat 文件编辑它,因为这必须在每台客户端计算机上执行。

最佳答案

未完全测试:

@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%"
)

关于java - 使用 bat 文件编辑 Deployment.properties 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32005012/

相关文章:

powershell - 使用批处理/powershell 脚本设置自定义行分隔符

通过 SSL https 连接的 Laravel IO Socket 和 redis

java - 如何使用 Java 应用程序为我的 AppEngine 激活 SSL?

java - for 循环如何将文本放入 3 个 JTextArea

java劫持套接字可能吗?

windows-7 - DOS 批处理 : Getting partial file names

command-line - cURL 命令失败

ssl - 如何解决 "error:1408F10B:SSL routines:ssl3_get_record:wrong version number"?

java - 如何保存ThreadPoolExecutor的队列以便重启后可以恢复?

Java:数组中交替 boolean 值