I have created a small tool that provides a GUI for gathering information in order to create a user account in Windows. I figured it would be a good idea to make direct API calls and get to understand how the system plugin works ... After going over the source of the UserManager plugin as well as several MSDN pages I am having trouble getting this to work.
In the first part of my code I am using InstallOptionsEx in order to create the GUI then I gather all the info into variables (working part, not shown here). The second part however that is handling the user creation is not working:
If I make the call like this:
Note that all the variables used have been declared. Also I am using some error checking to make sure that the username and password have correct lengths.
Any help will be much appreciated
CF
More info about the USER_INFO_1 structure can be found here
The NetUserAdd function is described here
In the first part of my code I am using InstallOptionsEx in order to create the GUI then I gather all the info into variables (working part, not shown here). The second part however that is handling the user creation is not working:
The above gives me error 997 (ERROR_IO_PENDING) and $4 gives me error 87 (INVALID_PARAMETER)code:
; I am using some default definitions straight out of Lmaccess.h
!define UF_SCRIPT 0x000001
!define UF_NORMAL_ACCOUNT 0x000200
!define UF_DONT_EXPIRE_PASSWD 0x010000
!define USER_PRIV_USER 0x000001
; First I get the computername as ComputerNamePhysicalNetBIOS:
System::Call 'kernel32.dll::GetComputerNameExW(i 4, w .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2'
StrCpy $TargetServerName "\\$0"
; Then I am constructing the USER_INFO_1 structure
StrCpy $1 "$TargetServerName"
StrCpy $2 1
StrCpy $R1 "$UserName"
StrCpy $R2 "$Password"
StrCpy $R3 ${USER_PRIV_USER}
StrCpy $R4 "$UserDescription"
System::Int64Op ${UF_SCRIPT} + ${UF_NORMAL_ACCOUNT}
Pop $R5
System::Int64Op $R5 + ${UF_DONT_EXPIRE_PASSWD}
Pop $R5
System::Call '*(w R1, w R2, i 0, i R3, n, w R4, i R5, n)i.s'
Pop $R6
; Then I call the NetAddUser function from netapi32.dll
System::Call 'netapi32.dll::NetUserAdd(w r1, i 1, i R6, i.r3) i.r4 ?e'
If I make the call like this:
then I get error 997 (ERROR_IO_PENDING) and $4 gives me error 2202 (ERROR_BAD_USERNAME)code:
System::Call 'netapi32.dll::NetUserAdd(w r1, i 1, *i R6, i.r3) i.r4 ?e'
Note that all the variables used have been declared. Also I am using some error checking to make sure that the username and password have correct lengths.
Any help will be much appreciated

CF
More info about the USER_INFO_1 structure can be found here
The NetUserAdd function is described here
Comment