title: How to modify local group policy and local security policy programatically?
body: <p>What I need to do is to modify local group policy and local security policy on different machine.It is very inconvenient to modify them each item, so I want to find out any way that can modify them through programming.
  I have tried the way in this <a href="https://social.technet.microsoft.com/Forums/windows/en-US/cedf320b-cbf5-4f32-b37c-5d44706181dc/how-to-manage-local-security-policy?forum=winservercore" rel="nofollow noreferrer">website</a>,but it didn't work. 
  What I need to modify are shown as below:</p>
  
  <p>1.Launch the Local/Group Policy Editor. </p>
  
  <ul>
  <li><p>Disable Windows update option at shutdown 
  Go to Computer Configuration -> Administrative Templates -> Windows Components -> Windows Updates, and double click on Windows Updates. </p>
  
  <p>set "Do not display 'Install Updates and Shut Down'" to <strong>Enable</strong>.</p></li>
  <li><p>Set "Display Shutdown Event Tracker" in Group Policy Editor to Disabled.  </p>
  
  <p>Computer Configuration->Administrative Templates->System. Set "Display Shutdown Event Tracker" to <strong>Disabled</strong>. </p></li>
  <li><p>Computer Configuration->Windows Settings->Security Settings->Local Policies->Security Options.</p>
  
  <p>Set the group policy option "Shutdown: Allow system to be shut down without having to log on" to Disabled.</p></li>
  </ul>
  
  <p>2.Launch the Local Security Policy(run secpol.msc). </p>
  
  <ul>
  <li><p>Security Settings->Local Policies->Security Options.</p>
  
  <p>Set the “Interactive logon: Do not display last username" option to <strong>Enabled</strong>. </p></li>
  <li><p>Security Settings->Local Policies->User Rights Assignment.</p>
  
  <p>Add the user Administrator to "Deny logon through terminal services".</p></li>
  <li><p>Security Settings->Account Policies > Password Policy</p>
  
  <p>Set the "Password must <strong>meet complexity requirements</strong>" </p></li>
  </ul>
  
  <p>By the way, the windows operation is Windows server 2008r2 and windows server 2012r2.</p>