From ggrothendieck at myway.com  Mon Nov 29 03:11:31 2004
From: ggrothendieck at myway.com (Gabor Grothendieck)
Date: Mon Nov 29 03:11:44 2004
Subject: [Rd] Version names
References: <loom.20041128T190755-473@post.gmane.org>
	<bl6kq05o6vuscam0rrlg00ndvchi68jals@4ax.com>
	<loom.20041128T200019-382@post.gmane.org>
	<eujkq0lbgdji3073ud8sjg73016upfdb1u@4ax.com>
	<loom.20041128T235131-532@post.gmane.org>
	<6463A9E0-4198-11D9-9579-0003938AF008@math.uni-augsburg.de>
	<loom.20041129T011607-744@post.gmane.org>
Message-ID: <loom.20041129T024007-634@post.gmane.org>

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.


[Rd] Version names
Gabor Grothendieck