Name

Connect

Description

HRESULT
Connect([in] LONG apiVersion,
        [in] LONG hostType,
        [in] BSTR hostName,
        [in] LONG hostPort,
        [in] BSTR userName,
        [in] BSTR password,
        [in] LONG options,
        [in] IVixHandle* propertyList,
        [in] ICallback* jobDoneCallback,
        [out,retval] IJob** connectJob);

Creates a host handle. This handle cannot be shared or reused after disconnect.

Parameters

apiVersion
Must be VixCOM.Constants.VIX_API_VERSION.
hostType
With vCenter Server, ESX/ESXi hosts, and VMware Server 2.0, use VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_VI_SERVER. With VMware Workstation, use VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION. With VMware Workstation (shared mode), use VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION_SHARED. With VMware Player, use VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_PLAYER. With VMware Server 1.0.x, use VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER.
hostName
Varies by product platform. With vCenter Server, ESX/ESXi hosts, VMware Workstation (shared mode) and VMware Server 2.0, use a URL of the form "https://<hostName>:<port>/sdk" where <hostName> is either the DNS name or IP address. If missing, <port> may default to 443 (see Remarks below). In VIX API 1.10 and later, you can omit "https://" and "/sdk" specifying just the DNS name or IP address. Credentials are required even for connections made locally. With Workstation, use NULL (C++), null (C#), or empty (VB) to connect to the local host. With VMware Server 1.0.x, use the DNS name or IP address for remote connections, or the same as Workstation for local connections.
hostPort
TCP/IP port on the remote host. With VMware Workstation and VMware Player, use zero for the local host. With ESX/ESXi hosts, VMware Workstation (shared mode) and VMware Server 2.0 you specify port number within the hostName parameter, so this parameter is ignored (see Remarks below).
login
Username for authentication on the remote machine. With VMware Workstation, VMware Player, and VMware Server 1.0.x, use NULL (C++), null (C#), or empty (VB) to authenticate as the current user on local host. With vCenter Server, ESX/ESXi hosts, VMware Workstation (shared mode) and VMware Server 2.0, you must use a valid login.
password
Password for authentication on the remote machine. With VMware Workstation, VMware Player, and VMware Server 1.0.x, use NULL (C++), null (C#), or Empty (VB) to authenticate as the current user on local host. With ESX/ESXi, VMware Workstation (shared mode) and VMware Server 2.0, you must use a valid login.
options
Should be zero. The option VIX_HOSTOPTION_USE_EVENT_PUMP has been deprecated and may be removed from future versions of the VIX API.
propertyList
Must be NULL (C++), null (C#), or Nothing (VB).
jobDoneCallback
An ICallback instance that will be called when the operation is complete.
connectJob
Returns an IJob object that describes the state of this asynchronous operation.

Return Value

HRESULT

Remarks

Side Effects

None.

Requirements

VixCOM.h, since VMware Workstation 6.0.

Example


VBScript:
Dim lib
Dim job
Dim err
Dim host
Dim results

Set lib = CreateObject("VixCOM.VixLib")

Set results = Nothing

Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_VI_SERVER, "https://viserver/sdk", 0, "Administrator", "adminpass", 0, Nothing, Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), results)
If lib.ErrorIndicatesFailure(err) Then
   ' Handle the error...
End If

Set host = results(0)

' ...Do everything in your program...

Set results = Nothing
Set job = Nothing

host.Disconnect()

Copyright (C) 2007-2011 VMware, Inc. All rights reserved.