My system is making good progress but I have hit my next snag. I get my VM to startup, i can transfer an exe to it and run it, but I cannot seem to grab the output. the exe is a basic console app that just prints every second:
The code to run and read is as follows:Loop: 1
Loop: 2
...
Code: Select all
var progStart = vm.LaunchVMProcess(session, "gui", "");
progStart.WaitForCompletion(5000);
File.Copy(@"C:\Users\...\Documents\Visual Studio 2010\Projects\vBoxService\TestClient\bin\Debug\TestClient.exe", @"\\VMOFFICE2010\Users\Public\Documents\TestClient.exe");
var console = session.Console;
var guest = console.Guest;
var guestSession = guest.CreateSession("admin", "admin", "", "anon");
while (guestSession.Status != GuestSessionStatus.GuestSessionStatus_Started)
{
Thread.Sleep(100);
}
string[] arr = { "loop" };
var progExe = guestSession.ProcessCreate(@"C:\Users\Public\Documents\TestClient.exe", arr, null, null, 0);
progExe.WaitForArray(new ProcessWaitForFlag[] { ProcessWaitForFlag.ProcessWaitForFlag_StdOut }, 0);
while (progExe.Status == ProcessStatus.ProcessStatus_Started)
{
var read = progExe.Read(0, 2048, 1000);
Thread.Sleep(1000);
}
not sure what I might be doing wrong.