0

I'm trying to find out how to get the real path from .lnk files. I took this approach because the original files are in different locations and the routes have no pattern in its names. So I grouped a shortcuts of each file in a unique route. but still can't get the original routes automatically.

I need something like this:

files <- list.files(route, pattern = ".lnk", full.names = T)
real_path_files <- real_path(files) #using some function

I have R versión 4.4.0 so the packages "com" and "RDCOMClient" aren't availables. I say it because GPT suggested to me to use those packages. I believe (And I choose to believe) there is another way to solve this problem.

Any suggestions?

**** Aditional information ****

  read_raw <- function(x) {
    dput(readBin(x, raw(), n=file.info(x)$size))
  }

output:

lnk_bytes <- as.raw(c(0x4c, 0x00, 0x00, 0x00, 0x01, 0x14, 0x02, 0x00, 0x00, 
0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 
0x9b, 0x00, 0x08, 0x00, 0x20, 0x04, 0x00, 0x00, 0xa2, 0x88, 0x82, 
0x33, 0xff, 0xec, 0xda, 0x01, 0xa0, 0x5e, 0x08, 0x66, 0x00, 0xf4, 
0xda, 0x01, 0x70, 0xff, 0x86, 0x33, 0xff, 0xec, 0xda, 0x01, 0xdd, 
0x8d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0xfa, 0x03, 0x14, 0x00, 0x1f, 0x00, 0x89, 0x19, 0x27, 0x04, 
0xd2, 0xc4, 0x20, 0xa8, 0xed, 0x50, 0x62, 0xb6, 0x12, 0xf8, 0xa1, 
0xff, 0xa8, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x59, 
0x56, 0x76, 0x30, 0x04, 0x43, 0x47, 0x43, 0x20, 0x2d, 0x20, 0x33, 
0x30, 0x30, 0x2e, 0x43, 0x4f, 0x4e, 0x54, 0x52, 0x41, 0x54, 0x4f, 
0x53, 0x20, 0x2d, 0x20, 0x30, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 
0x72, 0x61, 0x74, 0x6f, 0x73, 0x00, 0x00, 0x76, 0x00, 0x09, 0x00, 
0x04, 0x00, 0xef, 0xbe, 0xc4, 0x58, 0x3b, 0xa0, 0x15, 0x59, 0xf0, 
0x94, 0x2e, 0x00, 0x00, 0x00, 0xc6, 0x52, 0x04, 0x00, 0x00, 0x00, 
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x70, 0x00, 0x90, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3e, 0x06, 0x00, 0x43, 0x00, 
0x47, 0x00, 0x43, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x33, 
0x00, 0x30, 0x00, 0x30, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 
0x4e, 0x00, 0x54, 0x00, 0x52, 0x00, 0x41, 0x00, 0x54, 0x00, 0x4f, 
0x00, 0x53, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x30, 0x00, 
0x31, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 
0x00, 0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 
0x00, 0x00, 0x32, 0x00, 0x80, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 
0x00, 0xc4, 0x58, 0x9b, 0xa9, 0x10, 0x04, 0x30, 0x38, 0x2e, 0x20, 
0x41, 0x53, 0x45, 0x53, 0x4f, 0x52, 0x49, 0x41, 0x20, 0x43, 0x4f, 
0x4e, 0x54, 0x52, 0x41, 0x54, 0x4f, 0x00, 0x5c, 0x00, 0x09, 0x00, 
0x04, 0x00, 0xef, 0xbe, 0xc4, 0x58, 0x12, 0xa3, 0x15, 0x59, 0xf0, 
0x94, 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x48, 0x06, 0x00, 0x00, 0x00, 
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x00, 0x90, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xe5, 0xc4, 0x00, 0x30, 0x00, 
0x38, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x41, 0x00, 0x53, 0x00, 0x45, 
0x00, 0x53, 0x00, 0x4f, 0x00, 0x52, 0x00, 0x49, 0x00, 0x41, 0x00, 
0x20, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x52, 
0x00, 0x41, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x24, 0x00, 
0x60, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x58, 0xd9, 
0xaa, 0x10, 0x04, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x74, 0x69, 
0x64, 0x61, 0x00, 0x00, 0x46, 0x00, 0x09, 0x00, 0x04, 0x00, 0xef, 
0xbe, 0xc4, 0x58, 0x2a, 0xa4, 0x15, 0x59, 0xf0, 0x94, 0x2e, 0x00, 
0x00, 0x00, 0x00, 0x15, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x1a, 0x60, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x58, 0x64, 0xf3, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x6d, 
0x00, 0x70, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 0x00, 
0x64, 0x00, 0x61, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x8a, 0x00, 0x31, 
0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x58, 0xa8, 0x99, 0x10, 0x04, 
0x48, 0x69, 0x74, 0x6f, 0x73, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x72, 
0x61, 0x63, 0x74, 0x75, 0x61, 0x6c, 0x65, 0x73, 0x5f, 0x32, 0x30, 
0x32, 0x34, 0x00, 0x00, 0x62, 0x00, 0x09, 0x00, 0x04, 0x00, 0xef, 
0xbe, 0xc4, 0x58, 0xd9, 0xaa, 0x15, 0x59, 0xf0, 0x94, 0x2e, 0x00, 
0x00, 0x00, 0xc9, 0x99, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x1a, 0x60, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x85, 0x13, 0x63, 0x00, 0x48, 0x00, 0x69, 0x00, 0x74, 
0x00, 0x6f, 0x00, 0x73, 0x00, 0x20, 0x00, 0x63, 0x00, 0x6f, 0x00, 
0x6e, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x63, 0x00, 0x74, 
0x00, 0x75, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x73, 0x00, 
0x5f, 0x00, 0x32, 0x00, 0x30, 0x00, 0x32, 0x00, 0x34, 0x00, 0x00, 
0x00, 0x28, 0x00, 0x4a, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x13, 0x59, 0x95, 0x74, 0x10, 0x04, 0x55, 0x53, 0x31, 0x00, 0x38, 
0x00, 0x09, 0x00, 0x04, 0x00, 0xef, 0xbe, 0xc4, 0x58, 0xf2, 0xaa, 
0x15, 0x59, 0xf0, 0x94, 0x2e, 0x00, 0x00, 0x00, 0x03, 0xa9, 0x0b, 
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 
0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0xfa, 0x29, 
0x01, 0x55, 0x00, 0x53, 0x00, 0x31, 0x00, 0x00, 0x00, 0x12, 0x00, 
0x60, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x58, 0x29, 
0x6f, 0x10, 0x04, 0x30, 0x36, 0x2e, 0x2d, 0x20, 0x4a, 0x75, 0x6e, 
0x69, 0x6f, 0x00, 0x00, 0x46, 0x00, 0x09, 0x00, 0x04, 0x00, 0xef, 
0xbe, 0xf1, 0x58, 0xb5, 0x6b, 0x15, 0x59, 0xf0, 0x94, 0x2e, 0x00, 
0x00, 0x00, 0x69, 0x76, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x1a, 0x60, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x9f, 0x18, 0xea, 0x00, 0x30, 0x00, 0x36, 0x00, 0x2e, 
0x00, 0x2d, 0x00, 0x20, 0x00, 0x4a, 0x00, 0x75, 0x00, 0x6e, 0x00, 
0x69, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x84, 0x00, 0x31, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x59, 0x20, 0xac, 0x10, 0x04, 
0x33, 0x2e, 0x20, 0x42, 0x75, 0x73, 0x65, 0x73, 0x20, 0x53, 0x75, 
0x6d, 0x69, 0x6e, 0x69, 0x73, 0x74, 0x72, 0x61, 0x64, 0x6f, 0x73, 
0x00, 0x00, 0x5e, 0x00, 0x09, 0x00, 0x04, 0x00, 0xef, 0xbe, 0xf1, 
0x58, 0xb5, 0x6b, 0x15, 0x59, 0xf0, 0x94, 0x2e, 0x00, 0x00, 0x00, 
0x6f, 0x76, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x1a, 0x60, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x3a, 0x06, 0xca, 0x00, 0x33, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x42, 
0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 
0x53, 0x00, 0x75, 0x00, 0x6d, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x69, 
0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x64, 0x00, 
0x6f, 0x00, 0x73, 0x00, 0x00, 0x00, 0x26, 0x00, 0xa4, 0x00, 0x32, 
0x00, 0xdd, 0x8d, 0x15, 0x00, 0x0c, 0x59, 0x20, 0xac, 0x20, 0x04, 
0x31, 0x33, 0x2e, 0x20, 0x44, 0x65, 0x62, 0x65, 0x72, 0x20, 0x64, 
0x65, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x72, 0x20, 
0x68, 0x29, 0x20, 0x69, 0x76, 0x29, 0x2e, 0x78, 0x6c, 0x73, 0x78, 
0x00, 0x74, 0x00, 0x09, 0x00, 0x04, 0x00, 0xef, 0xbe, 0x0c, 0x59, 
0x20, 0xac, 0x0c, 0x59, 0x20, 0xac, 0x2e, 0x00, 0x00, 0x00, 0xe5, 
0x42, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x1a, 0x20, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 
0x4e, 0xd3, 0x00, 0x31, 0x00, 0x33, 0x00, 0x2e, 0x00, 0x20, 0x00, 
0x44, 0x00, 0x65, 0x00, 0x62, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 
0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6e, 0x00, 
0x66, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x72, 
0x00, 0x20, 0x00, 0x68, 0x00, 0x29, 0x00, 0x20, 0x00, 0x69, 0x00, 
0x76, 0x00, 0x29, 0x00, 0x2e, 0x00, 0x78, 0x00, 0x6c, 0x00, 0x73, 
0x00, 0x78, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x1d, 0x01, 
0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 
0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x1c, 0x01, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 
0x00, 0xbe, 0x32, 0xdb, 0x9e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x43, 
0x3a, 0x5c, 0x55, 0x73, 0x65, 0x72, 0x73, 0x5c, 0x67, 0x6f, 0x6e, 
0x7a, 0x61, 0x6c, 0x6f, 0x2e, 0x73, 0x61, 0x6e, 0x64, 0x6f, 0x76, 
0x61, 0x6c, 0x5c, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 
0x69, 0x6f, 0x20, 0x64, 0x65, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 
0x70, 0x6f, 0x72, 0x74, 0x65, 0x73, 0x20, 0x50, 0xfa, 0x62, 0x6c, 
0x69, 0x63, 0x6f, 0x20, 0x4d, 0x65, 0x74, 0x72, 0x6f, 0x70, 0x6f, 
0x6c, 0x69, 0x74, 0x61, 0x6e, 0x6f, 0x5c, 0x43, 0x47, 0x43, 0x20, 
0x2d, 0x20, 0x33, 0x30, 0x30, 0x2e, 0x43, 0x4f, 0x4e, 0x54, 0x52, 
0x41, 0x54, 0x4f, 0x53, 0x20, 0x2d, 0x20, 0x30, 0x31, 0x2e, 0x43, 
0x6f, 0x6e, 0x74, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x5c, 0x30, 0x38, 
0x2e, 0x20, 0x41, 0x53, 0x45, 0x53, 0x4f, 0x52, 0x49, 0x41, 0x20, 
0x43, 0x4f, 0x4e, 0x54, 0x52, 0x41, 0x54, 0x4f, 0x5c, 0x43, 0x6f, 
0x6d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x64, 0x61, 0x5c, 0x48, 0x69, 
0x74, 0x6f, 0x73, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 
0x74, 0x75, 0x61, 0x6c, 0x65, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x34, 
0x5c, 0x55, 0x53, 0x31, 0x5c, 0x30, 0x36, 0x2e, 0x2d, 0x20, 0x4a, 
0x75, 0x6e, 0x69, 0x6f, 0x5c, 0x33, 0x2e, 0x20, 0x42, 0x75, 0x73, 
0x65, 0x73, 0x20, 0x53, 0x75, 0x6d, 0x69, 0x6e, 0x69, 0x73, 0x74, 
0x72, 0x61, 0x64, 0x6f, 0x73, 0x5c, 0x31, 0x33, 0x2e, 0x20, 0x44, 
0x65, 0x62, 0x65, 0x72, 0x20, 0x64, 0x65, 0x20, 0x69, 0x6e, 0x66, 
0x6f, 0x72, 0x6d, 0x61, 0x72, 0x20, 0x68, 0x29, 0x20, 0x69, 0x76, 
0x29, 0x2e, 0x78, 0x6c, 0x73, 0x78, 0x00, 0x00, 0xdd, 0x00, 0x2e, 
0x00, 0x2e, 0x00, 0x5c, 0x00, 0x2e, 0x00, 0x2e, 0x00, 0x5c, 0x00, 
0x2e, 0x00, 0x2e, 0x00, 0x5c, 0x00, 0x44, 0x00, 0x69, 0x00, 0x72, 
0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 
0x69, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 
0x00, 0x54, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x73, 0x00, 
0x70, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 
0x00, 0x20, 0x00, 0x50, 0x00, 0xfa, 0x00, 0x62, 0x00, 0x6c, 0x00, 
0x69, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x4d, 0x00, 0x65, 
0x00, 0x74, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x6f, 0x00, 
0x6c, 0x00, 0x69, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x6f, 
0x00, 0x5c, 0x00, 0x43, 0x00, 0x47, 0x00, 0x43, 0x00, 0x20, 0x00, 
0x2d, 0x00, 0x20, 0x00, 0x33, 0x00, 0x30, 0x00, 0x30, 0x00, 0x2e, 
0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x52, 0x00, 
0x41, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x20, 0x00, 0x2d, 
0x00, 0x20, 0x00, 0x30, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x43, 0x00, 
0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, 
0x00, 0x6f, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x30, 0x00, 0x38, 0x00, 
0x2e, 0x00, 0x20, 0x00, 0x41, 0x00, 0x53, 0x00, 0x45, 0x00, 0x53, 
0x00, 0x4f, 0x00, 0x52, 0x00, 0x49, 0x00, 0x41, 0x00, 0x20, 0x00, 
0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x52, 0x00, 0x41, 
0x00, 0x54, 0x00, 0x4f, 0x00, 0x5c, 0x00, 0x43, 0x00, 0x6f, 0x00, 
0x6d, 0x00, 0x70, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 
0x00, 0x64, 0x00, 0x61, 0x00, 0x5c, 0x00, 0x48, 0x00, 0x69, 0x00, 
0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x20, 0x00, 0x63, 0x00, 0x6f, 
0x00, 0x6e, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x63, 0x00, 
0x74, 0x00, 0x75, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x73, 
0x00, 0x5f, 0x00, 0x32, 0x00, 0x30, 0x00, 0x32, 0x00, 0x34, 0x00, 
0x5c, 0x00, 0x55, 0x00, 0x53, 0x00, 0x31, 0x00, 0x5c, 0x00, 0x30, 
0x00, 0x36, 0x00, 0x2e, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x4a, 0x00, 
0x75, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x5c, 0x00, 0x33, 
0x00, 0x2e, 0x00, 0x20, 0x00, 0x42, 0x00, 0x75, 0x00, 0x73, 0x00, 
0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 0x53, 0x00, 0x75, 0x00, 0x6d, 
0x00, 0x69, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 
0x72, 0x00, 0x61, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x5c, 
0x00, 0x31, 0x00, 0x33, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x44, 0x00, 
0x65, 0x00, 0x62, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x64, 
0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x66, 0x00, 
0x6f, 0x00, 0x72, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x72, 0x00, 0x20, 
0x00, 0x68, 0x00, 0x29, 0x00, 0x20, 0x00, 0x69, 0x00, 0x76, 0x00, 
0x29, 0x00, 0x2e, 0x00, 0x78, 0x00, 0x6c, 0x00, 0x73, 0x00, 0x78, 
0x00, 0xcc, 0x00, 0x43, 0x00, 0x3a, 0x00, 0x5c, 0x00, 0x55, 0x00, 
0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x67, 
0x00, 0x6f, 0x00, 0x6e, 0x00, 0x7a, 0x00, 0x61, 0x00, 0x6c, 0x00, 
0x6f, 0x00, 0x2e, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 
0x00, 0x6f, 0x00, 0x76, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x5c, 0x00, 
0x44, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 
0x00, 0x6f, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x20, 0x00, 
0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x54, 0x00, 0x72, 0x00, 0x61, 
0x00, 0x6e, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x72, 0x00, 
0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 0x50, 0x00, 0xfa, 
0x00, 0x62, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x63, 0x00, 0x6f, 0x00, 
0x20, 0x00, 0x4d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x72, 0x00, 0x6f, 
0x00, 0x70, 0x00, 0x6f, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x74, 0x00, 
0x61, 0x00, 0x6e, 0x00, 0x6f, 0x00, 0x5c, 0x00, 0x43, 0x00, 0x47, 
0x00, 0x43, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x33, 0x00, 
0x30, 0x00, 0x30, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 
0x00, 0x54, 0x00, 0x52, 0x00, 0x41, 0x00, 0x54, 0x00, 0x4f, 0x00, 
0x53, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x30, 0x00, 0x31, 
0x00, 0x2e, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 
0x72, 0x00, 0x61, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x5c, 
0x00, 0x30, 0x00, 0x38, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x41, 0x00, 
0x53, 0x00, 0x45, 0x00, 0x53, 0x00, 0x4f, 0x00, 0x52, 0x00, 0x49, 
0x00, 0x41, 0x00, 0x20, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 
0x54, 0x00, 0x52, 0x00, 0x41, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x5c, 
0x00, 0x43, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x61, 0x00, 
0x72, 0x00, 0x74, 0x00, 0x69, 0x00, 0x64, 0x00, 0x61, 0x00, 0x5c, 
0x00, 0x48, 0x00, 0x69, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 
0x20, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x72, 
0x00, 0x61, 0x00, 0x63, 0x00, 0x74, 0x00, 0x75, 0x00, 0x61, 0x00, 
0x6c, 0x00, 0x65, 0x00, 0x73, 0x00, 0x5f, 0x00, 0x32, 0x00, 0x30, 
0x00, 0x32, 0x00, 0x34, 0x00, 0x5c, 0x00, 0x55, 0x00, 0x53, 0x00, 
0x31, 0x00, 0x5c, 0x00, 0x30, 0x00, 0x36, 0x00, 0x2e, 0x00, 0x2d, 
0x00, 0x20, 0x00, 0x4a, 0x00, 0x75, 0x00, 0x6e, 0x00, 0x69, 0x00, 
0x6f, 0x00, 0x5c, 0x00, 0x33, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x42, 
0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 
0x53, 0x00, 0x75, 0x00, 0x6d, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x69, 
0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x64, 0x00, 
0x6f, 0x00, 0x73, 0x00, 0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 
0xa0, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x33, 
0x67, 0x73, 0x61, 0x6e, 0x64, 0x6f, 0x76, 0x61, 0x6c, 0x00, 0x00, 
0x00, 0x00, 0x00, 0xaa, 0xf1, 0x68, 0xa8, 0x25, 0xae, 0x1d, 0x4b, 
0xa3, 0x02, 0x6d, 0x67, 0x96, 0xd5, 0xe5, 0x5a, 0x01, 0x45, 0xb0, 
0x43, 0xcc, 0x5f, 0xef, 0x11, 0xa2, 0x65, 0x98, 0xfa, 0x9b, 0xcf, 
0xf8, 0x34, 0xaa, 0xf1, 0x68, 0xa8, 0x25, 0xae, 0x1d, 0x4b, 0xa3, 
0x02, 0x6d, 0x67, 0x96, 0xd5, 0xe5, 0x5a, 0x01, 0x45, 0xb0, 0x43, 
0xcc, 0x5f, 0xef, 0x11, 0xa2, 0x65, 0x98, 0xfa, 0x9b, 0xcf, 0xf8, 
0x34, 0x95, 0x05, 0x00, 0x00, 0x09, 0x00, 0x00, 0xa0, 0x71, 0x00, 
0x00, 0x00, 0x31, 0x53, 0x50, 0x53, 0xe0, 0x85, 0x9f, 0xf2, 0xf9, 
0x4f, 0x68, 0x10, 0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9, 
0x55, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x10, 
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x47, 
0x00, 0x6f, 0x00, 0x6e, 0x00, 0x7a, 0x00, 0x61, 0x00, 0x6c, 0x00, 
0x6f, 0x00, 0x20, 0x00, 0x41, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x72, 
0x00, 0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 0x53, 0x00, 0x61, 0x00, 
0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x76, 0x00, 0x61, 0x00, 0x6c, 
0x00, 0x20, 0x00, 0x47, 0x00, 0x75, 0x00, 0x65, 0x00, 0x72, 0x00, 
0x72, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x09, 0x01, 0x00, 0x00, 0x31, 0x53, 0x50, 0x53, 0x30, 0xf1, 
0x25, 0xb7, 0xef, 0x47, 0x1a, 0x10, 0xa5, 0xf1, 0x02, 0x60, 0x8c, 
0x9e, 0xeb, 0xac, 0x55, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 
0x00, 0x1f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x31, 0x00, 
0x33, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x44, 0x00, 0x65, 0x00, 0x62, 
0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 
0x20, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x72, 
0x00, 0x6d, 0x00, 0x61, 0x00, 0x72, 0x00, 0x20, 0x00, 0x68, 0x00, 
0x29, 0x00, 0x20, 0x00, 0x69, 0x00, 0x76, 0x00, 0x29, 0x00, 0x2e, 
0x00, 0x78, 0x00, 0x6c, 0x00, 0x73, 0x00, 0x78, 0x00, 0x00, 0x00, 
0x15, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 
0x00, 0x00, 0x00, 0x4e, 0x5a, 0x34, 0xff, 0xec, 0xda, 0x01, 0x15, 
0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 
0x00, 0xdd, 0x8d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x00, 
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 
0x23, 0x00, 0x00, 0x00, 0x48, 0x00, 0x6f, 0x00, 0x6a, 0x00, 0x61, 
0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x63, 0x00, 
0xe1, 0x00, 0x6c, 0x00, 0x63, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x6f, 
0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x4d, 0x00, 
0x69, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x6f, 
0x00, 0x66, 0x00, 0x74, 0x00, 0x20, 0x00, 0x45, 0x00, 0x78, 0x00, 
0x63, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 
0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 
0x00, 0x70, 0xff, 0x86, 0x33, 0xff, 0xec, 0xda, 0x01, 0x00, 0x00, 
0x00, 0x00, 0x0d, 0x02, 0x00, 0x00, 0x31, 0x53, 0x50, 0x53, 0xa6, 
0x6a, 0x63, 0x28, 0x3d, 0x95, 0xd2, 0x11, 0xb5, 0xd6, 0x00, 0xc0, 
0x4f, 0xd9, 0x18, 0xd0, 0xf1, 0x01, 0x00, 0x00, 0x1e, 0x00, 0x00, 
0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0xef, 0x00, 0x00, 0x00, 0x43, 
0x00, 0x3a, 0x00, 0x5c, 0x00, 0x55, 0x00, 0x73, 0x00, 0x65, 0x00, 
0x72, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x67, 0x00, 0x6f, 0x00, 0x6e, 
0x00, 0x7a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x2e, 0x00, 
0x73, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x76, 
0x00, 0x61, 0x00, 0x6c, 0x00, 0x5c, 0x00, 0x44, 0x00, 0x69, 0x00, 
0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 
0x00, 0x69, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 
0x20, 0x00, 0x54, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x73, 
0x00, 0x70, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x74, 0x00, 0x65, 0x00, 
0x73, 0x00, 0x20, 0x00, 0x50, 0x00, 0xfa, 0x00, 0x62, 0x00, 0x6c, 
0x00, 0x69, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x4d, 0x00, 
0x65, 0x00, 0x74, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x6f, 
0x00, 0x6c, 0x00, 0x69, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6e, 0x00, 
0x6f, 0x00, 0x5c, 0x00, 0x43, 0x00, 0x47, 0x00, 0x43, 0x00, 0x20, 
0x00, 0x2d, 0x00, 0x20, 0x00, 0x33, 0x00, 0x30, 0x00, 0x30, 0x00, 
0x2e, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x52, 
0x00, 0x41, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x20, 0x00, 
0x2d, 0x00, 0x20, 0x00, 0x30, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x43, 
0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 
0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x30, 0x00, 0x38, 
0x00, 0x2e, 0x00, 0x20, 0x00, 0x41, 0x00, 0x53, 0x00, 0x45, 0x00, 
0x53, 0x00, 0x4f, 0x00, 0x52, 0x00, 0x49, 0x00, 0x41, 0x00, 0x20, 
0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x52, 0x00, 
0x41, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x5c, 0x00, 0x43, 0x00, 0x6f, 
0x00, 0x6d, 0x00, 0x70, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 
0x69, 0x00, 0x64, 0x00, 0x61, 0x00, 0x5c, 0x00, 0x48, 0x00, 0x69, 
0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x20, 0x00, 0x63, 0x00, 
0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x63, 
0x00, 0x74, 0x00, 0x75, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x65, 0x00, 
0x73, 0x00, 0x5f, 0x00, 0x32, 0x00, 0x30, 0x00, 0x32, 0x00, 0x34, 
0x00, 0x5c, 0x00, 0x55, 0x00, 0x53, 0x00, 0x31, 0x00, 0x5c, 0x00, 
0x30, 0x00, 0x36, 0x00, 0x2e, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x4a, 
0x00, 0x75, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x5c, 0x00, 
0x33, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x42, 0x00, 0x75, 0x00, 0x73, 
0x00, 0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 0x53, 0x00, 0x75, 0x00, 
0x6d, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 
0x00, 0x72, 0x00, 0x61, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x73, 0x00, 
0x5c, 0x00, 0x31, 0x00, 0x33, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x44, 
0x00, 0x65, 0x00, 0x62, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 
0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x66, 
0x00, 0x6f, 0x00, 0x72, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x72, 0x00, 
0x20, 0x00, 0x68, 0x00, 0x29, 0x00, 0x20, 0x00, 0x69, 0x00, 0x76, 
0x00, 0x29, 0x00, 0x2e, 0x00, 0x78, 0x00, 0x6c, 0x00, 0x73, 0x00, 
0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x39, 
0x00, 0x00, 0x00, 0x31, 0x53, 0x50, 0x53, 0xb1, 0x16, 0x6d, 0x44, 
0xad, 0x8d, 0x70, 0x48, 0xa7, 0x48, 0x40, 0x2e, 0xa4, 0x3d, 0x78, 
0x8c, 0x1d, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x48, 
0x00, 0x00, 0x00, 0xb7, 0x38, 0xfb, 0x7d, 0xc6, 0xfe, 0x94, 0x4a, 
0x94, 0xc5, 0x15, 0x2e, 0xb8, 0x44, 0x02, 0x60, 0x00, 0x00, 0x00, 
0x00, 0xc9, 0x01, 0x00, 0x00, 0x31, 0x53, 0x50, 0x53, 0x4c, 0x58, 
0xe0, 0xe3, 0x88, 0xb7, 0x5a, 0x4a, 0xbb, 0x20, 0x7f, 0x5a, 0x44, 
0xc9, 0xac, 0xdd, 0xad, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 
0x00, 0x1f, 0x00, 0x00, 0x00, 0xcd, 0x00, 0x00, 0x00, 0x43, 0x00, 
0x3a, 0x00, 0x5c, 0x00, 0x55, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 
0x00, 0x73, 0x00, 0x5c, 0x00, 0x67, 0x00, 0x6f, 0x00, 0x6e, 0x00, 
0x7a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x2e, 0x00, 0x73, 
0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x76, 0x00, 
0x61, 0x00, 0x6c, 0x00, 0x5c, 0x00, 0x44, 0x00, 0x69, 0x00, 0x72, 
0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 
0x69, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 
0x00, 0x54, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x73, 0x00, 
0x70, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 
0x00, 0x20, 0x00, 0x50, 0x00, 0xfa, 0x00, 0x62, 0x00, 0x6c, 0x00, 
0x69, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x4d, 0x00, 0x65, 
0x00, 0x74, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x6f, 0x00, 
0x6c, 0x00, 0x69, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x6f, 
0x00, 0x5c, 0x00, 0x43, 0x00, 0x47, 0x00, 0x43, 0x00, 0x20, 0x00, 
0x2d, 0x00, 0x20, 0x00, 0x33, 0x00, 0x30, 0x00, 0x30, 0x00, 0x2e, 
0x00, 0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x52, 0x00, 
0x41, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x53, 0x00, 0x20, 0x00, 0x2d, 
0x00, 0x20, 0x00, 0x30, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x43, 0x00, 
0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, 
0x00, 0x6f, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x30, 0x00, 0x38, 0x00, 
0x2e, 0x00, 0x20, 0x00, 0x41, 0x00, 0x53, 0x00, 0x45, 0x00, 0x53, 
0x00, 0x4f, 0x00, 0x52, 0x00, 0x49, 0x00, 0x41, 0x00, 0x20, 0x00, 
0x43, 0x00, 0x4f, 0x00, 0x4e, 0x00, 0x54, 0x00, 0x52, 0x00, 0x41, 
0x00, 0x54, 0x00, 0x4f, 0x00, 0x5c, 0x00, 0x43, 0x00, 0x6f, 0x00, 
0x6d, 0x00, 0x70, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 
0x00, 0x64, 0x00, 0x61, 0x00, 0x5c, 0x00, 0x48, 0x00, 0x69, 0x00, 
0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x20, 0x00, 0x63, 0x00, 0x6f, 
0x00, 0x6e, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x63, 0x00, 
0x74, 0x00, 0x75, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x73, 
0x00, 0x5f, 0x00, 0x32, 0x00, 0x30, 0x00, 0x32, 0x00, 0x34, 0x00, 
0x5c, 0x00, 0x55, 0x00, 0x53, 0x00, 0x31, 0x00, 0x5c, 0x00, 0x30, 
0x00, 0x36, 0x00, 0x2e, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x4a, 0x00, 
0x75, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x5c, 0x00, 0x33, 
0x00, 0x2e, 0x00, 0x20, 0x00, 0x42, 0x00, 0x75, 0x00, 0x73, 0x00, 
0x65, 0x00, 0x73, 0x00, 0x20, 0x00, 0x53, 0x00, 0x75, 0x00, 0x6d, 
0x00, 0x69, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 
0x72, 0x00, 0x61, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00))
2
  • 1
    Can you share a sample lnk file with something like read_raw <- function(x) dput(readBin(x, raw(), n=file.info(x)$size))? If you put the output of read_raw("myfile.lnk") in the question it might be possible to decode without any additional packages. I just don't have any test files since I'm on a mac.
    – MrFlick
    Commented Aug 21 at 20:47
  • I'm not sure if I understood correctly, but I'm going to put the output of the function you provided with one of my lnk files.
    – Gonzalo S
    Commented Aug 22 at 16:34

