04_NSIS顯示JAVA版本和使用者是否為admin
04_NSIS顯示JAVA版本和使用者是否為admin
Code
#NSIS顯示JAVA版本和使用者是否為admin
# name installer
outFile "04.exe"
# default section start
section
# read the value from the registry into the $0 register
readRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" CurrentVersion
# print the results in a popup message box
messageBox MB_OK "version: $0"
# call userInfo plugin to get user info. The plugin puts the result in the stack
userInfo::getAccountType
# pop the result from the stack into $0
pop $0
# compare the result with the string "Admin" to see if the user is admin.
# If match, jump 3 lines down.
strCmp $0 "Admin" +3
# if there is not a match, print message and return
messageBox MB_OK "not admin: $0"
return
# otherwise, confirm and return
messageBox MB_OK "is admin $0"
# default section end
sectionEnd