Jump to content

EXE does not stop running untill autoit script is killed


Recommended Posts

Hi,

I am a new user of Autoit and would appreciate some assistance with a very basic unattended install script I have written.

I am trying to perform a silent install of a prepackaged piece of software, the software has been packages using Installshield, I have created a setup.iss file and I am calling the install from a Autoit script using Run() and tracking the PID until setup.exe terminates then I continue the autoit script.

The probelm I have is there appears to be some sor of parent child relationship between the Autoit script and the setup.exe file being run within the Autoit script. calling the setup.exe script outside of Autoit runs to completion. Once I call hte script inside the Autoit script the setup.exe does not ever terminate, even though the install for all intensive purposes has ended, if I kill the autoit script the setup.exe terminates soon after.

I suspect the autoit script is some how keeping the setup.exe active, can anyone please point me in the right direction to resolve this issue I have also tried using RunWait, ShellExecute and ShellExecuteWait.

Thanks in advance for any assitance.

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

;Or (StringInStr(RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","PATH"),"c:\ecl\home") == 0) Or (StringInStr(RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","PATH"),"c:\ecl\macros") == 0) Then

$answer = MsgBox(36, "Eclipse", " Please be aware that your system requires a reboot after Eclipse 2007.2 has been installed." & @CRLF & @CRLF & "We advise that you save any existing work and close down your open applications.")

; Check the user's answer to the prompt (see the help file for MsgBox return values)

; If "No" was clicked (7) then exit the script

If $answer = 7 Then

MsgBox(0, "Eclipse ", " OK. Bye!")

Exit

EndIf

If (RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path") == "") Then

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_EXPAND_SZ", "C:\ecl\home;C:\ecl\macros")

Else

$PATH = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path")

if StringInStr($PATH,"C:\ecl\home;C:\ecl\macros") >= 1 Then

Else

$PATH = $PATH & ";C:\ecl\home;C:\ecl\macros"

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_EXPAND_SZ", $PATH)

EndIf

EndIf

if (FileExists ( "C:\ecl\2007.2\bin\pc\eclipse.exe" )) Then

MsgBox(64, "Eclipse", "Eclipse has already been installed on your machine")

Exit

Else

if FileExists("C:\ecl" ) == 0 Then

$PID=Run("c:\setup.exe /s /f1\c:\setup.iss")

Else

$PID=Run("\setup.exe /s /f1c:\Eclipse_2007_2.iss")

EndIf

EndIf

If (RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","LM_LICENSE_FILE") == "") Then

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "LM_LICENSE_FILE", "REG_SZ", "1751@license01")

Else

$LM_LICENSE_FILE = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","LM_LICENSE_FILE")

if StringInStr($LM_LICENSE_FILE,"1751@license01") >= 1 Then

Else

$LM_LICENSE_FILE = "1751@license01;" & $LM_LICENSE_FILE

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "LM_LICENSE_FILE", "REG_SZ", $LM_LICENSE_FILE)

EndIf

EndIf

While ProcessWaitClose ($PID)

Sleep(10000)

WEnd

;Copy eclrc.bat file for eclipse 2007.2 to ecl home directory

FileCopy ( "\\techdata\$eclrc_xp_2007.2.bat", "c:\ecl\home\eclrc.bat", 1 )

;Copy config file to ecl macros area

; FileCopy ( "\\techdata\data\\CNFIG.ECL", "c:\ecl\macros\CONFIG.ECL", 1 )

$Ans = MsgBox(36, "Eclipse", " Your machine will be automatically rebooted" & @CRLF & @CRLF & "We advise that you save any existing work and close down your open applications."& @CRLF & @CRLF &" Do you wish to proceed ?")

If $Ans = 6 Then

shutdown(6)

EndIf

Exit

Link to comment
Share on other sites

Hi. Just ideas but did you try playing with ProcessClose, ProcessExists, ProcessWait, ProcessWaitClose ? Maybe that's what you would need.

p.s : type [auto.it] [/auto.it]

around your code to display it as autoitcode :) (remove the . of course)

Edited by MikeP
Link to comment
Share on other sites

Hi. Just ideas but did you try playing with ProcessClose, ProcessExists, ProcessWait, ProcessWaitClose ? Maybe that's what you would need.

p.s : type [auto.it] [/auto.it]

around your code to display it as autoitcode :) (remove the . of course)

Hi Mike I have tried ProcessWait, ProcessWaitClose with no luck, I am relying on the fact that setup.exe end as a result of the silent software install ending.

P.S.

Thanks for the tip

[codebox]
; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
;Or (StringInStr(RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","PATH"),"c:\ecl\home") == 0) Or (StringInStr(RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","PATH"),"c:\ecl\macros") == 0) Then

$answer = MsgBox(36, "Eclipse", " Please be aware that your system requires a reboot after Eclipse 2007.2 has been installed." & @CRLF & @CRLF & "We advise that you save any existing work and close down your open applications.")
; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
MsgBox(0, "Eclipse ", " OK. Bye!")
Exit
EndIf

