[Rd] Version names
Gabor Grothendieck
ggrothendieck at myway.com
Mon Nov 29 03:11:31 CET 2004
Gabor Grothendieck <ggrothendieck <at> myway.com> writes:
>
> Simon Urbanek <simon.urbanek <at> math.uni-augsburg.de> writes:
>
> : If all you want to do is to determine the current (most recently
> : installed) R version, then all it takes is two lines of C code [just
> : read one registry entry] - and it's at least as portable across Windows
> : systems as a batch script, but far more flexible. (There may even be a
> : way to get that info w/o coding at all - I'm not sure whether regedit
> : has any batch mode or something ...).
>
> I don't think regedit has a batch mode. e.g. regedit /? does not give help.
I looked into a bit more and some of this information is actually in
the FAQ:
2.15 Does R use the Registry?
Not itself.
The installers set some entries to allow uninstallation. In
addition (by default, but this can be de-selected) they set
a Registry key LOCAL_MACHINE\Software\R-core\R giving the
version and install path. Again, this is not used by R
itself, but it will be used by the DCOM interface
(http://cran.r-project.org/other-software.html). Finally, a
file association for extension .RData is set in the
Registry.
You can add the Registry entries by running RSetReg.exe in
the bin folder, and remove them by running this with
argument /U. Note that the settings are all per machine and
not per user, and that this neither sets up nor removes the
file associations.
Also it seems that one uses reg.exe rather than regedit.exe from
batch files so putting all this together we get the following
Windows XP batch statement to get the current path to the rw.... folder.
It puts the path into the Rrw variable:
for /f "tokens=2*" %%a in (
'reg query hklm\software\r-core\r /v InstallPath') do set Rrw=%%b
The bad news is that this is not 100% guaranteed to work since, as mentioned
above, the user can deselect modification of the registry during installation
but its certainly more than sufficient for my purposes and probably most
other purposes too.
Thanks for pointing the way.
More information about the R-devel
mailing list