Jump to content

Vmware + autoit


Recommended Posts

You can get informations from you VM's library in the inventory.vmls file under %UserProfile%AppDataRoamingVMware

ok, but I do not understand which folders are

according to me is more simple to start vmware, go in the left side, send the folder number, send enter, and send ctrl+b to power all 

Edited by benny12
Link to comment
Share on other sites

The vmrun syntax should be vmrun start "Path to vmx file".

You could retrieve the vmx file list in the inventory.vmls file (seems easy to parse). Did you try to open it with a text editor to see its content ?

Link to comment
Share on other sites

The vmrun syntax should be vmrun start "Path to vmx file".

You could retrieve the vmx file list in the inventory.vmls file (seems easy to parse). Did you try to open it with a text editor to see its content ?

this is the first content of the file
 
.encoding = "windows-1252"
vmlist94.config = "folder94"
vmlist94.Type = "2"
vmlist94.DisplayName = "1"
vmlist94.ParentID = "0"
vmlist94.ItemID = "94"
vmlist94.SeqID = "1"
vmlist94.IsFavorite = "FALSE"
vmlist94.UUID = "folder:52 25 43 ff 30 bf 29 ea-9b 31 04 86 a9 e7 33 ce"
vmlist94.Expanded = "FALSE"
vmlist95.config = "U:\1\1 - MAU\1 - MAU.vmx"
vmlist95.DisplayName = "1 - MAU"
vmlist95.ParentID = "94"
vmlist95.ItemID = "95"
vmlist95.SeqID = "0"
vmlist95.IsFavorite = "FALSE"
vmlist95.IsClone = "FALSE"
vmlist95.CfgVersion = "8"
vmlist95.State = "normal"
vmlist95.UUID = "56 4d db d7 7b e1 7d a3-25 d2 6a 18 29 cc 88 40"
vmlist95.IsCfgPathNormalized = "TRUE"
vmlist96.config = "U:\1\2 - DAD\2 - DAD.vmx"
vmlist96.DisplayName = "2 - DAD"
vmlist96.ParentID = "94"
vmlist96.ItemID = "96"
vmlist96.SeqID = "1"
vmlist96.IsFavorite = "FALSE"
vmlist96.IsClone = "FALSE"
vmlist96.CfgVersion = "8"
vmlist96.State = "normal"
vmlist96.UUID = "56 4d 1d 6b 87 69 36 6e-04 0b e7 d4 f7 0e b5 1a"
vmlist96.IsCfgPathNormalized = "TRUE"
vmlist97.config = "U:\1\3 - ANN\3 - ANN.vmx"
vmlist97.DisplayName = "3 - ANN"
vmlist97.ParentID = "94"
Link to comment
Share on other sites

 

this is the first content of the file
 
.encoding = "windows-1252"
vmlist94.config = "folder94"
... ....

 

hope this helps

Local $a = VmwareInventoryToArray()

#include <Array.au3>                               ; ..just to show the array
_ArrayDisplay($a, "from VmwareInventoryToArray()") ; ..just to show the array


Func VmwareInventoryToArray()
    Local $a[1][2]
    $a[0][0] = 0
    Local $sFile = FileRead(@UserProfileDir & "\AppData\Roaming\VMware\inventory.vmls")
    If $sFile = "" Then Return SetError(1, 1, $a)
    Local $n, $p, $aFile = StringSplit($sFile, @CRLF)
    Local $a[14][1000]
    $a[0][0] = 0
    $a[1][0] = "SelfIndex"
    For $n = 1 To $aFile[0]
        If StringLeft($aFile[$n], 6) = "vmlist" Then
            Switch StringMid($aFile[$n], StringInStr($aFile[$n], '.') + 1, StringInStr($aFile[$n], '=') - StringInStr($aFile[$n], '.') - 2)
                Case "config"
                    $p = VmwareInventoryToArray_AddToArray($a, $aFile[$n], 2)
                    VmwareInventoryToArray_AddToArray_ISOfile($a, $p, 13)
                Case "DisplayName"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 3)
                Case "ParentID"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 4)
                Case "ItemID"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 5)
                Case "SeqID"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 6)
                Case "IsFavorite"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 7)
                Case "IsClone"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 8)
                Case "CfgVersion"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 9)
                Case "State"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 10)
                Case "UUID"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 11)
                Case "IsCfgPathNormalized"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 12)
            EndSwitch
        EndIf
    Next

    ReDim $a[14][$a[0][0] + 1]
    If $a[0][0] > 990 Then
        $a[0][1] = "you've got too many entries !"
        Return SetError(2, 1, $a) ; something is very wrong if you have over 100 VMs on 1 PC
    EndIf
    $a[0][1] = "OK"
    Return SetError(0, 0, $a)
