我现在遇到这么一个问题,就是在我的项目中要通过js判断某个软件是否安装比如word,如果这个软件已经安装了就可以打开相应的文件,如果机器没有打开,则提示用户需要安装,下面是我写的代码,但是经测试后,如果操作系统不同,则注册表的地址不同,在别的系统操作会提示注册表跟路径不对,而且,我想知道怎么样才可以通过js搜索注册表,而不是
var shell = new ActiveXObject("WScript.Shell");
var pregkey="HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\DisableRegistryTools";
var sNic = shell.RegRead(pregkey);
这样的话,如果注册表路径不对,仍然报js错误,而不是会出现用户没有安装该软件的提示,请教各位大侠指点,感激不尽!<html>
<head>
</head>
<body>
<p>js打开exe程序</p>
<script language="JavaScript">
//判断是否安装某软件
function check(shellp,str) {
alert("shellp=" + shellp + " ---- str=" + str);
var shell = new ActiveXObject("WScript.Shell");
if(shellp == "notepad.exe") {
var pregkey ="HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\DisableRegistryTools";
var sNic = shell.RegRead(pregkey);
alert(sNic);
} else if(shellp == "winword.exe") {
var pregkey ="HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Office\\11.0\\Common\\InstallRoot\\Path";
var sNic = shell.RegRead(pregkey);
alert(sNic);
} else if(shellp == "ACDSee10.exe") {
var pregkey ="HKEY_LOCAL_MACHINE\\SOFTWARE\\ACD Systems\\ACDSee\\100\\InstallDir";
var sNic = shell.RegRead(pregkey);
alert(sNic);
} if (sNic==null) {
alert("用户没有安装!");
} else {
alert("用户已安装!");
shell.run(shellp+" "+str);
}
} // 打开exe程序
// function open_exe(shellp,str)
// {
// a=new ActiveXObject("wscript.shell");
// shell.run(shellp+" "+str);
// }
//重启
function cq()
{
b=new ActiveXObject("wscript.shell");
b.run("rundll32.exe")
}
</script>
<button onclick="check('notepad.exe','D:\\test_js\\test_js.txt')">打开notepad</button>
<button onclick="check('winword.exe','D:\\test_js\\test_js.doc')">打开word</button>
<button onclick="check('ACDSee10.exe','D:\\test_js\\背景.jpg')">打开Acdsee</button>
<button onclick="cq();">重启</button></body>
</html>
var shell = new ActiveXObject("WScript.Shell");
var pregkey="HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\DisableRegistryTools";
var sNic = shell.RegRead(pregkey);
这样的话,如果注册表路径不对,仍然报js错误,而不是会出现用户没有安装该软件的提示,请教各位大侠指点,感激不尽!<html>
<head>
</head>
<body>
<p>js打开exe程序</p>
<script language="JavaScript">
//判断是否安装某软件
function check(shellp,str) {
alert("shellp=" + shellp + " ---- str=" + str);
var shell = new ActiveXObject("WScript.Shell");
if(shellp == "notepad.exe") {
var pregkey ="HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\DisableRegistryTools";
var sNic = shell.RegRead(pregkey);
alert(sNic);
} else if(shellp == "winword.exe") {
var pregkey ="HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Office\\11.0\\Common\\InstallRoot\\Path";
var sNic = shell.RegRead(pregkey);
alert(sNic);
} else if(shellp == "ACDSee10.exe") {
var pregkey ="HKEY_LOCAL_MACHINE\\SOFTWARE\\ACD Systems\\ACDSee\\100\\InstallDir";
var sNic = shell.RegRead(pregkey);
alert(sNic);
} if (sNic==null) {
alert("用户没有安装!");
} else {
alert("用户已安装!");
shell.run(shellp+" "+str);
}
} // 打开exe程序
// function open_exe(shellp,str)
// {
// a=new ActiveXObject("wscript.shell");
// shell.run(shellp+" "+str);
// }
//重启
function cq()
{
b=new ActiveXObject("wscript.shell");
b.run("rundll32.exe")
}
</script>
<button onclick="check('notepad.exe','D:\\test_js\\test_js.txt')">打开notepad</button>
<button onclick="check('winword.exe','D:\\test_js\\test_js.doc')">打开word</button>
<button onclick="check('ACDSee10.exe','D:\\test_js\\背景.jpg')">打开Acdsee</button>
<button onclick="cq();">重启</button></body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body><br />
<script type="text/javascript">
/*
* author:Jena.want
* web:www.AOBODO.com
* last edit:2008.11.11
* 谨以此送给正在享受光棍节的哥们们!祝今年节日快乐!祝明年不再过此节!
*/
//<![data[
checkInstalled = function(m) {
switch(m){
case 'msn':
try {
new ActiveXObject("MSNMessenger.P4QuickLaunch");
return true;
}
catch (e) {
return false;
}
case 'skype':
try{
new ActiveXObject("Skype.Detection");
return true;
}catch(e){
return false;
}
case 'qq':
try {
new ActiveXObject("TimwpDll.TimwpCheck");
return true;
}
catch (e) {
return false;
}
}
}
//]]-->
</script>
<input type="button" value="检测有没有安装MSN" onclick="alert(checkInstalled('msn'))" />
<input type="button" value="检测有没有安装QQ" onclick="alert(checkInstalled('qq'))" />
<input type="button" value="检测有没有安装SKYPE" onclick="alert(checkInstalled('skype'))" />
</body><br />
</html><br />
JS判断客户端是否安装了MSN,Skype,QQ软件
楼主用activeX插件只能再ie下运行
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD> <BODY>
<script language="JavaScript">
//判断是否安装某软件
function checkInstalled(shellp,str) {
var shell = new ActiveXObject("WScript.Shell");
switch(shellp){
case 'ACDSee':
try {
new ActiveXObject("ACDSee10.Application");
//如果存在,则运行ACDSee
shell.run(shellp+" "+str);
return true;
} catch (e) {
alert("请安装ACDSee10!");
return false;
}
case 'notepad':
try{
new ActiveXObject("notepad.Application");
//如果存在,则运行记事本
shell.run(shellp+" "+str);
return true;
}catch(e){
alert("请安装记事本!");
return false;
}
case 'winword':
try {
new ActiveXObject("Word.Application");
//如果存在,则运行word
shell.run(shellp+" "+str);
return true;
}
catch (e) {
alert("请安装word!");
return false;
}
}
}
</script> <button onclick="checkInstalled('notepad','D:\\test_js\\test_js.txt')">打开notepad</button>
<button onclick="checkInstalled('winword','D:\\test_js\\test_js.doc')">打开word</button>
<button onclick="checkInstalled('ACDSee','D:\\test_js\\背景.jpg')">打开Acdsee</button>
</BODY>
</HTML>现在的问题是,word和excel可以用new ActiveXObject("Word.Application");来判断,但是其它软件那,比如机器本身的记事本,new ActiveXObject("notepad.Application");这样是不可以的, new ActiveXObject("ACDSee10.Application");也是不可行的,其余的软件我该怎么来new ActiveXObject("")??????????