Copy file with elevated privileges

delphi, permissions, windows

Solution

You could prompt the user to enter credentials for a user with elevated permissions and then temporarily operate under that other user's login while writing to the network share. To do this, you are looking for the `LogonUser` and `ImpersonateLoggedOnUser` functions. Please see this answer.

Problem

Is there a way to elevate privileges to the level required to write files to a network folder with our Delphi 2006 (Win32) application? The user running the application does not have permission to write (or view) files in the network folder in question. Any recommended techniques or alternative suggestions?

Original source