Archive: When to "Run as Admin" for fonts?


When to "Run as Admin" for fonts?
Does anyone know which versions of Windows require "run as Admin" to install fonts?
Also, will the code below work only on Win-7, or will it also work on Win-XP and Vista?

I'm using an old font.dll (don't have that with me today) on the app I sell, but was looking to upgrade to the new NSIS. About 5 to 10% of the users have been having problems installing the fonts, and I provide a manual procedure, but that number seems to be growing lately (I'm guessing because of Win 7).

I wrote the following sample and tested today at home on Win7 (created with v2.46).


!include FontReg.nsh
!include FontName.nsh
!include WinMessages.nsh

; The name of the installer
Name "FontTest01"

; The file to write
OutFile "FontTest01.exe"

; The default installation directory
InstallDir $DESKTOP\Example1

; Request application privileges for Windows Vista
RequestExecutionLevel user

;--------------------------------
; Pages
Page directory
Page instfiles
;--------------------------------

; The stuff to install
Section "" ;No components page, name is not important

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File readme.txt

SectionEnd ; end the section

Section "Fonts"
StrCpy $FONT_DIR "c:\windows\fonts" ; one directory under current directory
!insertmacro InstallTTFFont 'hebbook.ttf'
!insertmacro InstallTTFFont 'hebbook6.ttf'
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000
SectionEnd


When I didn't do right-click "run as Admin" on the fontTest01.exe, I get this error:

Error opening file for writing: C:\windows\fonts\hebbook.ttf.

Thanks,
Neal Walters


Originally posted by NealWalters
Does anyone know which versions of Windows require "run as Admin" to install fonts?
All NT versions. That includes 2000, XP and anything newer than that.

Originally posted by NealWalters
Also, will the code below work only on Win-7, or will it also work on Win-XP and Vista?
Your code will not work on ANY windows version. You requestexecutionlevel user, while you need admin to install a font. (Remember: requestexecutionlevel only works on Vista/7 when UAC is turned ON! You must always use the UserInfo plugin in .onInit to verify whether you really got admin access!)