博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NSIS打包+管理员权限+多用户安装
阅读量:6001 次
发布时间:2019-06-20

本文共 1688 字,大约阅读时间需要 5 分钟。

 
; 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 IsUserAdmin
Push $R0
Push $R1
Push $R2
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $R1
UserInfo::GetAccountType
Pop $R2
StrCmp $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 Done
Continue:
; 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
""
Win9x
StrCpy $R0
"
false
"
;MessageBox MB_OK
'
User "$R1" is in the "$R2" group
'
Goto Done
Win9x:
; 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 $R2
Pop $R1
Exch $R0
FunctionEnd
;转
;获取管理员权限
RequestExecutionLevel none|user|highest|admin
;多用户安装
;使用SetShellVarContext all 将快捷方式创建到alluser的开始菜单中
SetShellVarContext all

转载于:https://www.cnblogs.com/08shiyan/archive/2011/05/10/2042099.html

你可能感兴趣的文章
IOS初级教程2:UITapGestureRecognizer手势识别的简单使用
查看>>
ThinkPHP框架系统源码解析——URL路由解析
查看>>
Quartz 的 Misfire处理规则
查看>>
Oracle关于left join on…and 及 left join on...whe...
查看>>
overlayfs存储驱动的使用以及技术探究
查看>>
【CF 应用开发大赛】巨能搜,聚合搜索应用
查看>>
做性能测试时候常用的Linux命令(不断更新)
查看>>
微信公众采坑记录-微信weixinjs分享那些坑
查看>>
删数算法
查看>>
Android端应用秒开优化体验
查看>>
Wine小工具:Winetricks使用指南
查看>>
进展】关于一个团队管理服务平台(第二次架构修改)
查看>>
微服务随记
查看>>
PHP:调试的时候显示所有信息
查看>>
初识JVM虚拟机
查看>>
编译器介绍--OpenWatCOM
查看>>
spring4配置文件详解
查看>>
Xcode中Info.plist文件各个键的作用说明
查看>>
grub2的mbr分析
查看>>
Python网络通信TCP服务端
查看>>