code: func controlService(c svc.Cmd, to svc.State) error {
  	// Connect to the windows service manager.
  	serviceManager, err := mgr.Connect()
  	if err != nil {
  		return err
  	}
  	defer serviceManager.Disconnect()
  
  	service, err := serviceManager.OpenService(svcName)
  	if err != nil {
  		return fmt.Errorf("could not access service: %v", err)
  	}
  	defer service.Close()
  
  	status, err := service.Control(c)
  	if err != nil {
  		return fmt.Errorf("could not send control=%d: %v", c, err)
  	}
  
  	// Send the control message.
  	timeout := time.Now().Add(10 * time.Second)
  	for status.State != to {
  		if timeout.Before(time.Now()) {
  			return fmt.Errorf("timeout waiting for service to go "+
  				"to state=%d", to)
  		}
  		time.Sleep(300 * time.Millisecond)
  		status, err = service.Query()
  		if err != nil {
  			return fmt.Errorf("could not retrieve service "+
  				"status: %v", err)
  		}
  	}
  
  	return nil
  }
docs: // controlService allows commands which change the status of the service.  It
  // also waits for up to 10 seconds for the service to change to the passed
  // state.