programming-examples/perl/Win32/Create a new user account.pl
2019-11-15 12:59:38 +01:00

33 lines
667 B
Raku

#!/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() );
}