EndFunc   ;==>VmwareInventoryToArray

Func VmwareInventoryToArray_AddToArray_ISOfile(ByRef $a, $p, $i)
    If Not $p Then Return
    Local $sFile = FileRead($a[2][$p])
    If $sFile = "" Then Return
    If $a[$i][0] = "" Then $a[$i][0] = "ISO file"
    Local $aFile = StringSplit($sFile, @CRLF)
    For $n = 1 To $aFile[0]
        If StringRight($aFile[$n], 5) = '.iso"' Then
            $a[$i][$p] = StringTrimRight(StringTrimLeft($aFile[$n], StringInStr($aFile[$n], '=') + 2), 1)
            Return
        EndIf
    Next
EndFunc   ;==>VmwareInventoryToArray_AddToArray_ISOfile

Func VmwareInventoryToArray_GetArrayPos($i, ByRef $a)
    Local $n
    $i = Int($i)
    For $n = 999 To 1 Step -1
        If $a[1][$n] = $i Then Return $n
    Next
    For $n = 1 To 999 Step 1
        If $a[1][$n] = "" Then
            $a[1][$n] = $i
            $a[0][0] = $a[0][0] + 1
            Return $n
        EndIf
    Next
    Return 999
EndFunc   ;==>VmwareInventoryToArray_GetArrayPos

Func VmwareInventoryToArray_AddToArray(ByRef $a, $s, $i)
    If $a[$i][0] = "" Then $a[$i][0] = StringMid($s, StringInStr($s, '.') + 1, StringInStr($s, '=') - StringInStr($s, '.') - 2)
    If StringTrimRight(StringTrimLeft($s, StringInStr($s, '=') + 2), 1) = "" Then Return 0
    Local $p = VmwareInventoryToArray_GetArrayPos(Int(StringMid($s, 7, StringInStr($s, '.') - 7)), $a)
    $a[$i][$p] = StringTrimRight(StringTrimLeft($s, StringInStr($s, '=') + 2), 1)
    Return $p
EndFunc   ;==>VmwareInventoryToArray_AddToArray
 

Edit: added to know what CD it used from the VMX file, you don't need it but I wanted to.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

hope this helps

Local $a = VmwareInventoryToArray()

#include <Array.au3>                               ; ..just to show the array
_ArrayDisplay($a, "from VmwareInventoryToArray()") ; ..just to show the array


Func VmwareInventoryToArray()
    Local $a[1][2]
    $a[0][0] = 0
    Local $sFile = FileRead(@UserProfileDir & "\AppData\Roaming\VMware\inventory.vmls")
    If $sFile = "" Then Return SetError(1, 1, $a)
    Local $n, $p, $aFile = StringSplit($sFile, @CRLF)
    Local $a[14][100]
    $a[0][0] = 0
    $a[1][0] = "Index"
    For $n = 1 To $aFile[0]
        If StringLeft($aFile[$n], 6) = "vmlist" Then
            Switch StringMid($aFile[$n], StringInStr($aFile[$n], '.') + 1, StringInStr($aFile[$n], '=') - StringInStr($aFile[$n], '.') - 2)
                Case "config"
                    $p = VmwareInventoryToArray_AddToArray($a, $aFile[$n], 2)
                    VmwareInventoryToArray_AddToArray_ISOfile($a, $p, 13)
                Case "DisplayName"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 3)
                Case "ParentID"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 4)
                Case "ItemID"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 5)
                Case "SeqID"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 6)
                Case "IsFavorite"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 7)
                Case "IsClone"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 8)
                Case "CfgVersion"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 9)
                Case "State"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 10)
                Case "UUID"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 11)
                Case "IsCfgPathNormalized"
                    VmwareInventoryToArray_AddToArray($a, $aFile[$n], 12)
            EndSwitch
        EndIf
    Next

    ReDim $a[14][$a[0][0] + 1]
    Return SetError(0, 0, $a)
EndFunc   ;==>VmwareInventoryToArray

