Ok, so I have this Microsoft wizard which i can configure to execute in
unattend fashion. However, in true MS style, the unattend wizard throws up a
dialogue box requiring user intervention once it completes. This causes my
script to never continue executing and complete. I would like to find a way
to dismiss this dialogue box through script. I've been reading up on SendKey
method, and this sounds like it would do what i want. The problem though, is
that I'm not sure how best to get this to execute. I've copied my code below.
I'm calling the wizard through the 'Run' Method with the WaitOnReturn value
set to 'false', so as soon as i kick it off, the script continues to execute
and i can call the SendKeys method. Now the wizard that i've just invoked
performs a lot of file copying, and as such the time this takes could vary
from server to server. I've invoked a DO While loop immediattely after
invoking the wizard, but not sure how best to set a condition for the loop
to, well loop. :)
I've thought about using the return code from the Run method, but I'm not
sure if this is ever updated, once i've invoked the wizard. Anyway, i'm
babbling now. Any chance someone can look at the below for me :
Function fnCompRisetup(strScriptDir)
Dim ObjRunSh, ObjSendKey, strAppName, strSendKey1, strRunCmd, intRetCode,
intCount
set ObjRunSh = CreateObject("Wscript.Shell")
Set objSendkey = CreateObject("Wscript.Shell")
strAppName = "Authorizing DHCP"
strSendKey1 = " "
strRunCmd = "risetup.exe /AUTO " & strScriptDir & "\rissetup.inf"
intRetCode =0
fnWriteLog("Executing " & strConfiguration)
intRetCode = ObjRunSh.Run(strConfiguration, 1,false)
fnwritelog("Return Code :" & intRetCode)
fnwritelog("Starting Loop until condition equals ")
Do While intRetCode=0 '1
or
Do While intCount < 100000
fnwritelog(strRetCode & " Returned.")
fnwriteLog("Switching to Application" & strAppName)
ObjSendKey.AppActivate(strAppName)
fnwritelog("Sleeping...")
sleep 100
fnwritelog("Sending SendKey 1" & strSendKey1)
ObjSendKey.SendKeys(strSendKey1)
fnwritelog("Complete SendKeys - Exiting")
intCount = intCount+1
Loop
Set ObjSendKey = Nothing
End Function