Exemplo n.º 1
0
 private static void AllowTheHostedNetwork()
 {
     try
     {
         Process.Start(new ProcessStartInfo()
         {
             FileName        = "netsh",
             Arguments       = "wlan set hostednetwork mode=allow",
             UseShellExecute = false,
             CreateNoWindow  = true,
             WindowStyle     = ProcessWindowStyle.Hidden,
         });
     }
     catch (Exception ex)
     {
         LogExceptions.Log(ex);
     }
 }
Exemplo n.º 2
0
        private static void StartTheServices(bool stopServices)
        {
            try
            {
                // Routing and Remote Access
                using (var svc = new ServiceController())
                {
                    svc.ServiceName = "RemoteAccess";

                    if (svc.Status != ServiceControllerStatus.Running)
                    {
                        try
                        {
                            ServiceHelper.ChangeStartMode(svc, ServiceStartMode.Automatic);
                        }
                        catch (Exception ex)
                        {
                            LogExceptions.Log(ex);
                        }

                        svc.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                LogExceptions.Log(ex);
            }

            if (stopServices)
            {
                try
                {
                    // Internet Connection Sharing (ICS)
                    using (var svc = new ServiceController())
                    {
                        svc.ServiceName = "SharedAccess";

                        if (svc.Status != ServiceControllerStatus.Running)
                        {
                            try
                            {
                                ServiceHelper.ChangeStartMode(svc, ServiceStartMode.Manual);
                            }
                            catch (Exception ex)
                            {
                                LogExceptions.Log(ex);
                            }
                        }
                        else
                        {
                            svc.Stop();
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogExceptions.Log(ex);
                }
            }
        }