title: Installer that adds entry to GPO Startup scripts
body: <p>I'm in the process of writing an installer using NSIS that will add an entry to the computer's GPO to run a command on system boot.</p>
  
  <pre><code># From http://nsis.sourceforge.net/LGP_Startup/Shutdown_Script
  !include LGPScript.nsh
  
  Section
    SetOutPath -
  
    # Install all files from myprog directory into C:\Program Files\myprog
    File myprog\*
  
    # Copy mysystweak.bat to System32\GroupPolicy\Machine\Scripts\Startup
    SetOutPath $SYSDIR\GroupPolicy\Machine\Scripts\Startup
    File myprog\mysystweak.bat
    SetOutPath -
  
    # Add GPO entry to execute mysystweak.bat on startup
    ${LGPScript::Create} 'Startup' 'mysystweak.bat' '' $R1
    DetailPrint "Create startup LGP return code:$R1"
  
    # Write uninstaller
    Writeuninstaller "${uninstall_name}"
  SectionEnd
  </code></pre>
  
  <p>Everything goes well except nothing shows up in …\Startup. The installer thinks everything worked:</p>
  
  <pre><code>Output folder: C:\WINDOWS\system32\GroupPolicy\Machine\Scripts\Startup
  Extract: mysystweak.bat... 100%
  Output folder: C:\Program Files (x86)\myprog
  </code></pre>
  
  <p>I originally tried using CopyFiles to copy the batch file from $INSTDIR into …\Startup, but got the same result.</p>
  
  <p>What's going wrong here?</p>
  
  <p><em>related: <a href="https://serverfault.com/q/266338/2101">https://serverfault.com/q/266338/2101</a></em></p>