The command line adds the user's "Log on as a service" right (when adding Windows users, the doorway is not more common) good

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.