Skip to content

Instantly share code, notes, and snippets.

@Eugeny
Created June 18, 2010 20:08
Show Gist options
  • Save Eugeny/444150 to your computer and use it in GitHub Desktop.
Save Eugeny/444150 to your computer and use it in GitHub Desktop.
public void RunVPC(string name, bool indeed)
{
if (indeed && name.StartsWith("serverA_"))
{
Service.Invoke("vpcprep");
Thread.Sleep(500);
}
string s = Environment.MachineName.ToUpper();
if (name.StartsWith("serverA_") && s.CompareTo("VI61") >= 0 && s.CompareTo("VI99") <= 0 && s.Length == 4)
{
File.WriteAllBytes("d:\\vhd\\" + name,
Encoding.Unicode.GetBytes(Encoding.Unicode.GetString(File.ReadAllBytes("d:\\vhd\\" + name)).Replace(
"<ram_size type=\"integer\">2048</ram_size>",
"<ram_size type=\"integer\">1024</ram_size>")));
}
try
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = @"C:\Program Files\Microsoft Virtual PC\Virtual PC.exe";
psi.Arguments = "-singlepc -pc \"" + name.Remove(name.LastIndexOf(".")) + "\" -launch";
if (indeed) Process.Start(psi);
}
catch { }
}
----> Service.Invoke() goes here:
public static void PrepareVPC()
{
Utils.Run(@"d:\settings\dsknife\vpcPreparer.bat", "", false);
}
public static void Run(string cmd, string args, bool visible)
{
Process p = new Process();
ProcessStartInfo psi = p.StartInfo;
psi.FileName = cmd;
psi.Arguments = args;
psi.UseShellExecute = false;
psi.CreateNoWindow = !visible;
p.StartInfo = psi;
try
{ p.Start(); }
catch { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment