https://technet.microsoft.com/en-in/sysinternals/bb897553.aspx
Sample Code:
static void Main(string[] args)
{
Process ProcessA = new Process();
ProcessA.StartInfo.UseShellExecute = false;
ProcessA.StartInfo.CreateNoWindow = true;
ProcessA.StartInfo.RedirectStandardOutput = true;
ProcessA.StartInfo.FileName = @"C:\PSTools\PsExec.exe";
ProcessA.StartInfo.Arguments = @"\\serverName_xx -u doamin_xx\userName_xx -p password_xx cmd /c (xcopy sourceLocation_xx destinationLocation_xx /S /Y)";
ProcessA.Start();
string outputA = ProcessA.StandardOutput.ReadToEnd();
ProcessA.WaitForExit();
Thread.Sleep(20000);
Process ProcessCopyB = new Process();
ProcessCopyB.StartInfo.UseShellExecute = false;
ProcessCopyB.StartInfo.RedirectStandardOutput = true;
ProcessCopyB.StartInfo.FileName = @"C:\PSTools\PsExec.exe";
ProcessCopyB.StartInfo.Arguments = @"\\serverName_xx -u userName_xx -p password_xx cmd /c (xcopy sourceLocation_xx destinationLocation_xx /S /Y)";
ProcessCopyB.Start();
string outputB = ProcessCopyB.StandardOutput.ReadToEnd();
ProcessCopyB.WaitForExit();
Thread.Sleep(10000);
}
No comments:
Post a Comment