你的分享就是我们的动力 ---﹥

Perl 添加 Windows 系统帐号

时间:2013-05-30 00:05来源:www.chengxuyuans.com 点击:

代码简介

暂无

Perl代码片段

#!/usr/bin/perl -w

use Win32::NetAdmin;

$host = '';

$username = "userName";
$password = "password";

$comment  = "your comments";

# User's home directory.
$homedir = "C:\\users\\" . $username;


$logon_script = "";

$flags = UF_SCRIPT | UF_NORMAL_ACCOUNT;

$status = Win32::NetAdmin::UserCreate($host,$username,$password,
             0, # Password age. Ignored.
             USER_PRIV_USER,  # Must use this value.
             $homedir,$comment,$flags,$logon_script);

if ($status) {
   print "Added $username account.\n";
} else {
   print_error();
}

sub print_error {
    print Win32::FormatMessage( Win32::GetLastError() );
}

转载注明地址:http://www.chengxuyuans.com/Perl/63091.html