6

I need to create a Symlink that lives in user roaming AppData, and points to a folder on another local drive, which is user specific. I have tried both mklink and New-Item -ItemType SymbolicLink in PowerShell 5 and both require admin rights, which makes it pretty useless in this context. I also tried putting the user environment variable in the path, like this D:\C4R\%username%, but that doesn't work either. Is there a mechanism for doing SymLinks as a regular user? Or is the whole concept of SymLinks really an admin thing?

1 Answer 1

7

You have to use the /J option

mklink /J <link> <target>

I don't know powershell, but this seems to work as well:

New-Item -Name <link> -ItemType Junction -Value <source>
4
  • 1
    @T Nierath That still requires elevated privileges. This page (sevenforums.com/tutorials/…) suggest that there is simply no way to do a SymLink without elevated privileges, but that seems kind, limiting.
    – Gordon
    Commented May 17, 2018 at 14:38
  • 1
    It really doesn't, try it out! Because you are creating a junction, not a symlink. I don't know why there is a difference, but junctions don't need admin rights, I just created one in my AppData dir to something on D:\ no problem.
    – T Nierath
    Commented May 17, 2018 at 14:39
  • 1
    I'm an idiot. I had copied a PS1 and shortcut to create a new test jig, and I hadn't noticed that the shortcut was set to Run as Administrator, so THAT was triggering the password, not the mklink IN the PS1. Now to find a way to run mklink without all the cruft in the console.
    – Gordon
    Commented May 17, 2018 at 14:48
  • Good to hear, I added a powershell solution.
    – T Nierath
    Commented May 17, 2018 at 15:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .