Jump to content

Recommended Posts

Posted

Hi

I have problem in the section 2 the filedelete not works , but if I separate the section 2 and run it in a separte script it works what is the problem?

 

;#NoTrayIcon
#include <File.au3>
#include <Date.au3>

;----------------------------------------------------- Section 1 --------------------------------------------------------------------------

$Folder = "C:\windows\temp"                          
   $Run = "Test.exe"                              
    
FileSetAttrib($Folder & "\*", "-R+SH",1)  

Run($Run)
ProcessWaitClose($Run)

$test = _FileListToArray($Folder)

If IsArray($test) Then
    For $i = 1 To UBound($test) - 1
        $tijd = StringRegExpReplace(FileGetTime($Folder & $test[$i], 1, 1), "(.{4})(.{2})(.{2})(.{2})(.{2})(.{2})", "${1}/${2}/${3} ${4}:${5}:${6}")
        If _DateDiff('D', $tijd, _NowCalc()) = 0 Then
            FileDelete($Folder & $test[$i])
            DirRemove ($Folder & $test[$i])
        
        EndIf
    Next
EndIf

FileSetAttrib($Folder1, "-RSH",1)                



;--------------------------------------------------------- Section 2 --------------------------------------------------------------------------------

FileSetAttrib(@TempDir & "\Test.exe", "-R+SH", 1)     
FileSetAttrib(@TempDir & "\start.exe", "-R+SH", 1)     

FileSetAttrib(@TempDir & "\Test.exe", "-RSH", 1)
FileSetAttrib(@TempDir & "\Start.exe", "-RSH", 1)           
FileDelete(@TempDir & "\Test.exe")
FileDelete(@TempDir & "\start.exe")
Exit

;-----------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

  • Moderators
Posted

Borje,

Are you sure that @TempDir is actually returning "C:\windows\temp" as your script assumes? When I look at that macro it returns "C:\Users\Melba23\AppData\Local\Temp".....

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Hi Melba23
I've checked it out, I've tried to separate these two script sections 1 and section 2 and when I run them separately they work separately. but if I have both section 1 and section 2 in the same script, then what's in section 2 does not work. What can it be?

  • Moderators
Posted

Borje,

Quote

I've checked it out

And what was the result? It seems to me that the first section is using "C:\windows\temp" as the path for the files while the second is using @TempDir - which as I showed above is not the same on my machine. Hence my question as to what @TempDir returns on your machine. I suggest that you add some ConsoleWrite statements to check what you are actually passing as filepaths to the various AutoIt commands.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

Borje,

And where are Start.exe and Test.exe located?

Please do as I suggested above  - add some Consolewrites to check the actual file paths being passed to the commands.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
×
×
  • Create New...