Jump to content

AutoIT Fails to delete file(s) if it's run from a


 Share

Recommended Posts

Hi, i'm useing Bart's PE Builder to build system cd's

But but, when i run a script from the cd to do a copy, runwait > delete files the script don't delete the files..

But if i then copy the script to the Ramdrv the script works fine.

Can some one tell me how to get arount this prob.

Link to comment
Share on other sites

Hi, i'm useing Bart's PE Builder to build system cd's

But but, when i run a script from the cd to do a copy, runwait > delete files the script don't delete the files..

But if i then copy the script to the Ramdrv the script works fine.

Can some one tell me how to get arount this prob.

<{POST_SNAPBACK}>

When copying from cd the files will have read-only attribute set, just use the FileSetAttrib function on the files after copying to drive:

From help file

FileSetAttrib

--------------------------------------------------------------------------------

Sets the attributes of one or more files.

FileSetAttrib ( "file pattern", "+-RASHNOT" [, recurse])

Parameters

file pattern File(s) to change, e.g. C:\*.au3, C:\Dir

+-RASHNOT Attribute(s) to set/clear. e.g. "+A", "+RA-SH"

recurse [optional] If this is set to 1, then directories are recursed into. Default is 0 (no recursion).

Return Value

Success: Returns 1.

Failure: Returns 0 if encountered any errors.

Remarks

The file pattern cannot contain spaces!

The attributes that can be modified with the function are + or -:

"R" = READONLY

"A" = ARCHIVE

"S" = SYSTEM

"H" = HIDDEN

"N" = NORMAL

"O" = OFFLINE

"T" = TEMPORARY

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

@gafrost,

I tink the question is not related with copying but running the script from a CD.

@rex

can you post a script that reproduce your problem? Not sure what you are really doing.

Link to comment
Share on other sites

@gafrost,

I tink the question is not related with copying but running the script from a CD.

@rex

can you post a script that reproduce your problem? Not sure what you are really doing.

<{POST_SNAPBACK}>

This is the code i use.

filecopy(@ScriptDir & "\Files\File.exe", @TempDir , 1)
runwait(@Tempdir & "\File.exe")
filesetattrib(@TempDir & "\File.exe", "-R")
FileDelete(@TempDir & "\File.exe")
exit

But it's not deleting the file..

How ever if i copy the script to the ramdrive and then run the script ones again it deletes the file.

Therefore i thourght that the script woulden delete files, if run from a readonly location. (not the file to delete but the script :) )

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