天天看點

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

但是遇到前六位重名的問題,我還沒有找到解決的方法