ffletch2
3rd April 2006 20:26 UTC
Add User Without non-stock Plugin
Anyone know of a way to add an OS user (assume 2k or xp) without using a "non-stock" plugin (i.e. a plugin that doesn't come with the default distribution)? Seems like there would be something I could use with the system plugin but I can't find anything in MSDN.
TIA for any ideas.
kichik
3rd April 2006 20:36 UTC
You could take a look at the source code of one of the plug-ins that do allow creating users and implement that code with the System plug-in. A quick MSDN search turned up NetUserAdd.
ffletch2
3rd April 2006 20:54 UTC
This looks promising - thanks.
The reason I'm asking about this is that I want to keep our overall build process to a minimum. I don't want to have to worry about a version of a plugin not working with a future version of NSIS. Not to mention that I don't want to have to worry about tracking the version of something other than NSIS.
Right now I have it such that I just say grab the most recent version of NSIS and click the build button.
For this reason I have generally avoided "non-stock" plugins. Anyone have any comments on how to best handle these type of issues?
kichik
3rd April 2006 20:59 UTC
I usually add the plug-ins to the source control along with the source code. This, however, mostly solves the problem of finding the right version of the plug-in and not having it work with every version of NSIS. But backwards compatibility is very important in NSIS and the user management plug-ins are usually simple and don't depend on anything internal, so they should not suddenly stop working. If they do, it'll probably be a bug with NSIS.
ffletch2
3rd April 2006 21:57 UTC
That makes sense. There are bugs in NSIS? ;)
Thinking this the original problem through, it seems like this would be somewhat easy to just call an external program or script to do this (like something that just says uses the "net" command) as referenced in this post.
Hmm, looks like I have some trial an error ahead of me....
Red Wine
4th April 2006 02:39 UTC
This code works just fine on XP. I have used it several times.
outfile "testuser.exe"
>name "accounts"
>section -
>nsexec::exec 'net user "test_user" "" /add'
>nsexec::exec 'net localgroup "Power Users" "test_user" /delete'
>nsexec::exec 'net localgroup "Users" "test_user" /delete'
>nsexec::exec 'net localgroup "Guests" "test_user" /delete'
>nsexec::exec 'net localgroup "HelpServicesGroup" "test_user" /delete'
>nsexec::exec 'net localgroup "Network Configuration Operators" "test_user" /delete'
>nsexec::exec 'net localgroup "Remote Desktop Users" "test_user" /delete'
>nsexec::exec 'net localgroup "Replicator" "test_user" /delete'
>nsexec::exec 'net localgroup "Backup Operators" "test_user" /delete'
>nsexec::exec 'net localgroup "Administrators" "test_user" /add'
>nsexec::exec 'net accounts /maxpwage:unlimited'
>sectionend
>
Though, the users who they run the installer must be administrators.
The account behaves normally in control panel once has been made.
I use it always in a small silent exe by adding it to HKLM..../RunOnce, setting the rebootflag etc, so once the machine is rebooted the account is ready for use.
*Originally used in (full) unattended xp installations under the setup paramaters section, (may be used in cmdlines as well) to create the first account.