1.ใช้ object document
2.สร้าง object ด้วย WScript.shell แล้ว เรียกใช้ method run() ของ WScript.shell
ตัวอย่างแบบ แรก
Code:
<SCRIPT>
function runpro_onclient() {
// document.location.href = "D:/cmd.php"; // ตัวอย่างการ รันไฟล์
document.location.href = "D:/WINDOWS/NOTEPAD.exe"; // ตัวอย่างรันโปแกรม
}
</SCRIPT>
<body onload="runpro_onclient()">
แบบที่ 2
Code:
<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
function runpro_onclient() {
var myshell = new ActiveXObject( "WScript.shell" );
myshell.run( '"c:/program files/microsoft
office/office11/excel.exe" "c:/yourfilename.xls"', 1, true );
}
</SCRIPT>
<!------------------------------------------------------------------->
<INPUT
TYPE="button"
NAME="button1"
VALUE="คลิกที่นี่เพื่อ Run Excel และกำหนดไฟล์ในการไปพร้อมกันด้วย"
ONCLICK="runpro_onclient()"
>
</INPUT>