1 Answer 1

2

lnk files

1) Use filePath in the R.utils package:

library(R.utils)

# create a test shortcut/lnk file in current directory to Notepad
createWindowsShortcut("toNotepad.lnk", "C:/Windows/notepad.exe")

# find its real path
filePath("toNotepad.lnk", expandLinks = "local")
## [1] "C:/Windows/notepad.exe"

Note that at least in this example there is no need to get the real file path as this works fine to run Notepad:

shell("toNotepad.lnk")

2) Another approach is to extract the strings from the lnk file and then look for the one specifying the path. Be sure that Rtools is installed and that strings has been set to the path to the strings.exe file.

strings <- "C:/rtools44/x86_64-w64-mingw32.static.posix/bin/strings.exe"

"toNotepad.lnk" |>
  paste(strings, ... = _) |>
  shell(intern = TRUE) |>
  grep("^C:", x = _, value = TRUE)

## [1] "C:\\Windows\\notepad.exe"

Windows symbolic links

3) That said, you probably don't want to use .lnk files but want to use Windows symbolic link files which unlike .lnk files are part of the Windows file system. With symbolic links read.csv, etc. will read the link directly and get the underlying file without having to know the real path. file.symlink is part of base R.

Ensure that R is running with Admin rights to create symbolic links.