Func VmwareInventoryToArray_AddToArray_ISOfile(ByRef $a, $p, $i)
    If Not $p Then Return
    Local $sFile = FileRead($a[2][$p])
    If $sFile = "" Then Return
    If $a[$i][0] = "" Then $a[$i][0] = "ISO file"
    Local $aFile = StringSplit($sFile, @CRLF)
    For $n = 1 To $aFile[0]
        If StringRight($aFile[$n], 5) = '.iso"' Then
            $a[$i][$p] = StringTrimRight(StringTrimLeft($aFile[$n], StringInStr($aFile[$n], '=') + 2), 1)
            Return
        EndIf
    Next
EndFunc   ;==>VmwareInventoryToArray_AddToArray_ISOfile

Func VmwareInventoryToArray_GetArrayPos($i, ByRef $a)
    Local $n
    $i = Int($i)
    For $n = 99 To 1 Step -1
        If $a[1][$n] = $i Then Return $n
    Next
    For $n = 1 To 99 Step 1
        If $a[1][$n] = "" Then
            $a[1][$n] = $i
            $a[0][0] = $a[0][0] + 1
            Return $n
        EndIf
    Next
    Return 99
EndFunc   ;==>VmwareInventoryToArray_GetArrayPos

Func VmwareInventoryToArray_AddToArray(ByRef $a, $s, $i)
    If $a[$i][0] = "" Then $a[$i][0] = StringMid($s, StringInStr($s, '.') + 1, StringInStr($s, '=') - StringInStr($s, '.') - 2)
    Local $p = VmwareInventoryToArray_GetArrayPos(Int(StringMid($s, 7, StringInStr($s, '.') - 7)), $a)
    $a[$i][$p] = StringTrimRight(StringTrimLeft($s, StringInStr($s, '=') + 2), 1)
    Return $p
EndFunc   ;==>VmwareInventoryToArray_AddToArray

Edit: added to know what CD it used from the VMX file, you don't need it but I wanted to.

 

thank you, because it can be helpful? there are not even all folders and are not put in order

i will prefer the solution with vwmare gui

Edited by benny12
Link to comment
Share on other sites

thank you, because it can be helpful? there are not even all folders and are not put in order

 

i will prefer the solution with vwmare gui

If you really insist on ControlSend() then I gave you a working example in post#4.

Seems your not taking the time to actually try anything people are suggesting for you.

I cant see why cmd based startup would not work, you just need to take the time to compile a list of your VM in each folder and you could easily wrap a GUI for it or something so you can just checkbox the VM "groups" you want.

Link to comment
Share on other sites

 

 

If you really insist on ControlSend() then I gave you a working example in post#4.

Seems your not taking the time to actually try anything people are suggesting for you.

I cant see why cmd based startup would not work, you just need to take the time to compile a list of your VM in each folder and you could easily wrap a GUI for it or something so you can just checkbox the VM "groups" you want.

 

I appreciate your effort and others to try to help me, but not being very responsible, I prefer to use a method that seems easier for me

i've tried

 
WinActivate("VMware Workstation")
ControlSend("VMware Workstation", "", 10002, "CentOS")

but I did not understand where to change the values to send

if I wanted to select the window, press 1, and sending ctrl + b
should be written as follows?
 
WinActivate("VMware Workstation")
ControlSend("VMware Workstation", "", 10002, "CentOS")
Send ("{NUMPAD1}")
Send ("{ENTER}")
Send("^b") 
Link to comment
Share on other sites

Perhaps you should take a look at this:

https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm

"CentOS" is the send I used in my example.

You would replace that with your strings.

WinActivate("VMware Workstation")
ControlSend("VMware Workstation", "", 10002, "{NUMPAD1}")
ControlSend("VMware Workstation", "", 10002, "{ENTER}")
ControlSend("VMware Workstation", "", 10002, "^b")
Link to comment
Share on other sites

Perhaps you should take a look at this:

https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm

"CentOS" is the send I used in my example.

You would replace that with your strings.

 

WinActivate("VMware Workstation")
ControlSend("VMware Workstation", "", 10002, "{NUMPAD1}")
ControlSend("VMware Workstation", "", 10002, "{ENTER}")
ControlSend("VMware Workstation", "", 10002, "^b")

thanks, now it works :lmao:

so, is "10002" the ID that autoit use to recognize that portion of the screen?

if I wanted to control the right side, what ID should I put? au3info show me only [CLASS: # 32770; INSTANCE: 2], without ID :sweating:

Link to comment
Share on other sites

The vmrun syntax should be vmrun start "Path to vmx file".

You could retrieve the vmx file list in the inventory.vmls file (seems easy to parse). Did you try to open it with a text editor to see its content ?

Do you know how i can clear the cache of dns/ip vmware? I always returns this error after booting the iso several times

 

 

Cattura.JPG

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...