6

I need to do this without installing software...

Any ideas?

MSDOS (cmd.exe) on Windows XP

qodeninja
  • 2,723
  • 10
  • 31
  • 33

4 Answers4

9

Are you talking about MS-DOS or Windows XP?

Since it's likely that you're just talking about doing this from a command-prompt on Windows XP I'll answer for that case first... >smile<

On an NTFS volume under Windows XP you can use the "fsutil" tool to create a hard link:

fsutil hardlink create <destination filename> <source filename>

Both source and destination must be on the same NTFS volume.


MS-DOS only supports the FAT filesystem (in various flavors). FAT doesn't "officially" support hard links. You could create the effect of a hard link by having two directory entries that refer to the same FAT chain. This would be detected as an "error" by CHKDSK and repaired, however.

If you didn't mind manipulating directory structures by hand using DEBUG you could get this done w/o installing any software. It wouldn't be pretty, but it would work.

As I said, though, it's technically illegal to have two directory entries point to the same FAT chain. Running a disk defragmenter on such a volume would probably damage the filesystem. CHKDSK would definitely see such a "jury-rigged hard link" as a filesystem error.

Evan Anderson
  • 141,071
  • 19
  • 191
  • 328
  • ^_^ great. Let me try this. fsutil is available on here. – qodeninja Oct 16 '09 at 22:52
  • I'm surprised you didn't suggest getting the force-field microscope out and tweak the bits on the disk that way :D – Jonathan Leffler Oct 16 '09 at 23:12
  • @Jonathan: Nah-- the tunneling electron microscope isn't installed by default, and the poster didn't want to install anything. >smile< Using DEBUG to do things like that isn't *too* arcane. I've fixed up many a partiton table using DEBUG. – Evan Anderson Oct 17 '09 at 02:18
  • Cross-linking IS a fault condition and will, or at least should, be detected and repaired by all disk utilities that perform error checking. It will also seriously screw with things like defragmentation. Even, I'm really surprised you even contemplated such a suggestion. – John Gardeniers Oct 17 '09 at 04:45
  • 2
    @John: If it gets the job done, so be it. I say "technically illegal", "damage the filesystem", and "filesystem error" in my post. I can't be much more blunt than that. If the OP wants to damage his filesystem, he'll do it w/ or w/o my help. It just happens that I made a "trick" diskette several years ago (God... more than several) that I distributed at a "con" that had little tricks like that on it (and a custom boot sector that displayed a little graphical logo), so I'm familiar with the technique. Having said that, I'm sure he was looking for an NTFS hardlink anyway. – Evan Anderson Oct 17 '09 at 14:21
  • @Evan - this is great! A solution that does not require the download of a utility program. Just to make sure - all the dangers discussed above are relevant to the DOS hack, right? There is no harm in using fsutil for creating links in WinXP. Is that correct? – ysap May 05 '11 at 20:48
  • @ysap: You are correct re: the "DOS hack" and the relevance of my comments above. – Evan Anderson May 05 '11 at 21:00
  • "MS-DOS only supports the FAT filesystem" - that's not true, there are NTFS drivers for DOS. – Ivan Dec 14 '12 at 21:54
3

fsutil hardlink works only for files. If you want to make link to directory, you could use junction from sysinternals package.

Be aware: if you try to delete link, contents of destination directory would be also deleted. To remove link, you should use juncion -d switch.

You could recognize links in Total commander: they have different icon than directories. In windows explorer these links looks the same as any directory.

sumar
  • 2,086
  • 12
  • 12
  • 3
    NTFS junction points are a type of reparse point, and aren't the same thing as a hardlink. You're are absolutely technical correct when you say that you can only make hardlinks to files, but the mechanism that junction points work through is different than the mechanism that makes hardlinks work (namely different code in the NTFS driver). – Evan Anderson Oct 17 '09 at 14:23
  • +1 for Sysinternals' Junction, which worked. – JYelton May 30 '13 at 23:34
2

linkd.exe is found in the windows 2003 resource kit. I just tested this and it works better than NTFS junctions. If you can download linkd.exe and get it to work on XP you would be all set.

Drew M
  • 21
  • 1
1

First off, you better be aware that cmd.exe is NOT MS-DOS, and that there are no remaining vestiges of DOS in any version of Windows these days. DOS died following Windows 95/98/ME, XP and it's successors were built on NT, which never had any DOS in it. cmd.exe is a native Windows application that superficially appears as a command-line and is capable of accepting commands similar to old DOS commands, but it is NOT DOS.

Secondly, before you go creating hard links in Windows, you will want to have a read of, and understand, this: http://blogs.msdn.com/oldnewthing/archive/2009/09/28/9900082.aspx

Finally, to do the dirty work itself, use fsutil as Evan describes above, or as is documented here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/fsutil.mspx?mfr=true

Maximus Minimus
  • 8,937
  • 1
  • 22
  • 36