From 132c315e3715ccfa1c582721f245172b3fb80557 Mon Sep 17 00:00:00 2001 From: javadib Date: Mon, 30 Nov 2015 13:50:04 +0330 Subject: [PATCH] fix logic error for example - WaitForToolsInGuest method wait for login, So first login then call the WaitForToolsInGuest. - Working with snapshot has broken when virtual Machine is powered off. --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e4ff78d..d321d93 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,10 @@ using (VMWareVirtualHost virtualHost = new VMWareVirtualHost()) { // power on this virtual machine virtualMachine.PowerOn(); - // wait for VMWare Tools - virtualMachine.WaitForToolsInGuest(); // login to the virtual machine virtualMachine.LoginInGuest("Administrator", "password"); + // wait for VMWare Tools + virtualMachine.WaitForToolsInGuest(); // run notepad virtualMachine.RunProgramInGuest("notepad.exe", string.Empty); // create a new snapshot @@ -60,8 +60,7 @@ using (VMWareVirtualHost virtualHost = new VMWareVirtualHost()) // take a snapshot at the current state VMWareSnapshot createdSnapshot = virtualMachine.Snapshots.CreateSnapshot(name, "test snapshot"); createdSnapshot.Dispose(); - // power off - virtualMachine.PowerOff(); + // find the newly created snapshot using (VMWareSnapshot foundSnapshot = virtualMachine.Snapshots.GetNamedSnapshot(name)) { @@ -70,6 +69,9 @@ using (VMWareVirtualHost virtualHost = new VMWareVirtualHost()) // delete snapshot foundSnapshot.RemoveSnapshot(); } + + // power off + virtualMachine.PowerOff(); } } ```