From hongooi at microsoft.com  Mon Apr 30 11:35:33 2018
From: hongooi at microsoft.com (Hong Ooi)
Date: Mon, 30 Apr 2018 09:35:33 +0000
Subject: [Rd] system() and system2() do not use long filenames on Windows
Message-ID: <KL1P15301MB0086B1C2B181024D71D5D565A6820@KL1P15301MB0086.APCP153.PROD.OUTLOOK.COM>

Hi,

On Windows, it appears that system() and system2() both use the 8.3 filename to run the supplied command, even if the full name is used. Most of the time this doesn't matter, but for .NET programs, it stops the program from finding its app.config file (which has the same name as the app, with '.config' appended).

Here is a simple test program, compiled with: g++ -o longfilename.exe test.cpp


#include <iostream>

int main(int argc, char **argv)
{
    std::cout << argv[0] << '\n';
    return 0;
}


When I run this from a command prompt, it prints the full name:

C:\>\users\hongooi\longfilename.exe
\users\hongooi\longfilename.exe


But when I run it from R (3.4.3) via system() or system2(), it prints the 8.3 filename:

> system2("c:\\users\\hongooi\\longfilename.exe")
c:\users\hongooi\LONGFI~1.EXE


And here is a question on StackOverflow where this cropped up: https://stackoverflow.com/questions/50090450/config-file-is-ignored-when-net-executable-is-called-from-r

Would it be possible to modify system() and system2() to respect long filenames?



[Rd] system() and system2() do not use long filenames on Windows
Hong Ooi