Jump to content
Sign in to follow this  

Run reports 'access denied'

Recommended Posts


I have used AutoIt successfully for several years, and was quite surprised yesterday when a script I had used for 2.5 years failed to run a program. I have been unable to determine the cause of the problem. I did update from AutoIt 3.1 to 3.2 in the hope of finding better tools to track the problem down, and I was really impressed with the SciTE development environment. I created a simpler version of the script which duplicates the problem, which is here:


$file = "notepad2.exe"

$dir = "C:\Documents and Settings\Ken Johnson\Desktop\"

$longname = FileGetLongName ( $dir & $file )

$attrib = FileGetAttrib ( $dir & $file )

$size = FileGetSize ( $dir & $file )

$modified = FileGetTime ( $dir & $file, 0, 1)

$created = FileGetTime ( $dir & $file, 1, 1)

$accessed = FileGetTime ( $dir & $file, 2, 1)

$Comments = FileGetVersion ( $dir & $file, "Comments" )

ConsoleWriteError ( "LongName : " & $longname & @LF )

ConsoleWriteError ( "Attributes : " & $attrib & @LF )

ConsoleWriteError ( "Size : " & $size & @LF )

ConsoleWriteError ( "Modified : " & $modified & @LF )

ConsoleWriteError ( "accessed : " & $accessed & @LF )

ConsoleWriteError ( "created : " & $created & @LF )

ConsoleWriteError ( "Comments : " & $Comments & @LF )

Run ( $dir & $file, $dir )


The notepad2.exe program is Florian Balmer's Scintilla-based editor.

Here's the output in the SciTE debug window:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\Ken Johnson\Desktop\minimumFail.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams

+>12:59:37 Starting AutoIt3Wrapper v. Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 2 CPU:X86)

>Running AU3Check ( from:C:\Program Files\AutoIt3

+>12:59:38 AU3Check ended.rc:0

>Running:(\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\Ken Johnson\Desktop\minimumFail.au3"

LongName : C:\Documents and Settings\Ken Johnson\Desktop\Notepad2.exe

Attributes : A

Size : 552960

Modified : 20040625000000

accessed : 20080313125921

created : 20080313123000

Comments : Notepad2 is FREEWARE!

C:\Documents and Settings\Ken Johnson\Desktop\minimumFail.au3 (23) : ==> Unable to execute the external program.:

Run( $dir & $file, $dir )

Access is denied.

->12:59:38 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 1.585

The output from the results of the FileGet... calls convince me that the $dir and $file variables are set the way I expect. It also tells me that the file I'm trying to run really exists. The script also fails with the same error if I just double-click on the script icon. The system is running Windows XP, with SP2 and patches at least through Jan 2008, the account is a member of Administrators. A double-click on the desktop icon for Notepad2.exe runs the program. Notepad2 also runs if I set a command prompt window to the desktop directory and type notepad2.exe

I would be extremely pleased to receive suggestions on how to gather more information about what is going wrong. Thank you.

Share this post

Link to post
Share on other sites

A useful suggestion to learn more about this problem is to run the SysInternals/Microsoft filemon tool, with a filter string of "autoit".

A change that fixes the problem seen in this example program is to change the run function to look like this (34 decimal is the ascii double quote):

Run ( Chr ( 34 ) & $dir & $file & Chr ( 34 ), $dir )

This change also fixes the current version of the 'real' script. (which wasn't under source code control, unfortunately.) I'm still not clear on why the script stopped working, but I do have a solution.

Share this post

Link to post
Share on other sites

First version of this post deleted after I saw the second post.

The reason for the problem is the spaces in the path.

So this should also work

Run('"' & $dir & $file & '"','"' & $dir'"'); '"' is an inverted comma then a quotation mark then an inverted comma

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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