Jump to content

Run external application fails


LMTA
 Share

Recommended Posts

Hello AutoIT guru's,

Here is a little puzzle that I cannot solve for the moment, maybe someone is willing to puzzle with me?

We have an executable which we use to import files. This application is not visible, so to know if it is finished people have to start the taskmanager to see when it stops running. I thought I could make an easy AuotIT script, which will launch the application, wait until it is finished and provide feedback to the user.

What I came up with so far, is the following:

$Import = Run("C:\Appdir\Application.exe", "C:\Appdir")

SplashTextOn ( "Importing", "Files are being imported, this will take some time." & @CRLF & "One moment please...", 285, 95, -1, -1, 20, "", 8, -1)
$Proces = ProcessWaitClose ($Import)

If @error = 1 Then
    SplashOff ()
    MsgBox(262160, "Importing", "Error:" & @CRLF & "The process did not start properly!" & @CRLF & "Please try to re-run this script.")
Else
    SplashOff ()
    MsgBox(262208, "Importing", "The file import finished.")
EndIf

Exit

However, the external program is not started. If I replace the executable with e.g. 'Calc.exe' and rename this to 'Application.exe', the script runs fine: Calc is started, the Splash is shown with the message that files are being imported and when I manually close Calc the MsgBox is show that the file import finished. When I remove the 'Application.exe' I see the MsgBox that the process did not start properly.

When I switch back to the apllication.exe which it should be, the process does not start at all, it does not show up in the tasklist. When I fire the application.exe manually, it works as it should.

I tried to replace the Run command with ShellExecute, but that does not help. Does someone has an idea what to try next?

Thanks in forward for your suggestions and with regards,

Steve.

Edited by LMTA
Link to comment
Share on other sites

Hi,

try this:

SplashTextOn ( "Importing", "Files are being imported, this will take some time." & @CRLF & "One moment please...", 285, 95, -1, -1, 20, "", 8, -1)
RunWait (@ComSpec & " /c C:\Appdir\Application.exe", "C:\Appdir", @SW_HIDE)
;$Import = Run(@ComSpec & " /c  C:\Appdir\Application.exe", "C:\Appdir")
;$Proces = ProcessWaitClose ($Import)

If @error = 1 Then
    SplashOff ()
    MsgBox(262160, "Importing", "Error:" & @CRLF & "The process did not start properly!" & @CRLF & "Please try to re-run this script.")
Else
    SplashOff ()
    MsgBox(262208, "Importing", "The file import finished.")
EndIf

Exit

;-))

Stefan

P.S: Try also Function _RunDos, see helpfile...

Edited by 99ojo
Link to comment
Share on other sites

Thanks again for your suggestion.

I have been trying it out, but the result is the same so far.

I will read about the _RunDOS function to see if this could help and report the progress here.

Edited by LMTA
Link to comment
Share on other sites

Hi there,

Status update: solved.

Thanks Stefan for your input about this;

After all, the problem was not realted to the script itself:

The date/time format for the user profile was not set the way is should have been, which caused the application.exe not being able to start properly.

The software is running on a Windows 2003 server, so the RequireAdmin statement was not needed in this case. Thanks for the insight and thanks for all help!

Edited by LMTA
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...