方案一 :
通过IE浏览器自带的ActiveX控件打开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>open exe</title> <script type="text/javascript"> function run(strPath){ var objShell = new ActiveXObject("wscript.shell"); objShell.Run(strPath); objShell = null; } //注意路径中必须使用/ ,而不能使用 function open(){ run("D:/qbsoft/QBRecords.exe"); } </script> </head> <body> <a href="javascript:open()">open exe</a> </body> </html>
方案二:
创建QBRecord.reg (编码为unicode)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOTQBRecords]
@="URL:QBRecords"
"URL Protocol"=""
[HKEY_CLASSES_ROOTQBRecordsDefaultIcon]
@="D:\qbsoft\QBRecords.exe"
[HKEY_CLASSES_ROOTQBRecordsshell]
[HKEY_CLASSES_ROOTQBRecordsshellopen]
[HKEY_CLASSES_ROOTQBRecordsshellopencommand]
@=""D:\qbsoft\QBRecords.exe" "
注:
若需向exe传递参数,可以直接传递也可以用中间文件将注册表传入的参数进行转换 ,
[HKEY_CLASSES_ROOTQBRecordsshellopencommand] @=""D:\qbsoft\QBRecords.bat" "%1" "
或
[HKEY_CLASSES_ROOTQBRecordsshellopencommand]
@=""D:\qbsoft\QBRecords.exe" "%1" "
其中 QBRecords.bat 内容示例如下
call QBRecord.exe -devextensions -command -username=%1 -password=mangaer -Xms512m -Xmn512m -Xmx1024m pause
网页调用
<a href="QBRecords://">open reg</a>