Sign in to follow this  
Followers 0
LMTA

Run external application fails

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You know you can always just make a batch script:

C:\Appdir\Application.exe
@echo Process finished!
pause

Then just wait for "Press any key to continue... to appear".

Edited by omikron48

Share this post


Link to post
Share on other sites

That is an option I thought about, thanks for the suggestion!

If I do not succeed with AutoIt I think that will become the workaround...

I do prefer to use AutoIt if possible, however.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Hi,

just a guess. If you have Vista or above running try #RequireAdmin in your script.

;-))

Stefan

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0