Don Simons wrote:
> David Allsopp wrote
> >The only thing which should write to C:\Program Files or C:\Program
> >Files
> (x86) is a
> >setup program (MiKTeX Package Manager falls into this category) -
> 
> I believe the MiKTeX installer does as well

Indeed - but that's a de facto setup program :)

> >human beings
> >(and normal programs) should not write *anything* there. That's why the
> default
> >permission for normal users is read-only for C:\Program Files and why
> >even
> programs
> >can't write to it unless they're running elevated (of course, you're
> running as
> >Administrator on Windows XP then these facts are masked). The correct
> >place
> for
> >shared data between all users is, for Windows Vista / Windows 7,
> C:\ProgramData or
> >C:\Users\Public (it's a matter of taste whether you want to put a
> publically available third
> >party tree in the hidden C:\ProgramData or C:\Users\Public\Documents)
> >or
> for
> >Windows XP, it's C:\Documents and Settings\All Users\Application Data
> >or C:\Documents and Settings\All Users\Documents.
> 
> Andre and I went back and forth on this when preparing the manual
> mxinsuse.pdf and batch file instmus.bat (which calls setmaps.bat) for
> installing MusiXTeX 1.15. It was Andre who came up with what I believe is
> a very satisfying resolution. It involves using the built-in Windows
> environment variable %APPDATA%. For example, when I type "set" in a
> Windows XP command window, it tells me
> 
> APPDATA=C:\Documents and Settings\Don\Application Data
> 
> I believe %APPDATA% will represent a similar user-accessible path in
> Windows Vista and 7. So for the default we had the batch file copy
> MusiXTeX files into %APPDATA%\musixtexmf.

Yes, it does (C:\Users\you\AppData\Roaming - Windows Vista has 3 different 
Application Data folders per user, but Roaming is definitely the one to use 
here).

> I'd guess this will work for 99% of the Windows users of MusiXTeX. For
> the other 1% (who may have more than one user), I'm not sure what happens
> if the MusiXTeX files are in one user's space and that path is listed as
> a root in MiKTeX setup, but I'm about to do some testing that will answer
> that question. In any event, setmaps.bat could be edited to point to
> 
> %ALLUSERSPROFILE%\Application Data\musixtexmf

Not quite - on Vista, ALLUSERSPROFILE already points to the equivalent of 
"Application Data". The best way would be to say

setlocal enableextensions
if defined ProgramData (
  rem Windows Vista onwards
  set INSTALL_TARGET=%ProgramData%\musixtexmf
) else (
  rem Windows XP and earlier
  set INSTALL_TARGET=%ALLUSERSPROFILE%\Application Data\musixtexmf
)

Do the batch files already have a switch to indicate whether they're installing 
for all users or just for the local user? (indeed, do they attempt to register 
the root directly using initexmf?). The obvious choice to me, mirroring 
initexmf itself, would be to add the --admin switch to the batch file - this 
would cause it to attempt to install for all users and also pass --admin to 
initexmf to register the new root for all users instead of just the current 
one. Incidentally, in that instance, the following snippet is handy for 
detecting whether you're running in an elevated command prompt in Windows 
Vista+:

set NOT_ELEVATED=0
ver | find "Version 6." > nul
if not errorlevel 1 (
  whoami /groups | find "S-1-16-12288" > nul
  if errorlevel 1 set NOT_ELEVATED=1
)

Then later on you can test %NOT_ELEVATED% and display an error rather than a 
whole load of "Access denied" when you attempt to copy files to a folder the 
user can't write!

HTH,


David 

-------------------------------
TeX-music@tug.org mailing list
If you want to unsubscribe or look at the archives, go to 
http://tug.org/mailman/listinfo/tex-music

Reply via email to