简体   繁体   English

如何在远程系统上执行批处理文件

[英]How to execute a batch file on a remote system

I have a java web app running on a server. 我在服务器上运行了一个Java Web应用程序。 I will click a button on the UI on the server It should invoke the batch file on the client machine and execute it on the client. 我将在服务器上的UI上单击一个按钮。它应该在客户端计算机上调用批处理文件并在客户端上执行它。 Please suggest me how to go on doing it? 请建议我该怎么做?

If you're talking about a web app and it involves a browser as a client, then you cannot invoke a script on every client machine (I mean, you can do it in Windows, but not Linux). 如果您要谈论的是Web应用程序,并且它涉及到作为客户端的浏览器,那么您就不能在每台客户端计算机上调用脚本(我的意思是,您可以在Windows中执行脚本,但不能在Linux中执行脚本)。 Javascript is a client scripting language and runs in a sand-boxed environment often inside a web browser which prevents it from accessing resources on the computer. Javascript是一种客户端脚本语言,通常在Web浏览器内部的沙盒环境中运行,这会阻止Javascript访问计算机上的资源。 Nevertheless in Windows, you probably could do this: 不过,在Windows中,您可能可以执行以下操作:

var cmdshell = WScript.CreateObject("WScript.Shell");
cmdshell.Run("the command to run a batch script goes here");

Check this for more details. 检查以获取更多详细信息。

But in Linux, I haven't seen a way to do it since the environment is different altogether. 但是在Linux中,由于环境完全不同,所以我还没有找到实现此目的的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM