简体   繁体   English

从远程计算机执行批处理脚本

[英]execute batch script from a remote computer

Computer A is on network and is our main server.计算机 A 在网络上,是我们的主要服务器。 Currently, we have a windows batch script which is stored in c:\scripts folder.目前,我们有一个 Windows 批处理脚本,它存储在 c:\scripts 文件夹中。 This batch script accepts 2 string parameters (eg. TEST ABCD)此批处理脚本接受 2 个字符串参数(例如 TEST ABCD)

Currently, I go to this server, fireup the command prompt and then execute the script.目前,我去这台服务器,启动命令提示符,然后执行脚本。 eg:例如:

script.bat TEST ABCD

I want to execute this script over the LAN from ANY computer.我想从任何计算机通过 LAN 执行此脚本。 What is the best way to call the batch script on server A from any computer?从任何计算机调用服务器 A 上的批处理脚本的最佳方法是什么?

I have never tried this, so have little to no clue.我从来没有试过这个,所以几乎没有线索。 I tried searching stackOverflow, but, did not get any concrete answers.我尝试搜索stackOverflow,但没有得到任何具体答案。 Any help is appreciated.任何帮助表示赞赏。

You could use Telnet.你可以使用 Telnet。 Windows has built-in telnet server support and a telnet client . Windows 具有内置的远程登录服务器支持远程登录客户端

You would set up the telnet server on the server and log in from the client.您将在服务器上设置 telnet 服务器并从客户端登录。 This will be much like a command prompt would be on the server.这很像服务器上的命令提示符。

Update:更新:

Another alternative would be to set up a web server (IIS is built-in in windows, but any web server will do) and set up a CGI script that will run your batch file.另一种选择是设置一个 Web 服务器(IIS 内置在 Windows 中,但任何 Web 服务器都可以)并设置一个运行批处理文件的 CGI 脚本。 You could even have a page that lets your team enter/change the parameters to the script.您甚至可以拥有一个页面,让您的团队输入/更改脚本的参数。

I think the details to this CGI script are worth a followup question though.不过,我认为这个 CGI 脚本的细节值得提出后续问题。

If you have read/write access to the server:如果您对服务器具有读/写访问权限:

pushd "\\server\batch file folder\"
script.bat TEST ABCD
popd

This can be easily done from command prompt or bat file wmic /node:MachineName> process call create "cmd.exe c:\Test\script.bat TEST ABCD"这可以从命令提示符或 bat 文件 wmic /node:MachineName> process call create "cmd.exe c:\Test\script.bat TEST ABCD" 轻松完成

For help wmic /?寻求帮助 wmic /?

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

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