2009年5月30日

Delphi JEDI 增加、刪除 Windows 使用者帳號


需先安裝 JEDI VCL for Delphi

建立 Delphi Console Application
File -> New -> Other... -> Console Application

輸入參數
Run -> Paramters...
Paramters 中輸入 Username Password

program Project1;
{$APPTYPE CONSOLE}

uses
SysUtils, JclLANMan, System;

var
Username: string;
Password: string;
Input: string;
begin
if ParamCount < 2 then
begin
WriteLn(ExtractFileName(ParamStr(0)) + ' Username Password');
ReadLn(Input);
Exit;
end;
Username := ParamStr(1);
Password := ParamStr(2);
if CreateLocalAccount(Username, 'FullName',
Password, 'Comment', 'HomeDir', 'Script') then
begin
WriteLn('Create User ' + Username + ' Success');
if DeleteLocalAccount(Username) then
begin
WriteLn('Delete User ' + Username + ' Success');
end
else
begin
WriteLn('Delete User ' + Username + ' Success');
end;
end
else
begin
WriteLn('Create User ' + Username + ' Failure');
end;
ReadLn(Input);
end.
{ Stdout
Create User Username Success
Delete User Username Success
}

沒有留言:

網誌存檔