; Author: Lilla (lilla@earthlink.net) 2003 - 06 - 13 ; function IsUserAdmin uses plugin \NSIS\PlusgIns\UserInfo.dll; This function is based upon code in \NSIS\Contrib\UserInfo\UserInfo.nsi; This function was tested under NSIS 2 beta 4 (latest CVS as of this writing).;; Usage:; Call IsUserAdmin; Pop $R0 ; at this point $R0 is " true " or " false " ;Function IsUserAdminPush $R0Push $R1Push $R2ClearErrorsUserInfo::GetNameIfErrors Win9xPop $R1UserInfo::GetAccountTypePop $R2StrCmp $R2 " Admin " 0 Continue; Observation: I get here when running Win98SE. (Lilla); The functions UserInfo.dll looks for are there on Win98 too, ; but just don ' t work. So UserInfo.dll, knowing that admin isn ' t required; on Win98, returns admin anyway. (per kichik); MessageBox MB_OK ' User "$R1" is in the Administrators group ' StrCpy $R0 " true " Goto DoneContinue:; You should still check for an empty string because the functions; UserInfo.dll looks for may not be present on Windows 95 . (per kichik)StrCmp $R2 "" Win9xStrCpy $R0 " false " ;MessageBox MB_OK ' User "$R1" is in the "$R2" group ' Goto DoneWin9x:; comment / message below is by UserInfo.nsi author:; This one means you don ' t need to care about admin or ; not admin because Windows 9x doesn ' t either ;MessageBox MB_OK " Error! This DLL can't run under Windows 9x! " StrCpy $R0 " true " Done:;MessageBox MB_OK ' User= "$R1" AccountType= "$R2" IsUserAdmin= "$R0" ' Pop $R2Pop $R1Exch $R0FunctionEnd
;转
;获取管理员权限
RequestExecutionLevel none|user|highest|admin
;多用户安装
;使用SetShellVarContext all 将快捷方式创建到alluser的开始菜单中
SetShellVarContext all