最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Run a bat-file from php js - Stack Overflow

programmeradmin6浏览0评论

I've tried to implement this code but unfortunately Nothing Happens when I click the button: Play example.

Here's my code:

<script language="Javascript" type="text/javascript"> 
var wshShell = new ActiveXObject('WScript.Shell');
</script>

My PHP code includes:

echo "<input id='btnExplore' type='button' value='Play example' 
onclick='wshShell.Run('C:\\tools\\Play Example.bat');";

The Clipboard holds the correct adress to the source to play, like C:\tools\example.avi

I really would appreciate a comment from any of you.

Cheers, Torbjorn

I've tried to implement this code but unfortunately Nothing Happens when I click the button: Play example.

Here's my code:

<script language="Javascript" type="text/javascript"> 
var wshShell = new ActiveXObject('WScript.Shell');
</script>

My PHP code includes:

echo "<input id='btnExplore' type='button' value='Play example' 
onclick='wshShell.Run('C:\\tools\\Play Example.bat');";

The Clipboard holds the correct adress to the source to play, like C:\tools\example.avi

I really would appreciate a comment from any of you.

Cheers, Torbjorn

Share Improve this question asked Mar 20 at 22:24 user3437733user3437733 13 bronze badges 3
  • 1 When you write PHP that unconditionally sends a static of HTML and JS to the browser, the PHP is entirely irrelevant. – Quentin Commented Mar 20 at 23:00
  • 1 Are you testing this in a browser that you know supports ActiveX? – Quentin Commented Mar 20 at 23:01
  • "Nothing Happens when I click the button" — Nothing? Have you looked at the console in the browser's developer tools to see if there are any error messages displayed? – Quentin Commented Mar 21 at 16:40
Add a comment  | 

1 Answer 1

Reset to default 0

ActiveXObject is very Microsoft-specific and only available in older, pre-Edge browsers. If it is, it's disabled by default due to security concerns. Imagine you load a website and it executes some command on the command line (e.g., delete all files).

发布评论

评论列表(0)

  1. 暂无评论