Old 7th July 2011, 15:03   #1
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
RunAsAdmin

if i'm not mistaken, i cannot use the UAC plugin to have an installer in user mode execute a file as admin. is there any other way this can be done? the executed program would ideally request admin rights from the user first.

i came across this, not sure if this is a possible solution. anyway, i would prefer not having to use the registry for such a simple task.
Yathosho is offline   Reply With Quote
Old 7th July 2011, 15:17   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
To ExecWait an exe as admin, see here: http://forums.winamp.com/showthread.php?t=287227
I guess to Exec without Wait you can just call shellexecuteex without worrying about process handles.

(I found it by using the search function. Keyword 'admin', search in titles only, show results as threads, NSIS forum only.)

(Note: Running an exe As Admin will ALWAYS require the user to enter credentials. It would be bad if you could just run something as admin without the admin password!)
MSG is offline   Reply With Quote
Old 7th July 2011, 16:50   #3
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
i guess i'd have to make a system call? i have no idea how these work. anyone who could provide a reallife example please?
Yathosho is offline   Reply With Quote
Old 8th July 2011, 11:25   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Best way (if possible) is for the program itself to request administrator privileges using a requestExecutionLevel manifest and code to test the current user is an administrator.

Stu
Afrow UK is offline   Reply With Quote
Old 30th July 2011, 22:29   #5
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
so now i'm using ShellExecWait and it does the job for ExecWait.

however, i looking for the same to perform a simple Exec. i commented the following portion of the code and it works as desired.

code:
${If} $1 <> 0
System::Call '*$0(is,i,i,i,i,i,i,i,i,i,i,i,i,i,i.r1)' ;stack value not really used, just a fancy pop
System::Call 'kernel32::WaitForSingleObject(ir1,i-1)'
System::Call 'kernel32::GetExitCodeProcess(ir1,*i.s)'
System::Call 'kernel32::CloseHandle(ir1)'
${EndIf}



as i don't really understand this, i was wondering if there's more code i could leave?
Yathosho is offline   Reply With Quote
Old 31st July 2011, 09:12   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
If you don't need to wait for the process to exit, you don't want SEE_MASK_NOCLOSEPROCESS (0x00000040) for the 2nd member (fMask) of the SHELLEXECUTEINFO struct.

Stu
Afrow UK is offline   Reply With Quote
Old 31st July 2011, 18:22   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,891
Why make this more complicated than it has to be? To perform a ShellExecute without waiting you can just use the ExecShell command...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Tags
elevate, rights, runasadmin, vista, windows 7

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump