News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Win7 WINAPI command COPYFILE and symbolic links

Started by MtheK, July 18, 2014, 07:52:24 AM

Previous topic - Next topic

MtheK

  The WINAPI doc:

BOOL WINAPI CopyFile(
  _In_  LPCTSTR lpExistingFileName,
  _In_  LPCTSTR lpNewFileName,
  _In_  BOOL bFailIfExists
);

Symbolic link behavior—If the source file is a symbolic link,
the actual file copied is the target of the symbolic link.

If the destination file already exists and is a symbolic link,
the target of the symbolic link is overwritten by the source file.

---

Symbolic Links
A symbolic link is a file-system object that points to another file
system object. The object being pointed to is called the target.

===

  So, as shown when r-clicking my .lnk DSN w/explorer/Properties/Shortcut/Target:

C:\Windows\System32\cmd.exe /k "c: & cd \xxx & c:\xxx\NOTIFY.BAT -1 c:\xxx\ & EXIT"

what is the the "target of the symbolic link" ? cmd.exe? The .BAT? Nothing?

  In my MASM testing, when the target doesn't exist, the actual .lnk
file is copied. It's also copied even IF the target exists (ie: from a
previous run). Both the old source and the new/replaced target show
the Shortcut info as I expect, and are the same.

  I actually want that (for incremental backup w/DSNTODAY w/clones),
but wonder if it may NOT in a future OS. What am I missing here? Thankx...

sinsi

Pretty sure that a symbolic link (junction, reparse point) isn't the same as a shortcut (.lnk)

dedndave

sinsi is right, of course - a symbolic link is nothing like a shortcut
i almost never use them, so i forget most of the details - lol

but, if you remember DOS Append, and a couple other commands,
you could make "alias" path names for real paths
for example, i could make F:\data look like the drive R: (when there is no physical R: drive)
that's an example of a  symbolic link

a .LNK shortcut is a small file that holds information about a real file, including it's physcial path
when you clink on the shortcut, the OS finds the real file and opens it, as though you had clicked on it
many desktop icons are shortcuts
i sometimes create them for testing, as you can start a program minimized, maximized, etc


MtheK

  I ended up using INVOKE CopyFileEx with COPY_FILE_COPY_SYMLINK.
  Running a 'dir /aL /s \' from the root shows them all on a drive.
  And all this now FINALLY solves/identifies the ERROR_ACCESS_DENIEDs
I get after an INVOKE FindFirstFileA/FindNextFile, most all in \Users.