Privlege error trying to create symlink using python on windows 10 -


i attempting create symlink using python on windows 10 (home version) foll. code:

import ctypes  kdll = ctypes.windll.loadlibrary("kernel32.dll") kdll.createsymboliclinkw(src_dir, dst_dir, 1) 

but foll. error:

*** error: (1314, 'createsymboliclink', 'a required privilege not held client.') 

how fix this?

if uac enabled , user administrator, local security authority (lsa, hosted in lsass.exe) logs user on restricted access token. token, builtin\administrators group used denying access; integrity-level label medium instead of high; , privileges typically granted administrator have been filtered out.

to create symbolic link, need create process using unrestricted/elevated access token (i.e. elevated medium high integrity level). right-clicking , selecting "run administrator". elevated token inherited child processes, suffices run python script elevated command prompt, can open via keyboard shortcut win+x a. can verify cmd shell elevated running whoami /priv , checking presence of secreatesymboliclinkprivilege. don't alarmed if state disabled. windows createsymboliclink function automatically enables privilege.

that said, since you're creating directory symbolic link, perhaps junction work well. no special privilege required create junction. can create junction using cmd's mklink command. example:

subprocess.check_call('mklink /j "%s" "%s"' % (link, target), shell=true) 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -