Guest User

Untitled

a guest
Jun 24th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. public string exec(String cmd, String args)
  2.         {
  3.             string retMessage = String.Empty;
  4.  
  5.             /*
  6.              * C:\Program Files\Oracle\VirtualBox\VBoxManage.exe guestcontrol "Devel" execute --image "/bin/ls" --username="fotka" --password="@fotka" --wait-exit --wait-stdout /tmp
  7.              */
  8.             string vbm = @"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe";
  9.             string vbargs = " guestcontrol \"Devel\" execute --image \"" + cmd + "\" --username=\"fotka\" --password=\"@fotka\" --wait-exit --wait-stdout ";
  10.  
  11.             ProcessStartInfo startInfo = new ProcessStartInfo();
  12.             Process p = new Process();
  13.  
  14.             startInfo.CreateNoWindow = true;
  15.             startInfo.RedirectStandardOutput = true;
  16.  
  17.             startInfo.UseShellExecute = false;
  18.             startInfo.Arguments = vbargs;
  19.             startInfo.FileName = vbm;
  20.  
  21.             p.StartInfo = startInfo;
  22.             p.Start();
  23.             p.WaitForExit();
  24.  
  25.             return p.StandardOutput.ReadToEnd();
  26.         }
Add Comment
Please, Sign In to add comment