Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 20th July 2011, 23:34   #1
sliceofpie
Junior Member
 
Join Date: Jul 2011
Posts: 3
SetFileOwner

Hi,
I'm running into an issue with AccessControl::SetFileOwner.

I've created a script that sets the ownership of a file to the current logged in user:
code:

AccessControl::GetCurrentUserName "" "$0"
Pop $0
AccessControl::SetFileOwner "$INSTDIR\myfile.txt" $0



This works well in workgroups but does not work in a domain environment . In a domain, it actually assigns the local admin, instead of the logged in user. Im not sure if this is due to "RequestExecutionLevel admin".

Anyhow Id like it to assign the actual user that is logged on. I've tried to use UserMgr::GetCurrentDomain in conjuction with AccessControl::GetCurrentUserName but I believe my syntax was wrong.. (I'm new to NSIS so couldn't figure out the format )

Any ideas? Any help is greatly appreciated !!!
sliceofpie is offline   Reply With Quote
Old 21st July 2011, 01:27   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 2,810
If you are using RequestExecutionLevel admin then you can't really get the user.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st July 2011, 16:07   #3
sliceofpie
Junior Member
 
Join Date: Jul 2011
Posts: 3
I see. Is it possible to switch the RequestExecutionLevel back down then take ownership of the file? not sure if that would be appropriate in my scenario.

Any examples would really help.
sliceofpie is offline   Reply With Quote
Old 21st July 2011, 16:39   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,847
As far as I know it's not possible to downgrade access level in Windows. But if it is possible, the only way to do it is to use shellexecuteas or runas.exe to start a new process. And for that you need to know the username, which you don't.

So, the best option is probably to use the UAC plugin to get two instances of your installer, one at userlevel and one at adminlevel. You can then get the username in the outer (userlevel) instance, and do all adminny stuff in the inner (admin) instance. Not recommended for beginners.
MSG is offline   Reply With Quote
Old 21st July 2011, 17:24   #5
sliceofpie
Junior Member
 
Join Date: Jul 2011
Posts: 3
MSG thank you for suggestion.

I thought about something else. What if I run the dos command "takeown.exe" from the installer. Is that possible to do?
sliceofpie is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

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