Sign in to follow this  
Followers 0
Andy2k14

Unhandled Exception Error Help

8 posts in this topic

Hello All,

recently i have been trying to use Autoit to open an application. I have successfully used Autoit to load the app but have encountered a strange problem where once the App has been opened using AutoIT an Unhandled Exception Error is produced.

This error does not appear if i manually open the App, therefore i think it has something to do with AutoIt.

The script code i am using is:

#include <Constants.au3>
#include <MsgBoxConstants.au3>

run("C:\MyApp\MyApp.exe", "C:\MyApp", @SW_SHOWMAXIMIZED)

winwait("[TITLE:MyApp]")

Exit

As you can see its a very basic script. There is a clear difference between autoit opening the App and manually opening the App.

The error message i get is:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Invalid name.
Parameter name: name
   at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
   at System.Security.AccessControl.FileSystemSecurity..ctor(Boolean isContainer, String name, AccessControlSections includeSections, Boolean isDirectory)
   at System.Security.AccessControl.DirectorySecurity..ctor(String name, AccessControlSections includeSections)
   at TrwVisionClient.Model.PgmWriter.HasWriteAccess(String path)
   at TrwVisionClient.Presenter.MainPresenter.View_OnGetPgmRequest()
   at TrwVisionClient.View.MainView.StartCommButtonClick(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
TrwVisionClient
    Assembly Version: 3.0.2.0
    Win32 Version: 3.0.2.0
    CodeBase: file:///C:/MyApp/MyApp.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
CommandLine
    Assembly Version: 1.9.71.2
    Win32 Version: 1.9.71.2
    CodeBase: file:///C:/MyApp/CommandLine.DLL
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
PgmDownloader
    Assembly Version: 1.0.0.8
    Win32 Version: 1.0.0.8
    CodeBase: file:///C:/MyApp/PgmDownloader.DLL
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
4ruj2ecw
    Assembly Version: 3.0.2.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
vxlapi_NET20
    Assembly Version: 8.3.4737.17695
    Win32 Version: 8.3.4737.17695
    CodeBase: file:///C:/MyApp/vxlapi_NET20.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Ive also attached a screenshot of the error.

Can anyone help?

Thanks

 

post-85924-0-90077600-1400054527_thumb.p

Share this post


Link to post
Share on other sites



Yes i have just tried it and it produces the same error.

Very frustrating problem.

Share this post


Link to post
Share on other sites

Hi,

I think is a path dependancy.

Try to run script in the same directory of your application.

Check this:

EnvSet()

Cheers.


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Maybe I missed it, but which version of AutoIt do you run? Which operating system? 32 or 64 bit? Did you compile the AutoIt script for 32 or 64 bit? ...


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I faced the same problem before and didn't find a solution to it, didn't bother asking the forums because it was an auto login script that I tried to make for a game, tried running the client using autoit and I encountered a similar error.

Share this post


Link to post
Share on other sites

The error you're seeing is a .NET native message box for showing exceptions in compiled programs. It's nothing related to AutoIt.

I believe that the app you're trying to start does not like being a child process. If you use ShellExecute or Run commands, then the app you're trying to start will act as a child process of the process that started it. To test this you can download Process Explorer and try to start "notepad.exe" from ShellExecute or Run. You'll notice that the "notepad.exe" is now a child process of your autoit's script.

If that is indeed the case, then this might help:
 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>

;set your app destination here:
$AppThatIWantToStart = "C:\Windows\notepad.exe"; REQUIRES FULL DESTINATION if outside of %windir%, but in this case I could have just written: "notepad.exe" because "notepad.exe" is indeed in the %windir%

$Form1 = GUICreate("Form1", 300, 100)
$Button1 = GUICtrlCreateButton("start APP", 0, 0, 300, 50)
$Button2 = GUICtrlCreateButton("start APP alternative", 0, 50, 300, 50)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ShellExecute($AppThatIWantToStart)
        Case $Button2
            ShellExecuteNoParrent($AppThatIWantToStart, "", "/MAX");/MAX will maximize it, for other options check this link: http://ss64.com/nt/start.html
            if @error then MsgBox(0, "error", "could not start your program")
    EndSwitch
WEnd

Func ShellExecuteNoParrent($fileName, $parameters = "", $options = "", $title = "", $command = "")
    $tempFile = @TempDir & "\tempStartMyApp.bat"
    if StringLen($options) > 0 then $options = " " & $options
    $title = ' "' & $title & '"'
    if StringLen($command) > 0 then $command = ' "' & $command & '"'
    if StringLen($parameters) > 0 then $parameters = " " & $parameters
    $scriptLines = "@echo off" & @CRLF & 'START ' & $options & $title & ' "' & $fileName & '"' & $command & $parameters
    $FileHandle = FileOpen($tempFile, $FO_UTF8_NOBOM + $FO_OVERWRITE)
    if @error then Return SetError(1, 0, 0)
    FileWrite($FileHandle, $scriptLines)
    FileClose($FileHandle)
    ShellExecuteWait("tempStartMyApp.bat", Default, @TempDir, Default, @SW_HIDE)
    FileDelete($tempFile)
EndFunc

First button will start the app normally (and you can see that your app - notepad.exe, is now a child of your script), and the 2nd button will start the app as it's being started from a windows native "run" dialog box (where parent is "explorer.exe").

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