Add the user's "Log on as a service" right on the command line

Source: Internet
Author: User

1. Open the console ("START" | "run" and enter: MMC)

2. "file" menu | "Add/delete Management Unit" | "add..." | select "security template" | "close ".

3. On the "C: \ WINDOWS \ SECURITY \ templates" node, right-click "create template... ", in the pop-up dialog box, enter" new "in" Template Name ", and click OK.

4. Open the "New | Local Policy | user permission assignment" node and add the user to be granted this permission in "Log on as a server" on the right.

5. Right-click the new node and choose Save As... to save it to C: \ sec. INF ".

6. In the batch Creation Document, enter SeCEdit Configure/DB SeCEdit. sdb/CFG c: \ sec. INF.

 

The SQL Server database synchronization function is used in the new project in the past two days.ProgramThe Logon account of the SQLServerAgent service is automatically added during installation.

The following describesCodeFor your reference.

-- Install 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
-- Append the database after restart and automatically add synchronization jobs.
File. runonreboot (sessionvar. Expand ( " C: \ Program Files \ database \ setup. cmd " ), "" );
-- Add a Windows User
Shell. Execute ( " Net " , " Open " , " User SQLAgent 123456/Add/passwordreq: yes/passwordchg: No/expires: Never " , "" , Sw_minimize, True );
-- Add a user to the Administrator Group
Shell. Execute ( " Net " , " Open " , " Localgroup administrators SQLAgent/Add " , "" , Sw_minimize, True );
-- Set the Logon account, password, and start type of the SQLServerAgent service to automatic.
Shell. Execute ( " SC " , " Open " , " Config SQLServerAgent start = auto OBJ =. \ SQLAgent Password = 123456 " , "" , Sw_minimize, True );
-- Hide this user when Windows is started.
Shell. Execute ( " Regedit " , " Open " , " /S c: \ hidesqlagent. Reg " , "" , Sw_minimize, True );
-- Grant this user the "service-based login right" and "Deny local login"
Shell. Execute ( " SeCEdit " , " Open " , " /Configure/DB SeCEdit. sdb/CFG c: \ sec. inf " , "" , Sw_minimize, True );
-- Clear temporary files
Folder. deletetree (sessionvar. Expand ( " % Appfolder % \ msde2000 " ), Nil );
File. deleteonreboot ( " C: \ hidesqlagent. Reg " );
File. deleteonreboot ( " C: \ sec. inf " );
-- Restart the computer after installation.
_ Needsreboot =   True ;

 

 

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.