在远程服务器上执行.bat文件 [英] execute .bat file on remote server

查看:848
本文介绍了在远程服务器上执行.bat文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在远程服务器上运行.bat文件.我已经粘贴了我的代码,但是无法正常工作.它导致以下错误:

登录失败:未在此计算机上向用户授予请求的登录类型

AppPath = @" \\ da9741s033 \ d $ \ EmailServices \ AdhocProdRun \ bin \" ; 字符串 strFilePath = AppPath + "ACH-DDS_Dashboard_MNTLY.bat" ;

System.Diagnostics.

处理 proc = System.Diagnostics. ();

 

字符串 pwd = 欢迎" ;
"amrs" ; "kemani" ; SecureString secret = System.Security. (); foreach ( c in pwd)

secret.AppendChar(c);

proc.StartInfo.Password =秘密;

proc.StartInfo.UseShellExecute =

false ;

proc.StartInfo.WorkingDirectory =

@" ;

 

同时 (!proc.HasExited)

{

proc.Refresh();  

}

proc.Close();

有人可以帮助我吗?

谢谢

解决方案

你好Kesavaraj

 

请查看此代码项目,然后也下载该项目.希望对您有帮助.

http://www.codeproject.com/KB/cs/Remote_Process_using_WMI_.aspx

谢谢


How can i run the .bat file on remote server. i have pasted my code but its not working. Its ginving the following error:

Logon failure: the user has not been granted the requested logon type at this computer

 string AppPath = @"\\da9741s033\d$\EmailServices\AdhocProdRun\bin\";

 

string strFilePath = AppPath + "ACH-DDS_Dashboard_MNTLY.bat";

System.Diagnostics.

Process proc = new System.Diagnostics.Process();

proc.StartInfo.FileName = strFilePath;

 

string pwd = "Welcome";

proc.StartInfo.Domain =

"amrs";

proc.StartInfo.UserName =

"kemani";

System.Security.

SecureString secret = new System.Security.SecureString();

 

foreach (char c in pwd)

secret.AppendChar(c);

proc.StartInfo.Password = secret;

proc.StartInfo.UseShellExecute =

false;

proc.StartInfo.WorkingDirectory =

@"\\da9741s033\d$\EmailServices\AdhocProdRun\bin\";

proc.Start();

 

while (!proc.HasExited)

{

proc.Refresh(); 

}

proc.Close();

can anyone help me?

Thanks,

kesav

解决方案

Hello Kesavaraj

 

Please review this code project and download that project also. I hope it will help you.

http://www.codeproject.com/KB/cs/Remote_Process_using_WMI_.aspx

Thanks


这篇关于在远程服务器上执行.bat文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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