why filecopy for dll doesn't work?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
newcod3r
Posts: 505
Joined: 30 Sep 2021, 02:16

why filecopy for dll doesn't work?

Post by newcod3r » 27 Mar 2023, 02:36

Code: Select all

::;7::
If RunAsAdmin("FileCopy, C:\Dropbox\AppsPanelBL.dll, C:\Program Files (x86)\Common Files\Adobe\Adobe Desktop Common\AppsPanel\AppsPanelBL.dll")
{
    MsgBox, The file was copied successfully.
}
else
{
    MsgBox, There was an error copying the file.
}
return

RunAsAdmin(command)
{
    shell := ComObjCreate("Shell.Application")
    if !shell.IsRestricted("System", "EnableLUA")
    {
        try
        {
            shell.ShellExecute(command, "", "", "runas")
            return true
        }
        catch
        {
            ; Error occurred while elevating
        }
    }
    return false
}
when copy pasting it manually, it works, but not through ahk. it is running with elevated privileges already.

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

Re: why filecopy for dll doesn't work?

Post by mikeyww » 27 Mar 2023, 07:06

Hi,

Here is an "exec" script from @teadrinker. viewtopic.php?p=493956#p493956

newcod3r
Posts: 505
Joined: 30 Sep 2021, 02:16

Re: why filecopy for dll doesn't work?

Post by newcod3r » 27 Mar 2023, 07:43

mikeyww wrote:
27 Mar 2023, 07:06
Hi,

Here is an "exec" script from @teadrinker. viewtopic.php?p=493956#p493956
thanks! it shows the correct msgbox. However, the date modified did not change. I verified that a manual copy/paste does update the "date modified" using the original source file date.

how is that possible?

Also, how do I automatically terminate whichever process is locking the .dll file before initiating a filecopy?

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

Re: why filecopy for dll doesn't work?

Post by mikeyww » 27 Mar 2023, 08:34

I do not have answers, but I suspect that your script failed because it uses an ineffective approach to the shell exec. Would try teadrinker's. Others here will know more about these DLL calls.

newcod3r
Posts: 505
Joined: 30 Sep 2021, 02:16

Re: why filecopy for dll doesn't work?

Post by newcod3r » 28 Mar 2023, 00:45

mikeyww wrote:
27 Mar 2023, 08:34
I do not have answers, but I suspect that your script failed because it uses an ineffective approach to the shell exec. Would try teadrinker's. Others here will know more about these DLL calls.
what I meant was after using teadrinker's script, it runs the correct msgbox,

Code: Select all

 MsgBox, The file was copied successfully.
BUT it did not actually copy (based on date modified).

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

Re: why filecopy for dll doesn't work?

Post by mikeyww » 28 Mar 2023, 06:00

If you have a faulty script, posting it will enable readers to examine it and help you. You could post it here or in the other thread that explains the technique and provides examples of it.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: why filecopy for dll doesn't work?

Post by swagfag » 28 Mar 2023, 09:12

i suggest u first use regular FileCopy in a regular, admin-elevated ahk script and check all error conditions described in the docs. then ull know why the copy is failing and u can start troubleshooting from there

Post Reply

Return to “Ask for Help (v1)”