gpt4 book ai didi

java - 使用 bat 文件命令更改 Java 控制面板设置

转载 作者:行者123 更新时间:2023-11-30 08:00:41 25 4
gpt4 key购买 nike

我需要自动编辑以下内容:

Java Control Panel --> Advanced Tab --> Advanced Security Settings

使用批处理文件,如何可行? Windows 注册表编辑命令是否可用?经过分析,我发现要更改deployment.properties 文件才能执行此操作,是要这样做吗?

最佳答案

这是一个我用来打开 Java CPL 小程序的脚本,导航到“安全”选项卡并将站点添加到异常(exception),然后导航到“高级”选项卡并切换“使用 SSL 2.0 兼容的 ClientHello 格式”复选框。它通过 Jscript 中的 WshShell.SendKeys() 广泛使用键盘导航来实现此目的。它对于我的应用程序来说是高度特定的,因此您需要修改它以适应您自己的邪恶计划。 See this page获取字符列表及其等效的 SendKeys。

@if (@CodeSection == @Batch) @then

:: Save this as a .bat file.
:: begin batch portion

@echo off
setlocal enabledelayedexpansion

:: find newest javacpl.cpl
<NUL set /P "=Searching for Java Control Panel applet... "
for /f "delims=" %%I in ('dir /s /b "%PROGRAMFILES(x86)%\java\*javacpl.cpl"') do (
set "javacpl_test=%%I"
for /f "tokens=2 delims=.=" %%a in ('wmic datafile where "name='!javacpl_test:\=\\!'" get CreationDate /format:list ^| find "="') do (
set "created_test=%%a"
set "created_test=!created_test:~0,-4!"
)
if not defined created (
set "javacpl=!javacpl_test!"
set "created=!created_test!"
) else if !created_test! gtr !created! (
set "javacpl=!javacpl_test!"
set "created=!created_test!"
)
)

if not defined javacpl (
echo Not found. Is Java installed?
goto :EOF
) else (
setlocal disabledelayedexpansion
echo Found. Relax and enjoy the show!
endlocal
)

:: relaunch self with JScript engine
cscript /nologo /e:JScript "%~f0" "%javacpl%" "%cmdcmdline%"

:: end batch portion
goto :EOF

@end // end batch / begin JScript chimera

// launch Java control panel applet
var oShell = WSH.CreateObject('wscript.shell'),
cmd = oShell.Exec('cmd /c control "' + WSH.Arguments(0) + '"');

// function introduces a delay to slow down typing to 20 chars / sec
function kbd(arr) {
for (var i=0; i<arr.length; i++) {
oShell.SendKeys(arr[i]);
WSH.Sleep(50);
}
}

// wait for window to gain focus
while (!oShell.AppActivate('Java Control Panel')) { WSH.Sleep(500) }

// navigate to the fourth tab and activate "Edit Sites" button
kbd(['{RIGHT}','{RIGHT}','{RIGHT}','%s']);

// wait for exception list window to focus
while (!oShell.AppActivate('Exception Site List')) { WSH.Sleep(500) }

// activate "Add" button (has default focus -- exhibited weird behavior when trying to send Alt+a)
oShell.SendKeys(' ');

WSH.Sleep(500);

kbd('https://host.domain.tld/~'.split(''));

// Store added entry (Ctrl+Enter simulates OK button)
oShell.SendKeys('^~');

// wait for Java Control Panel to regain focus
while (!oShell.AppActivate('Java Control Panel')) { WSH.Sleep(500) }

// move focus within cpl window back to tab row
kbd(['{TAB}','{TAB}','{TAB}','{TAB}','{TAB}']);

// navigate to next tab, focus listbox, enter first few letters of "Advanced Security Settings"
// to scroll down, select the fourth check box and activate it, then Ctrl+Enter to save.
kbd(['{RIGHT}','{TAB}','a','d','v','{DOWN}','{DOWN}','{DOWN}','{DOWN}',' ','^~']);

// if double-clicked, delete self
if (!/^cmd \/c/i.test(WSH.Arguments(1))) {
WSH.Echo("Done. I guess everything went OK. Who knows? *shrug*");
} else {
var FSO = new ActiveXObject('scripting.filesystemobject');
// FSO.DeleteFile(WSH.ScriptFullName);
WSH.Echo("Pretending to delete self... done. That was fun.");
}

关于java - 使用 bat 文件命令更改 Java 控制面板设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31964376/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com