Search code examples
autoit

.exe won't open in AutoIt?


I want to install the .net Framework 3.5 offline on Windows 10 computers. The weird thing is that my installer (C:\DotNet_Win10.exe) doesn't start when I run this script:

Func _Au3RecordSetup()
    Opt('WinWaitDelay', 100)
    Opt('WinDetectHiddenText', 1)
    Opt('MouseCoordMode', 0)

    Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '')
    If $aResult[1] <> '00000407' Then
        MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000407->' & $aResult[1] & ')')
    EndIf
EndFunc

Func _WinWaitActivate($title, $text, $timeout = 0)
    WinWait($title, $text, $timeout)
    If Not WinActive($title,$text) Then WinActivate($title, $text)
    WinWaitActive($title, $text, $timeout)
EndFunc

_AU3RecordSetup()

Run('C:\DotNet_Win10.exe')

_WinWaitActivate("DotNet for Windows 10 x86 x64 Setup","")

Send("{ENTER}")
Sleep(20000)
Send("{TAB}{ENTER}")

_WinWaitActivate("DotNet for Windows 10 x86 x64 Setup ","")

Send("{ENTER}")

The more important part is of course the lower part.

Why doesn't it open? When I run the .exe normally it just opens and the installation works perfectly fine.


Solution

  • Even while I don't know exactly why Run() doesn't work here, you can try using ShellExecute() instead.