cat("a,b\n1,2\n", file = "my.csv") # create test file

file.symlink("my.csv", "mycsv")  # create symbolic link mycsv
## [1] TRUE

read.csv("mycsv")
##   a b
## 1 1 2

To remove the symbolic link file.remove("mycsv") will remove the symbolic link without removing the underlying file.

6
  • thanks but this approach doesn't work. And I don't know why. In the next comment left the commands and the error I got
    – Gonzalo S
    Commented Aug 22 at 16:20
  • filePath(files[1], expandLinks = "local") Aviso: In readWindowsShortcut.default(lnkFile) : Detected a possibly unsupported file format: There are unknown 'flags' in the Windows Shortcut link file: hasShellItemIdList=TRUE, pointsToFileOrDirectory=TRUE, hasDescription=FALSE, hasRelativePath=TRUE, hasWorkingDirectory=TRUE, hasCommandLineArguments=FALSE, hasCustomIcon=FALSE, unicodedStrings=TRUE, unknown1=FALSE, unknown2=FALSE, unknown3=FALSE, unknown4=FALSE, unknown5=FALSE, unknown6=FALSE, unknown7=FALSE, unknown8=FALSE, unknown9=FALSE, unknown10=FALSE, unknown11=FALSE, unknown12=TRUE
    – Gonzalo S
    Commented Aug 22 at 16:24
  • Try creating the lnk files using createWindowsShortcut as in the answer. Commented Aug 22 at 16:47
  • The files are in multiples routes, so I think is easier to copy manually the shortcuts in the unique folder for getting the real path after that. Try to do what you say, It would have the same problem as the original routes, I think.
    – Gonzalo S
    Commented Aug 22 at 19:52
  • Have provided an alternative. See (2). Commented Aug 22 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.