上传后如何在服务器端执行批处理文件:C# [英] How to execute the batch file on the server side after uploading it: C#

查看:64
本文介绍了上传后如何在服务器端执行批处理文件:C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#(FtpWebRequest)中的FTP将批处理文件传输(上传)到服务器。批处理文件有一些命令。我的要求是将批处理文件传输到服务器(我能够做到)并执行该批处理文件。



如何在批处理中执行命令从我的客户端在服务器上的文件?我可以使用Process.Start()方法或rsh ??哪个是更好的方法,并且可以赞赏这个例子的链接。



谢谢,

Nayan

I transfer (upload) the batch file to the server using FTP in C# (FtpWebRequest). Batch files have some commands. My requirement is to transfer the batch file to the server (which I am able to do) and execute that batch file.

How do I execute the commands in the batch file on the server from my client? Can I use Process.Start() approach or rsh?? Which is better way of doing it and a link to the example would be appreciated.

Thanks,
Nayan

推荐答案

在这里要非常小心 - 只是因为批处理文件物理存储在服务器上并不意味着你正在执行该服务器上的命令!



如果你谷歌为执行远程命令窗口你会得到几个链接来实现这个...这里有一些...



我个人使用sysinternals的psexec - http:/ /technet.microsoft.com/en-us/sysinternals/bb897553.aspx [ ^ ]



但我知道有些人使用过WMIC - http://technet.microsoft.com/en-us/library/bb742610.aspx [ ^ ]



和其他人更喜欢Powershell - http://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/ [ ^ ]
Be very careful here - just because the batch file is physically stored on the server does not mean that you are executing the commands on that server!

If you google for execute remote command windows you will get several links to ways of achieving this... here''s a few ...

Personally I use psexec from sysinternals - http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx[^]

but I know some people have used WMIC - http://technet.microsoft.com/en-us/library/bb742610.aspx[^]

and others prefer Powershell - http://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/[^]


这篇关于上传后如何在服务器端执行批处理文件:C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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