I am a starter in c# and I have a small knowledge. I have made a windows application on c# that shutdwon windows servers in my network remotely. I have a v-center server that hosts two Hosts with virtual machines. I could connect to the virtual machines and shut them down but my issue is I tried to write a code to shutdwon the host itself using VIX API in c#, but I couldn't. All I get is to disconnect them. Am I missing any other class or sdks???
try
{
VMWareVirtualHost host = new VMWareVirtualHost();
host.ConnectToVMWareVIServer("172.16.1.72", "root","123456");
//host.Disconnect();
IVMWareVirtualMachine machine = new VMWareVirtualMachine();
machine = host.Open("[datastore1] Kerio contarol/Kerio contarol.vmx");
machine.ShutdownGuest();
if (machine.IsRunning == true)
{
MessageBox.Show("Machine is running");
}
else
{
MessageBox.Show("Machine is not rinning");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}