NSIS脚本,检查权限和.NET环境 - (摘录及原创)
来源:互联网 发布:windows系统描述 编辑:程序博客网 时间:2024/06/05 19:23
NSIS 官网:http://nsis.sourceforge.net/Main_Page
一款很好用的NSIS脚本编辑器(HM NIS EDIT: A Free NSIS Editor/IDE):http://hmne.sourceforge.net/
---------------------------------------
; Assist Functions, CheckAdmin, CheckPlugin, CheckQB, CheckDotNet, InstallDotNet, CheckPluginUsing
Function CheckAdmin
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
# GetOriginalAccountType will check the tokens of the original user of the
# current thread/process. If the user tokens were elevated or limited for
# this process, GetOriginalAccountType will return the non-restricted
# account type.
# On Vista with UAC, for example, this is not the same value when running
# with `RequestExecutionLevel user`. GetOriginalAccountType will return
# "admin" while GetAccountType will return "user".
UserInfo::GetOriginalAccountType
Pop $2
StrCmp $1 "Admin" 0 +3
;MessageBox MB_OK 'User "$0" is in the Administrators group${REALMSG}'
Goto done
StrCmp $1 "Power" 0 +3
;MessageBox MB_OK 'User "$0" is in the Power Users group${REALMSG}'
Goto exit
StrCmp $1 "User" 0 +3
;MessageBox MB_OK 'User "$0" is just a regular user${REALMSG}'
Goto exit
StrCmp $1 "Guest" 0 +3
;MessageBox MB_OK 'User "$0" is a guest${REALMSG}'
Goto exit
MessageBox MB_OK "Unknown error"
Goto exit
Win9x:
# 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!"
exit:
MessageBox MB_OK "Only Administrator can run this application. Please run it again as Administrator."
Quit
done:
FunctionEnd
;以上方法来自NSIS自带例子
Function CheckDotNet
Call GetDotNETVersion
Pop $0
StrCmp $0 "not found" update1 check ; not found any .net library
check:
StrCpy $0 $0 "" 1 ;skip "v"
StrCpy $0 $0 3 ;get the version as "x.x"
StrCpy $2 $0 1 ;get the major version number (first x from x.x)
StrCmp $2 "1" update2 going
update1:
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1 ".NET runtime library is not installed. Installer will stop to help you to install .NET 2.0 runtime library. After .NET 2.0 installing, please run installer again to finish installation. Do you want to install .NET 2.0 runtime library?" IDYES install IDNO exit
update2:
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1 ".NET runtime library v2.0 or newer is required. You have v$0 installed. Installer will stop to help you to update it to .NET 2.0 runtime library. After .NET 2.0 installing, please run installer again to finish installation. Do you want to install .NET 2.0 runtime library?" IDYES install IDNO exit
install:
Call InstallDotNet
goto going
exit:
Quit
going:
FunctionEnd
;以上方法来自NSIS自带帮助
; Get the current .Net runtime liberary version
Function GetDotNETVersion
Push $0
Push $1
System::Call "mscoree::GetCORVersion(w .r0, i ${NSIS_MAX_STRLEN}, *i) i .r1 ?u"
StrCmp $1 "error" 0 +2
StrCpy $0 "not found"
Pop $1
Exch $0
FunctionEnd
; 以上方法来自NSIS官方网站
; Install .NET 2.0
Function InstallDotNet
Call UnZipDotNetInstaller
ExecWait "$TEMP/dotnetfx.exe"
Quit
FunctionEnd
;简单方法,用于调用.NET的安装包,原创
; Unzip .NET 2.0 Installer
Function UnZipDotNetInstaller
SetOutPath "$TEMP"
SetOverwrite off
File "Resource/dotnetfx.exe"
FunctionEnd
;简单方法,用于解包.NET的安装包,原创
- NSIS脚本,检查权限和.NET环境 - (摘录及原创)
- NSIS设置.net运行环境
- NSIS原创
- 使用Script.NET编写NSIS安装脚本
- NSIS脚本实例(引)
- nsis 脚本
- mysql replication环境检查脚本
- NSIS检查磁盘空间不足
- (摘录+原创)float与double的范围和精度+内存如何存储
- NSIS一键安装网站环境及部署网站
- NSIS安装MSDE2000和NET2.0脚本代码
- NSIS安装MSDE2000和NET2.0脚本代码
- Linux 上 RAC 环境检查脚本
- NSIS脚本详解
- nsis打包脚本
- NSIS 脚本介绍
- 全方位掌握nsis脚本
- NSIS脚本详解
- 分享我做的截屏小工具
- 怎么把PPT转成EXE格式,详细步骤
- 怎么用C++生成WORD文档,详细步骤 - (参考基础上原创)
- nginx proxy https
- C#利用CER证书文件对远程Service进行验证
- NSIS脚本,检查权限和.NET环境 - (摘录及原创)
- 用批处理实现自动做Build
- C#重绘,高级进度条 - (参考基础上原创)
- C# 圆角Panel - (参考基础上原创)
- C#跨进程窗体获得焦点
- 还是用CSDN吧……
- Web前端
- LVS负载均衡配置说明
- Nginx HTTP负载均衡/反向代理的相关参数测试