# NetUserAdd($server, \@shares) # Creates a new user testuser on server \\$computer. # MUST SPECIFY TARGET COMPUTER AS FIRST ARGUMENT (with or without '\\') # AND USER TO BE CREATED AS SECOND ARGUMENT use Win32::Lanman ; $computer = "$ARGV[0]" ; $user = "$ARGV[1]" ; $computer = substr($computer,2,) if (substr($computer,0,2) eq "\\\\") ; #print "------------[$computer]------------\n" ; if(!Win32::Lanman::NetUserAdd("\\\\$computer",{ 'name' => "$user", 'password' => 'testpassword', 'home_dir' => '\\\\$computer\\testshare', 'comment' => 'test users comment', 'flags' => UF_ACCOUNTDISABLE | UF_PASSWD_CANT_CHANGE | UF_TEMP_DUPLICATE_ACCOUNT, 'script_path' => '\\\\$computer\\testshare\\logon_script.bat', 'full_name' => 'test users full name', 'usr_comment' => 'test users usr comment', 'parms' => 'test users parameters', 'workstations' => 'comp0001,comp0002,comp0003,comp0004,comp0005,comp0006,comp0007,comp0008', 'profile' => '\\\\$computer\\testshare\\profile_dir', 'home_dir_drive' => 'Y:', 'acct_expires' => time() + 3600 * 24, 'country_code' => 49, 'code_page' => 850, 'logon_hours' => pack("b168", "000000001111111100000000" x 7), 'password_expired' => 1})) { print "Sorry, something went wrong; error: "; # get the error code print Win32::Lanman::GetLastError(); print " : $^E\n"; exit 1; }