I'm running tests on IE11. To do it I made some changes in registry. I have created new key 'FEATURE_BFCACHE' in folder 'FeatureControl'. Then I have added new 'DWord' value to 'FEATURE_BFCACHE' named 'iexplore.exe' with value '0'. I have done it manually. But now try to do it from my program. I wrote this but it does not work.
String[] c = new String[]{"reg", "add", "\"HKLM\\Software\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BFCACHE\"",
"/v", "\"iexplore.exe\"", "/t", "REG_DWORD", d", "0", "/f"};
try {
new ProcessBuilder(c).start();
} catch (IOException e) {
e.printStackTrace();
}
After some changes I have line that properly works in command line reg add "HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BFCACHE1" /t REG_DWORD /v iexplore.exe /d 0 /f
but does not work from java code
System.out.println("Creating new folder");
String[] c = new String[]{"reg", "add", "\"HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BFCACHE1\"",
"/t", "REG_DWORD", "/v", "iexplore.exe", "/d", "0", "/f"};
try {
new ProcessBuilder(c).start();
} catch (IOException e) {
e.printStackTrace();
}
Maybe to execute this command I need run as administrator?
Quoting strings is only needed when you run a command in a cmd promt or pass it as a single String, when you use a String array with a ProcessBuilder the quote characters will be passed to the called program as literal quote characters.
Try:
String[] c = new String[]{"reg", "add", "HKLM\\Software\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BFCACHE",
"/v", "iexplore.exe", "/t", "REG_DWORD", "/d", "0", "/f"};
修改注册表,我们需要以管理员身份执行命令行,因此,如果我以管理员身份打开IntelliJ Idea,它将起作用
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.