0

If I manually run the following command in Windows, it runs fine and creates the Junction Directory.

mklink /j "c:\Users\userid\OneDrive - Enterprise 365\backup\C\Users\userid\test" c:\Users\userid\test

But, if I do it programmatically with Go, using the following code, it comes back with Local NTFS volumes are required to complete the operation.

mklink := "mklink /j \"c:\\Users\\userid\\OneDrive - Enterprise 365\\backup\\C\\Users\\userid\\test\\\" c:\\Users\\userid\\test"

cmd := exec.Command("cmd", "/c", mklink)
out, err = cmd.CombinedOutput()

I've tried it a few different ways, but always getting the same result.

Any ideas?

xil3
  • 16,305
  • 8
  • 63
  • 97

1 Answers1

0

I was able to get it working by using PowerShell instead.

mklink := `New-Item -ItemType Junction -Path "c:\\Users\userid\OneDrive - 
Enterprise 365\backup\C\Users\userid\test" -Target c:\\Users\userid\test`

cmd := exec.Command("PowerShell", "-Command", mklink)
out, err = cmd.CombinedOutput()

I'm assuming the issue was the way that GoLang was sending the embedded quotes - cmd was interpreting them incorrectly. PowerShell seems to be a lot more 'forgiving'.

xil3
  • 16,305
  • 8
  • 63
  • 97