FileRecycle only works from C:?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

FileRecycle only works from C:?

Post by Skrell » 12 Nov 2022, 10:09

This is a strange one, but I have a script that uses the FileRecycle command on any files I drop on a GUI. The script works perfectly when I run it off my C: but if I move the script to another partition (such as my I:) and run it it will fail to recycle files and just ignore the drag and drop. Any ideas? I tried running script as admin and the behavior was the same. Is there some permission I'm missing?

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: FileRecycle only works from C:?

Post by mikeyww » 12 Nov 2022, 10:11

Hi,

You can display the path of the files to be recycled, so that you know what it is.

You can display the ErrorLevel from the command, so that you know what it is.

You can post your script in a reply below.

Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

Re: FileRecycle only works from C:?

Post by Skrell » 12 Nov 2022, 10:28

Unfortunately it's a lot of code but I want to clarify that the issue is NOT the files I'm recycling...its the GUI itself (which calls FileRecycle) that seems to fail.

Here are some snippets:

Code: Select all

Gui, 2: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 2: Show, NA
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x204, "WM_RBUTTONDOWN")
; Get a handle to this window we have created in order to update it later
hwnd2 := WinExist()
winId2 = ahk_id %hwnd2%

2GuiDropFiles:
    Tooltip, Moving Files...
    Loop, parse, A_GuiEvent, `n
    {
       ; MsgBox, 4,, File number %A_Index% is:`n%A_LoopField% `n`nContinue?
       FileRecycle, %A_LoopField% 
       if ErrorLevel   ; i.e. it's not blank or zero.
          MsgBox, % "Failed to Recycle " A_LoopField
    }
    Tooltip, 
return

WM_RBUTTONDOWN(wParam, lParam)
{
    X := lParam & 0xFFFF
    Y := lParam >> 16
    if A_GuiControl
        Control := "`n(in control " . A_GuiControl . ")"
    ; ToolTip You left-clicked in Gui window #%A_Gui% at client coordinates %X%x%Y%.%Control%
    Menu, MyMenu, Show
}

WM_LBUTTONDOWN(wParam, lParam)
{
    global hwnd2
    X := lParam & 0xFFFF
    Y := lParam >> 16
    if A_GuiControl
        Control := "`n(in control " . A_GuiControl . ")"
    ; ToolTip You left-clicked in Gui window #%A_Gui% at client coordinates %X%x%Y%.%Control%
    MouseGetPos, , , currentHwnd
    WinGet, whwnd, ID, ahk_id %currentHwnd%
    If (whwnd == hwnd2)
    {
        Run, explorer.exe shell:RecycleBinFolder
    }
}

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: FileRecycle only works from C:?

Post by mikeyww » 12 Nov 2022, 10:35

If you see the MsgBox "Failed to recycle...", then it may be an issue of access rights to the file.

Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

Re: FileRecycle only works from C:?

Post by Skrell » 12 Nov 2022, 10:57

mikeyww wrote:
12 Nov 2022, 10:35
If you see the MsgBox "Failed to recycle...", then it may be an issue of access rights to the file.
I don't see that error. It's like Windows 10 treats the script different when run from I: vs C: Maybe I: executable's can't access the C: recycle bin?

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: FileRecycle only works from C:?

Post by mikeyww » 12 Nov 2022, 11:09

You can see whether the FileRecycle line is reached. Your commented MsgBox could achieve that. If the command is reached, the file is not recycled, and no error occurs, then it seems possible that the drive's operating system has interfered. It's conceivable that an error might not be generated even with some kinds of access problems. A workaround is to move the file into a "trash" folder that you create and then manage later.

Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

Re: FileRecycle only works from C:?

Post by Skrell » 05 Dec 2022, 17:48

This post can be closed as I simply gave up and just run my script off the C: and have no issues.

Post Reply

Return to “Ask for Help (v1)”