在浏览器中点击按钮打开一个客户端

1、浏览器若为IE:

function doClientStatus(requisitionNum,runNum,status){
	//startMinaClient(requisitionNum,runNum,status);//向服务器传参
	window.oldOnError = window.onerror;
	window.onerror = function (err) {
		if (err.indexOf('utomation') != -1){
			alert("命令已经被用户禁止!请在ie选项的安全模块将此网站加入<可信站点>并<启动>该自定义级别中的'对未标记为可安全执行脚本的ActiveX控件初始化并执行脚本'选项,之后<刷新>页面");
			return true;
		}else
			return false;
	};

	var command = 'D:\\ACME\\win32_vc2008_desktop\\LogMonitor.exe';

//	command = command + ' 10.11.11.19 1234 -C';
	command = command + ' <%=serverIP%> <%=clientPORT%> -C';
	var wsh = new ActiveXObject('WScript.Shell');    //谷歌浏览器不支持
	if (wsh) {
		wsh.Run(command);
	}
	wsh = null;
	window.onerror = window.oldOnError;
}

2、若浏览器为谷歌:

以上方法无用,需要写注册表。

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ACME.1]
@="URL:ACME.1 Protocol Handler"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\ACME.1\shell]
[HKEY_CLASSES_ROOT\ACME.1\shell\open]
[HKEY_CLASSES_ROOT\ACME.1\shell\open\command]
@="D:\ACME\win32_vc2008_desktop\LogMonitor.exe 11.111.11.11 8888 -C"

说明:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ACME.1]                    //ACME.1名称自定义,HKEY_CLASSES_ROOT根目录下
@="URL:ACME.1 Protocol Handler"               //数据(ACME.1下)
"URL Protocol"=""                             //名称(ACME.1下)
[HKEY_CLASSES_ROOT\ACME.1\shell]              //只建立目录
[HKEY_CLASSES_ROOT\ACME.1\shell\open]         //只建立目录
[HKEY_CLASSES_ROOT\ACME.1\shell\open\command] //command下写入数据(@=后面的是数据)
@="D:\ACME\win32_vc2008_desktop\LogMonitor.exe 11.111.11.11 8888 -C"

写入注册表之后,直接利用

html页面中:

js中:
window.location.href = "ACME.1:\\"

 

你可能感兴趣的:(在浏览器中点击按钮打开一个客户端)