VMware {code} Community
aphiwat
Contributor
Contributor

can I use VIX API Check Current User Logon Guest OS (VMs)

Hi, Averyone

I must script for check current user logon guest os (VMs) with display list VMs and name user logon

How can I check that, So Whom have script for list state & current user logon

Thanks.

Reply
0 Kudos
2 Replies
stanguturi
VMware Employee
VMware Employee

No. VIX doesn't have any API that will give the information about the current logged in user.

Reply
0 Kudos
stanguturi
VMware Employee
VMware Employee

There is a workaround. Follow these steps.

- Execute VixVM_ListProcessesInGuest(). This api lists down the information (owner, process id, command name, etc) about all the running processes in the guest.

- From the list, check for processes which have 'vmtoolsd' and 'vmusr' in the command name.

- Get the owner of the matching processes.

This gives the information about the currently logged in user.

You can use 'vmrun' (command line utility bundled with VMware VIX API) to list the processes running in the guest. Use your favorite grep utility to search in the 'vmrun' output.

Ex:

vmrun -gu guestuser -gp guestpassword listprocessesinguest /path/to/myvm.vmx | grep -i vmtoolsd | grep -i  vmusr
pid=1412, owner=WINXP64-IRON\guestadmin, cmd="C:\Program Files\VMware\VMware Tools\vmtoolsd.exe"  -n vmusr

Check the owner. The currently logged in user is guestadmin. Smiley Happy

Reply
0 Kudos