![]() |
#1 |
Junior Member
Join Date: Jul 2012
Posts: 8
|
![]()
Im wondering is it possible to impersonate my admin user using nsis? I know the un and pw
do i need to call System.dll, how would i call the appropriate API functions? sorry if this is a silly question but im new to nsis. I will be logged in using with a standard user when running the installer Its this the correct route i should be following? http://forums.winamp.com/showthread.php?t=172544 |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,352
|
What is the goal? Why not just request admin rights like a normal installer?
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Jul 2012
Posts: 8
|
the installer is going to have to make updates by impersonating admin, admin has a password which the standard user will not have access to(Restricted User), so when i call RequestExecutionLevel admin,this brings up UAC requesting the admin password which the standard user will never know.
Is this possible with Nsis? |
![]() |
![]() |
![]() |
#4 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
That post you linked has the code you want.
Stu |
![]() |
![]() |
![]() |
#5 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,352
|
Just remember that impersonation is per thread (Will not affect CreateProcess, for that you have CreateProcess<AsUser|With[Token|Logon]> etc)
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#6 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Yes and the code in Sections run in a different thread. So if you do impersonation in .onInit you will need to do it again in a first Section.
Stu |
![]() |
![]() |
![]() |
#7 |
Junior Member
Join Date: Jul 2012
Posts: 8
|
Error Opening File
First thing thank you for the replys, ive tryied to implement the code as below, but im still running into problems:
1st Massage box : i get Number: 227633266688 this is a random number: 2nd Massage box : i get Number: 25769803776 then i get an Error message "Error opening file for writing" So i wondering if this is a permission thing? - not so sure of this as TestAdmin have full access rights on the c:\ PHP Code:
Last edited by dr_awol; 16th July 2012 at 10:56. Reason: setOutPath $INSTDIRApp_Applications = setOutPath $INSTDIR\App_Applications |
![]() |
![]() |
![]() |
#8 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,352
|
Should probably be
!define LogonUser "advapi32::LogonUser(t, t, t, i, i, *i) i" (change l to i) and since it returns BOOL really anything nonzero is success (but it is very rare that BOOL returning functions use anything other than 0 and 1) You should add ?e to the end of the command to get the windows error code. ...and finally, if someone really wanted to they could find the password (Debugger, decompile installer or look at the memory at the right moment in process explorer) IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
|
Tags |
impersonation, windows 7 |
Thread Tools | Search this Thread |
Display Modes | |
|
|