Quantcast
Channel: VMware Communities : Popular Discussions - VIX API
Viewing all articles
Browse latest Browse all 34639

PowerON VM from remote via PSEXEC and API doesn't work

$
0
0

Frame:

VMware Workstation 10.0

VS-Studio 2012

.NET 4.0

Windows 7 64bit

Vestris.VMwareLib.Dll [version 1.7] <-- wrapper for VIX API

Installed VMware-VIX-1.13.1-1379776.exe

-----------------------------------------------------------------------------------------------------------------------

 

I have a small C#-program to "shutdown" and "poweron" VM's. If I start my console-pgm with parameters from local in a BAT-file, all works fine.

 

Now i tried to start my pgm from a remote pc via psexec. The poweroff option works fine, the poweron option fails with the following error:

 

Failed to power on virtual machine: powerOnOption=512 timeoutInSeconds=120

 

Does anyone have an idea why?

 

psexec command> psexec \\xxx.xxx.xxx.xxx -u "{domain}\{user}" -p "{password}"  -s "D:\Programme\VMoperations\VMstart_XXNNV.bat

 

ADDON {05.03.2014 15:59}: I  tried it with PAEXEC and REEXEC, they failed too. And I changed my BATCH-file to call the VMrun.exe, but failed too. I think, it's a bug of VMware ?!?!?!

 

----------------------------------------------------------------------------------------------------------------------

 

BAT-File VMstart_XXNNV.bat:

SET fwpath="D:\Programme\VMoperations"

%fwpath%\VMoperations.exe -location:{vmpath} -vmname:XXNNV -o:poweron

----------------------------------------------------------------------------------------------------------------------

 

C# source VMoperations.exe:

reference to Vestris.VMWareLIb

refernce to Interop.VixCOM

--------------------------------------------------------------------------------------------


using Vestris.VMWareLib;  <-- version 1.7

...

 

private static void VMwork(string location, string vmName, string operationType)

        {

            try

            {

                using (VMWareVirtualHost virtualHost = new VMWareVirtualHost())

                {

                    virtualHost.ConnectToVMWareWorkstation();

                    vmxName = location + vmName + @"\" + vmName + @".vmx";

                    using (VMWareVirtualMachine virtualMachine = virtualHost.Open(vmxName))

                    {

                        vmPowerState = virtualMachine.PowerState;

 

                        switch (operationType)

                        {

                            case "shutdown":

                                if (vmPowerState == 1096)

                                {

                                    virtualMachine.ShutdownGuest();

                                }

                                break;

                            case "poweroff":

                                if (vmPowerState == 1096)

                                {

                                    virtualMachine.PowerOff();

                                }

                                break;

                            case "poweron":

                                if (vmPowerState == 2)

                                {

                                    virtualMachine.PowerOn(120);

                                }

                                break;

                        }

                        virtualMachine.Dispose();

                    }

                    virtualHost.Disconnect();

                    virtualHost.Dispose();

                }

                retCode = 0;

            }

            catch (Exception ex)

            {

                retCode = 1;

            }

        }

 

I tried everything, read dozends of internet pages, but found no info. Ever user on local and remote pc have full admin rights.

 

Best regards Hipp1010


Viewing all articles
Browse latest Browse all 34639

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>