1. Open the console (start | Run in input: MMC)
2. "File" menu | " Add Delete snap-in "|" Add ... "| select" Security template "|" Close ".
3, on the "C:\Windows\Security\templates" node, right-click "New Template ..." In the popup dialog box "template name" entered: New, OK.
4. Open the new| Local Policy | User Rights Assignment node and, on the right side, add the user to whom you want to assign the permission as a server login.
5. Then, right-click on the "New" node and select "Save As ..." to "C:\Sec.inf".
6. Create Batch document input:secedit configure/db secedit.sdb/cfg c:\Sec.inf
This two-day new project uses the SQL Server database synchronization feature, which requires the program to automatically add the login account of the SQLServerAgent service during the installation process.
The following code is written in setupfactory for reference.
--Installation MSDE2000
if (not registry.doeskeyexist (HKEY_LOCAL_MACHINE, "Software\\microsoft\\mssqlserver\\setup")) Then
Shell.execute (Sessionvar.expand ("%appfolder%\\msde2000\\setup.exe"), "open", "", "", SW_SHOWNORMAL, True);
End
--Attach the database after reboot, and automatically add synchronization jobs.
File.runonreboot (Sessionvar.expand ("C:\\Program files\\ Database \\Setup.cmd"), "");
--Add Windows users
Shell.execute ("NET", "open", "User SQLAgent 123456/add/passwordreq:yes/passwordchg:no/expires:never", "", Sw_ MINIMIZE, True);
--Add users to the Administrator group
Shell.execute ("NET", "open", "localgroup Administrators sqlagent/add", "", sw_minimize, True);
--Set the login account, password, and startup type of the SQLServerAgent service to Automatic.
Shell.execute ("SC", "open", "config SQLServerAgent start= auto obj=. \\SQLAgent password= 123456", "", sw_minimize, True);
--Hides the user when Windows starts.
Shell.execute ("regedit", "open", "/s C:\\hidesqlagent.reg", "", sw_minimize, True);
--Give the user the "right to log on as a service" and "Deny log on locally"
Shell.execute ("secedit", "open", "/configure/db secedit.sdb/cfg c:\\sec.inf", "", sw_minimize, True);
--Clean up temporary files
Folder.deletetree (Sessionvar.expand ("%appfolder%\\msde2000"), nil);
File.deleteonreboot ("C:\\hidesqlagent.reg");
File.deleteonreboot ("C:\\sec.inf");
--Requires restarting the computer after installation is complete
_needsreboot = true;
Http://www.cnblogs.com/pegger/archive/2009/02/18/1393052.html
The command line adds the user's "Log on as a service" right (when adding Windows users, the doorway is not more common) good