1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
using System; using System.Management.Automation; // Windows PowerShell namespace. namespace PowerSh { class PowerSh { static void Main(string[] args) { PowerShell ps = PowerShell.Create(); ps.AddScript("gps > procesos.txt"); IAsyncResult result = ps.BeginInvoke(); // do something else until execution has completed. // this could be sleep/wait, or perhaps some other work while (result.IsCompleted == false) { } Console.WriteLine("Fin!"); } // End Main. } // End PowerSh. } |