LoginInGuest fails the first time when powering up VM.
This is a branch off of (Unable to install tools?)
http://www.vmware.com/community/thread.jspa?messageID=660883)
History:[/b][/u]
pdovy[/b]
I'm able to log in once the VM has booted and is sitting at the login screen -
however if I have the API power on the VM and then call VixVM_WaitForToolsInGuest,
it returns immediately and the subsequent login attempt fails with the error
message that tools is not running.
Is this expected behavior? I have no real other way of programmatically
determining when the OS has booted other than attempting to log in
continuously until it eventually succeeds because the machine has finally
booted.
mattrich[/b]
Are you getting back any error from VixVM_WaitForToolsInGuest()?
Also, would you mind posting the code where you call VixVM_WaitForToolsInGuest()?
zerovoid[/b]
I too have experienced this... my solution was...
log("waitForToolsVM")
returnVal = waitForToolsVM()
If (returnVal=True) Then
log("Success")
Else
log("Error: " & functionErrorMessage) : exit sub
End If
log("Note: loginVM is expected to fail once if vm was not previously" & vbcrlf _
& " powered on, will retry up to 2 times after first failure")
logincount = 0 : returnVal = False
do while (returnVal = False)
if logincount > 2 then log("Error: Unable to Login") : : exit sub
log("loginVM : attempt " & logincount)
returnVal = loginVM()
If (returnVal=True) Then
log("Success")
Else
log("Error: " & functionErrorMessage)
End If
logincount = logincount+1
loop
/code
As my comment states...
Note: loginVM is expected to fail once if vm was not previously powered on,
will retry up to 2 times after first failure.
The second time it attempts, it connects fine.
This excerpt is from VixCOM and WSF/VBS
mattrich[/b]
Ok, that shouldn't be necessary. If you call WaitForToolsInGuest() while
watching the guest in the service console, at what point in the boot process
does it seem that WaitForToolsInGuest() finishes?
Can you post you implementation of waitForToolsVM()?
zerovoid[/b]
WaitForToolsInGuest() finishes after windows explorer seems to be loaded, in
the time prior to the profile being fully loaded, like desktop icons and custom
backgrounds. Around the normal time for windows services to be loaded.
' Needs nothing
Function waitForToolsVM()
'Checks for prereq based off of stage
prereqReturn = checkPrereq(4)
If Not (prereqReturn = True) Then waitForToolsVM = prereqReturn : exit function
set job = vm.WaitForToolsInGuest(0, Nothing)
myerr = job.WaitWithoutResults()
If VixLibA.ErrorIndicatesFailure(myerr) Then
on error resume next
waitForToolsVM = false
functionErrorCode = "-100" : functionErrorMessage = "error" : errMsg = VixLibA.GetErrorText(myerr, Nothing) : functionErrorCode = myerr : functionErrorMessage = errMsg
isToolsLoaded = False
waitForToolsVM = false : exit function
End If
isToolsLoaded = True
waitForToolsVM = True
End Function
/code
Like I said, it calls the function when it should, but the first time reports an
error, and the second time works perfectly if the machine is booted from an
powered down state. If the system is already running, everything works fine.
' Needs vmUser and VMPass passed to it
Function loginVM()
'Checks for prereq based off of stage
prereqReturn = checkPrereq(5)
If Not (prereqReturn = True) Then loginVM = prereqReturn : exit function
set job = vm.LoginInGuest(vmUser, VMPass, 0, Nothing)
myerr = job.WaitWithoutResults()
If VixLibA.ErrorIndicatesFailure(myerr) Then
on error resume next
loginVM = false
functionErrorCode = "-100" : functionErrorMessage = "error" : errMsg = VixLibA.GetErrorText(myerr, Nothing) : functionErrorCode = myerr : functionErrorMessage = errMsg
isLoggedIn = False
loginVM = false : exit function
End If
isLoggedIn = True
loginVM = True
End Function
/code
As you can probably tell, it was written as a class in another language and
ported eventually to VBS. Hence variables are assigned in the setters and
getters rather than being passed to the function... atleast for the
non-override ones, which were removed from the VBS version due to some
language limitations.
It works great with the work-around though.
BTW the Guest is Win2K3, if that helps.
mattrich[/b]
Are you logging in as an actual user on the virtual machine, or are you using
one of the constants from vix.h/the type library (such as
VIX_CONSOLE_USER_NAME)?
zerovoid[/b]
Actual user of the Virtual Machine.
I am going to break this thread off into its own, so people can quickly
reference it as a different question.
\----
And so we are here...