I am opening a file using the installer script nsis and i need to open it as an admin in order for it to run properly, but i cannot seem to figure out how to do this.
currently my open code looks like this:
FileOpen $4 "$R0" w
FileRead $4 $1
FileClose $4
it opens it but as a regular user and i need it to be as an admin. is there a way to do this?? thanks in advance for your help!
You cannot open a file as a different user in a normal application. If you need this kind of power the whole installer probably needs to run elevated :
Outfile RequireAdmin.exe
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
!include LogicLib.nsh
Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
MessageBox mb_iconstop "Administrator rights required!"
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
Quit
${EndIf}
FunctionEnd
Page InstFile
Section
SectionEnd
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.