Symlinks on windows?

NTFS file system has junction points, I think you may use them instead, You can use python win32 API module for that e.g.

import win32file

win32file.CreateSymbolicLink(fileSrc, fileTarget, 1)

If you do not want to rely on win32API module, you can always use ctypes and directly call CreateSymbolicLink win32 API e.g.

import ctypes

kdll = ctypes.windll.LoadLibrary("kernel32.dll")

kdll.CreateSymbolicLinkA("d:\\test.txt", "d:\\test_link.txt", 0)

MSDN (http://msdn.microsoft.com/en-us/library/aa363866(VS.85).aspx) says Minimum supported client is Windows Vista

In addition: This also works with directories (indicate that with the third argument). With unicode support it looks like this:

kdll.CreateSymbolicLinkW(UR"D:\testdirLink", UR"D:\testdir", 1)

also see
Create NTFS junction point in Python

Leave a Comment