asp.net:远程批处理文件执行(性能问题) [英] asp.net : Remote batch file execution (Performance issue)

查看:167
本文介绍了asp.net:远程批处理文件执行(性能问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题之前已经问过几次了.我正在使用网络应用程序,因此需要在远程计算机上执行批处理文件.
我尝试了两种方法:psexec和WMI,并且它们都起作用,但是它们都需要很长时间才能获得与远程计算机的连接(5-10秒)……!!!我想知道是否可以做些什么来提高性能(在WMI的情况下),或者是我还不知道的第三种方法……
在此先谢谢您

I know this question has been asked several times before. I’m working on a web application, and I need to execute a batch file on a remote machine.
I`v tried two approaches: psexec and WMI, and they worked, but both of them take a long time to acquire a connection to the remote machine (5-10 seconds) … !!! I wonder if there’s something I can do to enhance performance (in case of WMI), or maybe a third approach that i`m not aware of, yet…
thanks in advance

推荐答案

我的批处理文件(在远程服务器上)调用了一个应用程序,该应用程序从AD中提取用户信息并将其写入.txt文件...

在我的Web应用程序中,我习惯于遵循以下代码来执行该批处理文件.

< pre lang ="c#"> ConnectionOptions options = new ConnectionOptions();
options.Username =用户名;
options.Password =密码;
options.Authority =权限;
ManagementScope范围=新的ManagementScope("\\\\ remoteServerIP \\ root \\ cimv2",选项);
scope.Connect();

ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath =新的ManagementPath("Win32_Process");
ManagementClass processClass =新的ManagementClass(s​​cope,managementPath,objectGetOptions);
字符串sBatFile ="\\\\ remoteServerIP \\ c
my batch file (on the remote server) calls an application that extracts users information from AD and writes it to a .txt file...

In my web application i used to following code to execute that batch file.


<pre lang="c#">ConnectionOptions options = new ConnectionOptions();
options.Username = username;
options.Password = password;
options.Authority = authority;
ManagementScope scope = new ManagementScope("\\\\remoteServerIP\\root\\cimv2", options);
scope.Connect();

ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass(scope, managementPath, objectGetOptions);
string sBatFile = "\\\\remoteServerIP\\c


\\ nini.bat";
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams ["CommandLine"] = sBatFile;

ManagementBaseObject outParams = processClass.InvokeMethod("Create",inParams,null);</pre>


我注释掉了最后一行代码(InvokeMethod),以检查获取连接所需的时间,而不执行批处理文件.经过测试,连接到远程服务器花了10秒钟!

我还尝试在cmd上使用psexec执行我的远程批处理,并且还花费了超过5分钟的时间才能连接并完成执行...

到该远程服务器的链接确实很糟糕(64 Kbit/sec),那么还有另一种方法可以在远程服务器上执行该批处理吗?

再次感谢:)
\\nini.bat";
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = sBatFile;

ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);</pre>


i commented out the last line of code (InvokeMethod) to check the time required for acquiring a connection , without executing the batch file. When tested, it took 10 seconds to connect to the remote server !

i also tried to execute my remote batch using psexec on cmd, and it also took more than 5 minutes to connect and finish execution...

The link to that remote server is really bad (64 Kbit/sec) , so is there another way to execute that batch on the remote server?

thanks again :)


这篇关于asp.net:远程批处理文件执行(性能问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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