[python-win32] win32file.CreateSymbolicLink and

Roger Upole rwupole at msn.com
Thu Jun 18 08:11:56 CEST 2009


Devin Jeanpierre wrote:
> I'm new to pywin32 development, but wanted to toy with creating
> symlinks (and related new things) with a similar API to the current os
> module. The documentation in pywin32 states that the only flag is
> "SYMLINK_FLAG_DIRECTORY" (MSDN docs state that in the C++ API, the
> only flag is "SYMBOLIC_LINK_FLAG_DIRECTORY"). I don't know where to
> find it; the examples that were provided showed flags being in the
> same module, such as "win32pdh.PERF_DETAIL_WIZARD", but there is no
> win32file.SYMLINK_FLAG_DIRECTORY on my install, nor is there a
> win32file.SYMBOLIC_LINK_FLAG_DIRECTORY (in fact, nothing of the form
> win32file.SYM*). I could find no dedicated constants/flags module or
> submodule. I would appreciate some help finding the constant (for now,
> I am using the magic number 1 as described in the MSDN docs).
>
> Also, it appears that CreateSymbolicLink raises an exception in some
> failure circumstances (when the location that the symlink would be is
> already taken up by something), but not others (when the user doesn't
> have the appropriate permissions for creating symbolic links).
>
> Devin Jeanpierre

Some previous versions of the MSDN docs listed the name incorrectly.
I'll make sure the correct name shows up in the help file and one
of the constants modules in the next build.

Regarding the permissions, I get this traceback when attempting to
execute the function without SeCreateSymbolicLinkPrivilege
enabled:

Traceback (most recent call last):
  File 
"J:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", 
line 325, in RunScript
    exec codeObject in __main__.__dict__
  File "V:\Users\Public\Documents\py\test_CreateSymbolicLink.py", line 19, 
in ?
    win32file.CreateSymbolicLink(fname2,fname1,Transaction=trans)
error: (1314, 'CreateSymbolicLink', 'A required privilege is not held by the 
client.')

How are you verifying that the function failed ?

        Roger



More information about the python-win32 mailing list