// Package launcher configures Lantern to run on system start
package launcher

import (
	"fmt"
	"github.com/kardianos/osext"
	"github.com/luisiturrios/gowin"

	"github.com/getlantern/golog"
)

const (
	runDir = `Software\Microsoft\Windows\CurrentVersion\Run`
)

var (
	log = golog.LoggerFor("launcher")
)

func CreateLaunchFile(autoLaunch bool) {
	var startupCommand string

	lanternPath, err := osext.Executable()
	if err != nil {
		log.Errorf("Could not get Lantern directory path: %q", err)
		return
	}

	if autoLaunch {
		// Start Lantern normally.
		startupCommand = fmt.Sprintf(`"%s" -startup`, lanternPath)
	} else {
		// Just clear stored proxy settings and quit.
		startupCommand = fmt.Sprintf(`"%s" -clear-proxy-settings`, lanternPath)
	}

	err = gowin.WriteStringReg("HKCU", runDir, "Lantern", startupCommand)
	if err != nil {
		log.Errorf("Error setting Lantern auto-start registry key: %q", err)
	}
}

// Package launcher configures Lantern to run on system start
package launcher

import (
	"github.com/kardianos/osext"
	"github.com/luisiturrios/gowin"

	"github.com/getlantern/golog"
)

const (
	runDir = `Software\Microsoft\Windows\CurrentVersion\Run`
)

var (
	log = golog.LoggerFor("launcher")
)

func CreateLaunchFile(autoLaunch bool) {
	var err error

	if autoLaunch {
		lanternPath, err := osext.Executable()
		if err != nil {
			log.Errorf("Could not get Lantern directory path: %q", err)
			return
		}
		err = gowin.WriteStringReg("HKCU", runDir, "Lantern", fmt.Sprintf(`"%s" -startup`, lanternPath))
		if err != nil {
			log.Errorf("Error inserting Lantern auto-start registry key: %q", err)
		}
	} else {
		// Just remove proxy settings and quit.
		err = gowin.WriteStringReg("HKCU", runDir, "Lantern", fmt.Sprintf(`"%s" -clear-proxy-settings`, lanternPath))
		if err != nil {
			log.Errorf("Error removing Lantern auto-start registry key: %q", err)
		}
	}
}

--- 
+++ 
@@ -2,6 +2,7 @@
 package launcher
 
 import (
+	"fmt"
 	"github.com/kardianos/osext"
 	"github.com/luisiturrios/gowin"
 
@@ -17,23 +18,24 @@
 )
 
 func CreateLaunchFile(autoLaunch bool) {
-	var err error
+	var startupCommand string
+
+	lanternPath, err := osext.Executable()
+	if err != nil {
+		log.Errorf("Could not get Lantern directory path: %q", err)
+		return
+	}
 
 	if autoLaunch {
-		lanternPath, err := osext.Executable()
-		if err != nil {
-			log.Errorf("Could not get Lantern directory path: %q", err)
-			return
-		}
-		err = gowin.WriteStringReg("HKCU", runDir, "Lantern", fmt.Sprintf(`"%s" -startup`, lanternPath))
-		if err != nil {
-			log.Errorf("Error inserting Lantern auto-start registry key: %q", err)
-		}
+		// Start Lantern normally.
+		startupCommand = fmt.Sprintf(`"%s" -startup`, lanternPath)
 	} else {
-		// Just remove proxy settings and quit.
-		err = gowin.WriteStringReg("HKCU", runDir, "Lantern", fmt.Sprintf(`"%s" -clear-proxy-settings`, lanternPath))
-		if err != nil {
-			log.Errorf("Error removing Lantern auto-start registry key: %q", err)
-		}
+		// Just clear stored proxy settings and quit.
+		startupCommand = fmt.Sprintf(`"%s" -clear-proxy-settings`, lanternPath)
+	}
+
+	err = gowin.WriteStringReg("HKCU", runDir, "Lantern", startupCommand)
+	if err != nil {
+		log.Errorf("Error setting Lantern auto-start registry key: %q", err)
 	}
 }
Use either -startup or -clear-proxy-settings on the Lantern HKCU/.../CurrentVersion/Run registry key.
