|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
ok, there is no way to get the ip of vm using COM interface directly,
so I use another way... using "ping computerName" in the cmd.exe to get the vm's ip, hehe so at first u must know the vm's computerName try { string computerName = CmdArgs[paramIndex]; Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); p.StandardInput.WriteLine("ping " + computerName ); p.StandardInput.WriteLine("exit"); string strOutput = p.StandardOutput.ReadToEnd(); p.WaitForExit(); p.Close(); if (strOutput.Contains(" with 32 bytes of data")) { int indexStart = strOutput.LastIndexOf('[') + 1; int indexEnd = strOutput.LastIndexOf(']'); string ip = strOutput.Substring(indexStart, indexEnd - indexStart); output(ip); } else output("0.0.0.0"); } catch { output("0.0.0.0"); } |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
please me to find if there is something wrong in the program
![]() |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
i am a ramone wrote:
> ok, there is no way to get the ip of vm using COM interface directly, > so I use another way... > using "ping computerName" in the cmd.exe to get the vm's ip, hehe > so at first u must know the vm's computerName ComputerName is a property of the IVMGuestOS object in the virtual machine object available via the COM interface. Also you can read any registry key in the GuestOS under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters If you configure your VMs put the data you want in this registry path then you can retrieve them via the COM interface with IVMGuestOS->GetParameter("keyname") Yes this is specific to your VMs but it works. |
|
![]() |
| Outils de la discussion | |
|
|