Old 1st June 2017, 13:35   #1
droolrockworm
Junior Member
 
Join Date: Jun 2017
Posts: 4
UserMgr plugin question

What I need to do, is from the installer, place some entries into a specific user's registry settings. I tried this example I found from the web (below). It always dies with error 3 on the RegLoadUserHive.

Section User
UserMgr::CreateAccountEx "myuserA" "mypassword" "A test user created by the UserMgr plugin" "My User A" "A test user created by the UserMgr plugin" "UF_PASSWD_NOTREQD|UF_DONT_EXPIRE_PASSWD"
Pop $0
MessageBox MB_OK "CreateUser Result : $0"

UserMgr::BuiltAccountEnv "myuserA" "mypassword"
Pop $0
MessageBox MB_OK "BuiltAccountEnv Result : $0"

UserMgr::RegLoadUserHive "myuserA"
Pop $0
MessageBox MB_OK "RegLoadUserHive Result : $0"

WriteRegStr HKEY_USERS "myuserA\Software\My Company\My Software" "String Value" "dead beef"

UserMgr::RegUnLoadUserHive "myuserA"
Pop $0
MessageBox MB_OK "RegUnLoadUserHive Result : $0"
SectionEnd
droolrockworm is offline   Reply With Quote
Old 1st June 2017, 14:14   #2
droolrockworm
Junior Member
 
Join Date: Jun 2017
Posts: 4
Digging further... even though the command returns success.. The Build Account Environment does not seem to be creating an entry in the registry HKEY_USERS either.
droolrockworm is offline   Reply With Quote
Old 2nd June 2017, 03:53   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,525
Does it create a user? Is there a ntuser.dat file in the profile folder?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd June 2017, 13:28   #4
droolrockworm
Junior Member
 
Join Date: Jun 2017
Posts: 4
Yes. The user is good. The Build Env return success.

If I do this stuff from the Command line with Reg load and Reg add it works, but I'd rather use nsis.
droolrockworm is offline   Reply With Quote
Old 2nd June 2017, 15:07   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,525
Which Windows version is this?

I just tried this on a fresh Windows 2000 install (why not) and BuiltAccountEnv fails with error 1314 (when calling LogonUser) but RegLoadUserHive works and is able to write the value.

I guess my problem comes from https://support.microsoft.com/en-us/...ting-systems#: "The first and biggest of these restrictions is that on Windows NT and Windows 2000, the process that is calling LogonUser must have the SE_TCB_NAME privilege (in User Manager, this is the "Act as part of the Operating System" right)."

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd June 2017, 15:13   #6
droolrockworm
Junior Member
 
Join Date: Jun 2017
Posts: 4
Windows 10.
droolrockworm is offline   Reply With Quote
Old 3rd June 2017, 02:01   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,525
It works fine on XP for me if I add a call to UserMgr::AddToGroup:

PHP Code:
UserMgr::CreateAccountEx "myuserA" "mypassword" "A test user created by the UserMgr plugin" "My User A" "A test user created by the UserMgr plugin" "UF_PASSWD_NOTREQD|UF_DONT_EXPIRE_PASSWD"
Pop $0
DetailPrint 
"CreateUser Result : $0"

UserMgr::AddToGroup  "myuserA" "Users"
Pop $0
DetailPrint AddToGroup
=$0
UserMgr
::BuiltAccountEnv "myuserA" "mypassword"
Pop $0
DetailPrint 
"BuiltAccountEnv Result : $0"

UserMgr::RegLoadUserHive "myuserA"
Pop $0
DetailPrint 
"RegLoadUserHive Result : $0"

WriteRegStr HKEY_USERS "myuserA\Software\My Company\My Software" "String Value" "dead beef"
MessageBox mb_ok "Check in Regedit but remember to close Regedit again so the key is not held open!"
UserMgr::RegUnLoadUserHive "myuserA"
Pop $0
DetailPrint 
"RegUnLoadUserHive Result : $0" 
* CreateAccountEx calls NetUserAdd(USER_INFO_2)
* BuiltAccountEnv calls LogonUser+LoadUserProfile+UnloadUserProfile (This creates the profile directory and probably the ntuser.dat file but it does not load it into HKEY_USERS)
* RegLoadUserHive calls RegLoadKey after finding the path to ntuser.dat in ProfileList

If this does not work for you then perhaps you should try contacting the plug-in author for support, it was probably never tested on Windows 10.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast 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