|
|
#1 |
|
Junior Member
|
How to change the process owner of the installer?
Hi.
As a part of my project i am supposed to create a new Windows User with Administrator privileges. So far i have succeeded in that. Next what my task is for the process "installer.exe"; (i.e the currently running installer) to change its owner from the logged on user to the newly created user. In short i want to change the owner of the current process. Any help in this regard would be greatly appreciated. And by the way,this whole NSIS thing is simply outstanding stuff.Kudos to the development team for such a fantastic effort. Regards, Giriraj. |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 2,777
|
I don't think you can change a process owner/user on the fly. You probably have to start another instance of the same process by calling CreateProcessAsUser or one of the other CreateProcessAs/With api's with the system plugin
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#3 |
|
Junior Member
|
Thanks a lot Anders for your information.
Is it possible for you to give an example for the same. I am a newbie in this awesome technology called NSIS. |
|
|
|
|
|
#4 | |
|
Senior Member
|
Quote:
@giriraj You need to call LogonUser to get a primary token for the new user, convert the resulting impersonation token to a primary one with DuplicateTokenEx then call CreateProcessAsUser with the new token, in order to start a new process of the program. Alternatively you can call CreateProcessWithTokenW or the CreateProcessWithLogonW APIs as anders suggested. I'll try to put this together on a script if time permits, unless someone has it ready. CF |
|
|
|
|
|
|
#5 |
|
Junior Member
|
It would be really helpful to me if you can put up an example.
I am yet to get conversant with the terminologies involved in the System calls made through NSIS. |
|
|
|
|
|
#6 |
|
Senior Member
|
|
|
|
|
|
|
#7 |
|
Senior Member
|
@giriraj
After reading the MSDN info on the functions that are mentioned in this thread, I think that the easiest way to start a new process with your new account is by calling from your installer CreateProcessWithLogonW. Here is a minimal script to get you started: code: It will start notepad in the security context of the user test with password 1234 (Replace those with your new admin user's values) and will then exit. Go over the notes on the MSDN page, maybe your scenario needs some extra bits, but the above should be a good starting point. CF |
|
|
|
|
|
#8 |
|
Junior Member
|
Thanks a lot CF.
I was able to run your sample code and the notepad's owner was actually the new user i specified. But then i got stuck. What i specifically need is that whatever files are installed by the installer ,all of those files should have their preferences(for e.g file owner) set to the new user i just created(new user is created through the same installer process).I mean all these have to be performed through single instance of the running installer. I was looking for a way to do this through "CreateProcessWithLogonW". But i haven't found a way yet. I hope i am able to put forth my problem appropriately. Giriraj. |
|
|
|
|
|
#9 |
|
Junior Member
|
And just to add something more.
I have created a plug-in that encrypts a string using Win32Crypto API in VC(i am new to VC too ).Is there any place i can post my plug-in for others to use.? |
|
|
|
|
|
#10 | |
|
Senior Member
|
Ownership of files/folders you can set from within the installer using the AccessControl plugin...
Also you may want to have a look at the remarks at the end of the CreateProcessWithLogon MSDN page: Quote:
What this means is that you can run your program at the security context of your new user, however the user's profile is not loaded and his/her hive is not present in the registry. Changes that you would like to reflect to this user's program preferences will not be saved unless you load the user's profile... You can attach your plugin on this (or another) thread or you can create a wiki page for it (some related information can be found here) CF |
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|