天天看点

jsp页面利用js activexobject调用客户机exe文件

<SCRIPT language=JavaScript>

function Run(strPath)

{

try

{

var objShell = new ActiveXObject("wscript.shell");

objShell.Run(strPath);

objShell = null;

//alert("ok");

}

catch(e)

{

alert('找不到文件"'+strPath+'"(或它的组件之一)。请确定路径和文件名是否正确.')

}

}

</SCRIPT>

<span style="color:red;font-size:22;" mce_style="color:red;font-size:22;">恭喜您,登录成功!</span>

<body background="<%=pth%>/image/line.gif">

<a href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" mce_href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" οnclick="Run('d://norton//PMagic.exe')">魔术师</a>

</body>

但是如果路径中包含空格就会出现问题,会找不到要执行的文件

如:Program Files

wep app 22

遇到这样的情况就是取前六个字母,然后加~1

如:Progra~1

wepapp~1

但是遇到前六位重名的问题,我还没有找到解决的方法