If (RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path") == "") Then
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_EXPAND_SZ", "C:\ecl\home;C:\ecl\macros")
Else
$PATH = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path")
if StringInStr($PATH,"C:\ecl\home;C:\ecl\macros") >= 1 Then
Else
$PATH = $PATH & ";C:\ecl\home;C:\ecl\macros"
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_EXPAND_SZ", $PATH)
EndIf
EndIf


if (FileExists ( "C:\ecl\2007.2\bin\pc\eclipse.exe" )) Then
MsgBox(64, "Eclipse", "Eclipse has already been installed on your machine")
Exit
Else
if FileExists("C:\ecl" ) == 0 Then
$PID=Run("c:\setup.exe /s /f1\c:\setup.iss")
Else
$PID=Run("\setup.exe /s /f1c:\Eclipse_2007_2.iss")

EndIf
EndIf

If (RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","LM_LICENSE_FILE") == "") Then
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "LM_LICENSE_FILE", "REG_SZ", "1751@license01")
Else
$LM_LICENSE_FILE = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","LM_LICENSE_FILE")
if StringInStr($LM_LICENSE_FILE,"1751@license01") >= 1 Then
Else
$LM_LICENSE_FILE = "1751@license01;" & $LM_LICENSE_FILE
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "LM_LICENSE_FILE", "REG_SZ", $LM_LICENSE_FILE)
EndIf
EndIf

While ProcessWaitClose ($PID)
Sleep(10000)
WEnd

;Copy eclrc.bat file for eclipse 2007.2 to ecl home directory

FileCopy ( "\\techdata\$eclrc_xp_2007.2.bat", "c:\ecl\home\eclrc.bat", 1 )

;Copy config file to ecl macros area

; FileCopy ( "\\techdata\data\\CNFIG.ECL", "c:\ecl\macros\CONFIG.ECL", 1 )

$Ans = MsgBox(36, "Eclipse", " Your machine will be automatically rebooted" & @CRLF & @CRLF & "We advise that you save any existing work and close down your open applications."& @CRLF & @CRLF &" Do you wish to proceed ?")
If $Ans = 6 Then
shutdown(6)
EndIf

Exit
[/codebox]
Link to comment
Share on other sites

...

I suspect the autoit script is some how keeping the setup.exe active, can anyone please point me in the right direction to resolve this issue I have also tried using RunWait, ShellExecute and ShellExecuteWait.

...

I am not aware of an issue like a script keeping a setup process open as you mention. I do know that Installshield setups can immediately return because the setup extracts and runs a secondary process to handle the installation i.e setup.exe is just an archive of sort. I use the /sms switch on Installshield setups to force the setup to wait until the spawned process exits. I made some subtle changes with your code so give it a try.

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
;Or (StringInStr(RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","PATH"),"c:\ecl\home") == 0) Or (StringInStr(RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","PATH"),"c:\ecl\macros") == 0) Then

$answer = MsgBox(36, "Eclipse", _
        " Please be aware that your system requires a reboot after Eclipse 2007.2 has been installed." & _
        @CRLF & @CRLF & _
        "We advise that you save any existing work and close down your open applications.")
; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(0, "Eclipse ", " OK. Bye!")
    Exit
EndIf

If (RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path") == "") Then
    RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_EXPAND_SZ", "C:\ecl\home;C:\ecl\macros")
Else
    $PATH = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path")
    If Not StringInStr($PATH, "C:\ecl\home;C:\ecl\macros") Then
        $PATH &= ";C:\ecl\home;C:\ecl\macros"
        RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_EXPAND_SZ", $PATH)
    EndIf
EndIf


If FileExists("C:\ecl\2007.2\bin\pc\eclipse.exe") Then
    MsgBox(64, "Eclipse", "Eclipse has already been installed on your machine")
    Exit
ElseIf Not FileExists("C:\ecl") Then
    $exitcode = RunWait('c:\setup.exe /s /sms /f1"c:\setup.iss"')
Else
    $exitcode = RunWait('\setup.exe /s /sms /f1"c:\Eclipse_2007_2.iss"')
EndIf

If (RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "LM_LICENSE_FILE") == "") Then
    RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "LM_LICENSE_FILE", "REG_SZ", "1751@license01")
Else
    $LM_LICENSE_FILE = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "LM_LICENSE_FILE")
    If Not StringInStr($LM_LICENSE_FILE, "1751@license01") Then
        $LM_LICENSE_FILE = "1751@license01;" & $LM_LICENSE_FILE
        RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "LM_LICENSE_FILE", "REG_SZ", $LM_LICENSE_FILE)
    EndIf
EndIf

;Copy eclrc.bat file for eclipse 2007.2 to ecl home directory

FileCopy("\\techdata\$eclrc_xp_2007.2.bat", "c:\ecl\home\eclrc.bat", 1)

;Copy config file to ecl macros area

; FileCopy ( "\\techdata\data\\CNFIG.ECL", "c:\ecl\macros\CONFIG.ECL", 1 )

$Ans = MsgBox(36, "Eclipse", _
        " Your machine will be automatically rebooted" & _
        @CRLF & @CRLF & _
        "We advise that you save any existing work and close down your open applications." & _
        @CRLF & @CRLF & _
        " Do you wish to proceed ?")
If $Ans = 6 Then
    Shutdown(6)
EndIf

:)

Link to comment
Share on other sites

Hi Holden,

there's no way it's an AutoIt issue: Run() and others don't force child processes to wait. But I ran some time into a similar problem when spawning child processes on Vista (no SP1) if parent was started with higher privileges (as admin) and UAC activated: children won't ever end themselves if they show no GUI.

There are some articles on this in the MS KB but for me they didn't help anything. :)

Edited by doudou

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCEĀ 

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