На IE, добавить эта функция под функцией runApp (что) {} в теге
// A fucntion to run any cmd command
function runApp(which) {
// Using Windows Script Host Shell ActiveX to run cmd commands
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("cmd /c " + which);
}
// A function to set the Optimal Internet Options
function setOptimalInternetOptionsForDevelopers() {
// 1- Settings: Don't show the Dialog box "An ActiveX control on this page might be unsafe to interact
// with other parts of the page. Do you want to allow this interaction?"
// Refer to http://stackoverflow.com/questions/894369/an-activex-control-on-this-page-might-be-unsafe
var registryKey = '"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\0"';
// 1201 Value means: Initialize and script ActiveX controls not marked as safe
// Refer to http://support.microsoft.com/kb/833633
var regValName = "1201";
// Value of 1 will show the Dialog box (Default Value)
// Value of 0 will not show that dialog box (we need to set this value)
var regValue = "0";
runApp('reg add ' + registryKey + ' /v ' + regValName + ' /t REG_DWORD /d ' + regValue + ' /f');
// 2- Internet Options => Advanced tab => Check "Allow active content to run in files on My Computer*
// Default (1) not checked
// we need to change it to (0) to allow this option
// Refer to http://support.microsoft.com/kb/2002093
registryKey = '"HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_LOCALMACHINE_LOCKDOWN"';
regValName = "iexplore.exe";
regValue = "0";
runApp('reg add ' + registryKey + ' /v ' + regValName + ' /t REG_DWORD /d ' + regValue + ' /f');
}
Now, all you have to do is launch it in the <body> section before any script is needed to be triggered.
For Example:
<body>
<script type="text/javascript">
setOptimalInternetOptionsForDevelopers();
// the rest of the content
</script>
</body>
Примечание: первый раз, когда вы запустите эту страницу, это побудит сообщение «Разрешить заблокированное содержимое», просто нажмите на него, чтобы принять его , Затем нажмите «Да» в следующем диалоговом окне, которое появляется. Диалоговое окно «Элемент управления ActiveX на этой странице может быть небезопасным для взаимодействия с другими частями страницы. Вы хотите разрешить это взаимодействие?» Это произойдет только при первом запуске страницы. В следующий раз все будет работать как шарм без сообщений. Конечно, вы можете изменить мою функцию runApp (which) {} на любое другое имя для работы. Хотя приведенный выше сценарий будет работать для IE, я не думаю, что он будет работать для Chrome или Firefox.
Вы не можете использовать _ActiveX_ материал в браузерах, отличных от IE, поэтому попробовать это в _Chrome_ не получается. В IE необходимо активировать _ActiveX_ ** **. http://stackoverflow.com/questions/2138002/how-to-config-ie-to-make-wscript-shell-work –
Wow '' тег ... везде, где у вас есть этот пример, найдите другой источник. – Pointy
Для локальных файлов URL-адрес файла имеет три слэша. например 'file: ///' – mshsayem