Jump to content

Automating a Setup with no silent switch / Won't accept any Send keyboard commands


Recommended Posts

Hi Autoit Forum! I'm a Citrix / MDT / PowerShell Admin, who installs Windows Servers aka Citrix Master Images with Microsoft Deployment Toolkit.

Normally I write small PowerShell Scripts for each application, which I embed into MDT to install Citrix Master Images, which are then cloned to become a Citrix Site.
In 99% of the cases I succeed by using native MSI features, an EXE silent switch, file copy tricks, registry imports, App-V packages etc. But this time I encountered a setup.exe that is so strange, that I wasn't able to find any solution. But as the setup could be potentially finished by just a few keyboard strokes (UP, TAB, TAB, ENTER, ENTER, PAUSE, ENTER), after the initial launch, I thought I give AutoIt a try.

I took a look at the Notepad tutorial and tried some simple example setups myself (which have working silent switches, but just to train), which worked quite OK, at least the Keyboard commands were working. But with this setup, I haven't been able to send any keyboard command to the window.

This is the program (it's german, but shouldn't matter as we are purely talking about sending the right keyboard commands.) -> https://files.meinekleinefarm.net/f/3e914541d30b4ba8b498/
Please try this only on a test machine, as it installs drivers, fonts etc.

This are the steps as screenshots, if I'm not mistaken they are: UP, TAB, TAB, ENTER, ENTER, (PAUSE or maybe PAUSE for EXIT screen to be seen), ENTER

image.png.010b110b503e915ed425433403e32913.pngimage.png.a92449b358e37b8cedd27386f882941e.pngimage.png.7402aec0bf064f05229191760359581a.png

And this is the code I tried so far. Please notice that this is in no way meant to work, but to show which ways I have already tried, and non of them moved anything in the dialogue. Although manual keyboard input works all the time.

run("client_setup.exe")
;Sleep(5000)
WinWaitActive("Cargo Online Client Setup - [Installation Datenbanktreiber]")
WinActivate("Cargo Online Client Setup - [Installation Datenbanktreiber]")

Send("{DOWN}" & "{TAB 2}")
ControlSend("Installation Datenbanktreiber", "Datenbankversion", "", "{TAB 2}")
ControlSend("Datenbanktreiber", "", "", "{DOWN}")
ControlSend("Installation Datenbanktreiber", "", "[CLASS:pbdw125; INSTANCE:1]", "{DOWN 5}")
ControlClick("Cargo Online Client Setup","Bitte wählen Sie Ihre Datenbankversion",6,"left")
ControlClick("Installation Datenbanktreiber", "Datenbankversion", "", "left", "" , 114, 32)

WinClose("[CLASS:FNWND3125]", "")

And a second try:

#include <MsgBoxConstants.au3>

;Function for getting HWND from PID
Func _GetHwndFromPID($PID)
    $hWnd = 0
    $winlist = WinList()
    Do
        For $i = 1 To $winlist[0][0]
            If $winlist[$i][0] <> "" Then
                $iPID2 = WinGetProcess($winlist[$i][1])
                If $iPID2 = $PID Then
                    $hWnd = $winlist[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
    Until $hWnd <> 0
    Return $hWnd
EndFunc;==>_GetHwndFromPID

; Script Start - Add your code below here

;Run process
$iPID = Run("client_setup.exe")

;Allow window to initialize...
Sleep (10000)

;Get HWND.
$hWnd = _GetHwndFromPID($iPID)

WinWaitActive($hWnd)
WinActivate($hWnd)

;Send("{DOWN}" & "{TAB 2}")
ControlSend($hWnd, "", "", "{DOWN}")
    If @error Then ; check if _FileListToArray() function return any error
        MsgBox($MB_ICONERROR, '_FileListToArray', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; show error message
    EndIf

;Close
WinClose($hWnd)

Do you have any idea how I can send keyboard commands to this exe? As long as I get the cursor moving, I should hopefully be able to finish the rest myself.

Link to comment
Share on other sites

Thank you very much for your reply. It might be, that there is a valid and working setup for the SQL Anywhere Database driver, but I have to use the vendor provided setup file shown in the screenshots.

As you can see in the 2nd picture, there are other things installed alongside, like Ghostscript, some kind of mail solution, a PDF Printer and a Font. I could separate this stuff, but then I still wouldn't have the configuration this setup might apply to the OS and second it would be unsupported, as I didn't use the vendor provided installer.

We already had contact with the vendor. They refuse to provide a silent setup of their installer, nor do they allow to use anything beside the provided installer.

Which brings me back to my initial thought, I hope to use the original setup and automate its Keyboard control, to use it during my setup.

To further clarify things. I don't need it silent. It's ok if the Windows is visible during the MDT process. It has to be unattended. I would start it via a PowerShell process, let AutoIt do its Magic and when the Processes are finished, the PowerShell process would finish too. I will clarify this in the initial post.

Link to comment
Share on other sites

If you cannot use Send, I doubt you will find a way to automate this install.  But here what I would attempt to do :

1- use #RequireAdmin

2- run the script x64

3- try sending VK instead of actual chars (see _WinAPI_Keybd_Event)

Link to comment
Share on other sites

I feel so stupid, but that might be, because I'm a first time user. If I want to control an EXE that runs with admin permissions, I should also run SciTE with admin permissions otherwise the Send commands can't traverse the evaluation I guess. This code runs just fine. I think it would require some tuning, but that's not something I'm capable of yet.

Next step would be to find out, how to start this from a MDT/PowerShell command line. But I guess I find this in the FAQ or Wiki.

Thank you very much! Here is the PoC Code:

#RequireAdmin

run("client_setup.exe")

WinWaitActive("Cargo Online Client Setup - [Installation Datenbanktreiber]")
WinActivate("Cargo Online Client Setup - [Installation Datenbanktreiber]")
ControlSend("Cargo Online Client Setup - [Installation Datenbanktreiber]", "", 1007, "{UP}")
ControlClick("Cargo Online Client Setup - [Installation Datenbanktreiber]", "", 1005, "left")

WinWaitActive("Cargo Online Client Setup - [Installation Drucker/E-Mail]")
WinActivate("Cargo Online Client Setup - [Installation Drucker/E-Mail]")
ControlClick("Cargo Online Client Setup - [Installation Drucker/E-Mail]", "", 1006, "left")

WinWaitActive("Cargo Online Client Setup - [Installation abgeschlossen]")
WinActivate("Cargo Online Client Setup - [Installation abgeschlossen]")
ControlClick("Cargo Online Client Setup - [Installation abgeschlossen]", "", 1003, "left")

 

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...