Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public string GetCmDOutput(string cmd)
  2. ProcessStartInfo startInfo = new ProcessStartInfo("control", cmd)
  3. {
  4. WindowStyle = ProcessWindowStyle.Hidden,
  5. UseShellExecute = false,
  6. RedirectStandardOutput = true,
  7. CreateNoWindow = true
  8. };
  9.  
  10. string output = string.Empty;
  11.  
  12. Process process = Process.Start(startInfo);
  13. process.OutputDataReceived += (sender, e) => output = string.Concat(output, e.Data);
  14. process.BeginOutputReadLine();
  15. process.Start();
  16. process.WaitForExit();
  17. Delay.Milliseconds(1500) //API-specific delay
  18.  
  19. return output;
  20. }
  21.  
  22. string cmd = @"psexec.exe \remoteComputerName -u username -p password -c cmd /c wmic qfe";
  23. GetCmdOutput(cmd);
  24. Report.Info(cmd); //API-specific reporting
  25.  
  26. <Exec IgnoreExitCode="True"
  27. Command="$(PSToolsPath)PsExec.exe \%(RemoteSereverIP) -u $(Username) -p $(UserPassword) -w $(ReleaseAssetsBasePath)BuildCommands msbuild Build.xml /t:switchwebsites /p:Releaseversion=$(Releaseversion);" >
  28. </Exec>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement