How to make symbolic links in windows via Ansible ?

769 views
Skip to first unread message

ishan jain

unread,
Feb 11, 2016, 9:47:40 AM2/11/16
to Ansible Project
I am trying to make a lot symbolic links for my directories and files and manually i use mklink command to make them. Oddly enough, this command requires admin level privileges to create links. 

How can i use mklink via ansible with admin privileges to create symbolic links ?

J Hawkesworth

unread,
Feb 11, 2016, 11:45:19 AM2/11/16
to Ansible Project
Obviously you will need to connect as an Administrator user.

You don't mention which version of windows you are controlling but you may just need to temporarily disable UAC prompt for Administrator users.

On Server 2012 the setting for this is in

 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
ConsentPromptBehaviorAdmin
0

set it back to 2 to restore current default behaviour.

Hope this helps.  I have not used mklink though.

Jon

ishan jain

unread,
Feb 12, 2016, 4:07:08 AM2/12/16
to Ansible Project
Hi Jon,

I am using windows server 2012 R2. Disabling UAC doesn't seem like a good idea, specially with my automation scripts on a regular basis. I am connecting via admin account obviously but that doesn't seem to be enough for making a symlink. I will have to start a command shell using 'Run as admin'.
Reply all
Reply to author
Forward
0 new messages