我在服务器上有一个共享文件夹,我需要在一些文件上远程执行命令。我该怎么做?
需要在服务器上运行哪些服务才能使其正常工作?
一些细节:只能使用C#。服务器中不能安装任何东西。
发布于 2009-01-09 14:56:23
您可以使用SysInternal的PsExec。
发布于 2010-02-02 19:50:20
try
{
string AppPath = "\\\\spri11U1118\\SampleBatch\\Bin\\";
string strFilePath = AppPath + "ABCED120D_XXX.bat";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = strFilePath;
string pwd = "s44erver";
proc.StartInfo.Domain = "abcd";
proc.StartInfo.UserName = "sysfaomyulm";
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 = "psexec \\\\spri11U1118\\SampleBatch\\Bin ";
proc.Start();
while (!proc.HasExited)
{
proc.Refresh();
// Thread.Sleep(1000);
}
proc.Close();
}
catch (Exception ex)
{
throw ex;
}
发布于 2009-01-09 14:58:50
https://stackoverflow.com/questions/428276
复制相似问题