PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.virtualserver > I have found a way to get the vm's ip :)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
I have found a way to get the vm's ip :)

Réponse
 
LinkBack Outils de la discussion
Vieux 21/02/2008, 07h44   #1
i am a ramone
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut I have found a way to get the vm's ip :)

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");
}
  Réponse avec citation
Vieux 21/02/2008, 07h45   #2
i am a ramone
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: I have found a way to get the vm's ip :)

please me to find if there is something wrong in the program
  Réponse avec citation
Vieux 21/02/2008, 13h16   #3
Richard Cardona
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: I have found a way to get the vm's ip :)

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.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h27.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07584 seconds with 11 queries