如何使用C#代码运行远程计算机的批处理文件 [英] how to run a batch file of the remote machine using c# code

查看:97
本文介绍了如何使用C#代码运行远程计算机的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在共享的远程处理中有一个批处理文件.如何使用c#代码调用要在远程计算机的命令提示符下运行的批处理文件.

谢谢您提前.

I have a batch file on the remote maching which is shared .how can i call the batch file to be run at the command promt of the remote machine using c# code.

Thanks is advance

推荐答案



您无法从计算机执行远程批处理文件.即使您共享了该文件,它也会在您的计算机上执行,而不是在远程计算机上运行. (这就是我的想法)

但是我发现此讨论 [ ^ ].请检查是否适合您.



您可以在该计算机上创建任务计划程序以运行批处理文件(如果有访问权限).然后使用此 [ ^ ]命令.

希望这对您有帮助,

谢谢
-Amit Gajjar.
Hi,

You can not execute remote batch file from your computer. even if you shared that file it will execute on your computer instead running on the remote computer. (this is what i was thinking)

But i found this discussion[^]. please check if it works for you.

OR

You can Create Task Scheduler on that computer to run batch file(if you have access). and then execute scheduler remotely using this[^] commands.

Hope this helps you,

Thanks
-Amit Gajjar.


使用ASP.NET,有一台运行Web服务器(IIS)的服务器计算机,以及一台在浏览器中查看页面的客户端计算机(例如Internet Explorer).您的远程"机器是哪一台?
如果是服务器,那么事情很简单:在文件后面的代码中,使用Process.Start(batchfile.bat)调用该批处理文件-无需共享,但是Web服务器必须能够访问和执行文件!
如果是客户,事情就会变得复杂.您可以在客户端上注册新协议,然后在页面中嵌入一个链接,单击该链接将执行该批处理文件.
With ASP.NET, there is a server computer on which the web server (IIS) is running, and a client machine on which the page is viewed in a browser (e.g. Internet Explorer). Which one is your "remote" machine?
If it is the server, the thing is simple: in your code behind file, call that batch file with a Process.Start(batchfile.bat) - no need for sharing, but the web server must be able to access and execute the file!
If it is the client, things become complicated. You could register a new protocol on the client, and then embed a link in your page, which - after clicking it - will have the batchfile executed.


这篇关于如何使用C#代码运行远程计算机的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