I would like to create a soft symlink for a file from R on Windows (with Mklink ). It fails because I cannot tell R to "run it as an administrator." Is there any way to do this?
I managed to create hard symbolic links to files:
path_src <- file.path(tempdir(), "test.txt") write("Hello World!", file = path_src) path_tgt <- file.path(tempdir(), "test_symlink.txt") shell(sprintf("mklink /H %s %s", normalizePath(path_tgt, mustWork = FALSE), normalizePath(path_src) ))
Notice how the file in path_tgt reflects the changes made to path_src :
write("HELLO WORLD!", file = path_src, append = TRUE)
However, this fails:
path_tgt_2 <- file.path(tempdir(), "test_symlink_2.txt") > shell(sprintf("mklink /D %s %s", normalizePath(path_tgt_2, mustWork = FALSE), normalizePath(path_src) )) Ihre Berechtigungen reichen nicht aus, um diesen Vorgang auszufhren. Warning messages: 1: running command 'C:\Windows\system32\cmd.exe /c mklink /DC:\Users\Thyson\AppData\Local\Temp\Rtmpum73ZU\test_symlink_2.txt C:\Users\Thyson\AppData\Local\Temp\Rtmpum73ZU\test.txt' had status 1 2: In shell(sprintf("mklink /D %s %s", normalizePath(path_tgt_2, mustWork = FALSE), : 'mklink /DC:\Users\Thyson\AppData\Local\Temp\Rtmpum73ZU\test_symlink_2.txt C:\Users\Thyson\AppData\Local\Temp\Rtmpum73ZU\test.txt' Ausführung mit Fehlerkode 1 fehlgeschlagen
Note
Due to the German version of Windows, I cannot get errors in English. The first line corresponds to several lines: "You do not have enough authority to complete this process"
r symlink
Rappster
source share