/// <summary> /// Upgrades the driver. /// </summary> /// <param name="driver">The driver.</param> /// <param name="queueName">Name of the queue.</param> public void UpgradeDriver(PrintDeviceDriver driver, string queueName) { if (driver == null) { throw new ArgumentNullException("driver"); } DateTime start = DateTime.Now; DateTime end = DateTime.Now; InstallStatusData status = _installStatus.Create(queueName); lock (_driverLock) { UpdateStatus("Upgrading print driver... " + driver.Name); status.Record("DRIVER UPGRADE START", out start); // Upgrade the driver, but do not check to see if the driver is installed, // this has already been done. DriverInstaller.Upgrade(driver.CreateDetail(), queueName); status.Record("DRIVER UPGRADE END", out end); status.Record("DRIVER UPGRADE TOTAL", end.Subtract(start)); } }
protected override void OnStart(string[] args) { Log.Info("Scarlet.Crush Productions DSx Service Started"); Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); Log.InfoFormat("Setting working directory to {0}", GlobalConfiguration.AppDirectory); Directory.SetCurrentDirectory(GlobalConfiguration.AppDirectory); _mControlHandler = ServiceControlHandler; _mServiceHandle = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero); var installTask = Task.Factory.StartNew(() => { if (GlobalConfiguration.Instance.ForceBluetoothDriverReinstallation) { DriverInstaller.InstallBluetoothDongles( ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.BluetoothHost)); } if (GlobalConfiguration.Instance.ForceDs3DriverReinstallation) { DriverInstaller.InstallDualShock3Controllers( ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.DualShock3)); } if (GlobalConfiguration.Instance.ForceDs4DriverReinstallation) { DriverInstaller.InstallDualShock4Controllers( ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.DualSHock4)); } }); installTask.ContinueWith(task => { Log.FatalFormat("Error during driver installation: {0}", task.Exception); Stop(); }, TaskContinuationOptions.OnlyOnFaulted); try { rootHub.Open(); rootHub.Start(); } catch (RootHubAlreadyStartedException rhex) { Log.FatalFormat("Couldn't start the root hub: {0}", rhex.Message); Stop(); return; } ScpDevice.RegisterNotify(_mServiceHandle, UsbDs3.DeviceClassGuid, ref _ds3Notify, false); ScpDevice.RegisterNotify(_mServiceHandle, UsbDs4.DeviceClassGuid, ref _ds4Notify, false); ScpDevice.RegisterNotify(_mServiceHandle, BthDongle.DeviceClassGuid, ref _bthNotify, false); ScpDevice.RegisterNotify(_mServiceHandle, UsbGenericGamepad.DeviceClassGuid, ref _genericNotify, false); }
protected override void OnStart(string[] args) { Log.Info("Scarlet.Crush Productions DS3 Service Started"); Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); Log.InfoFormat("Setting working directory to {0}", WorkingDirectory); Directory.SetCurrentDirectory(WorkingDirectory); _mControlHandler = ServiceControlHandler; _mServiceHandle = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero); var installTask = Task.Factory.StartNew(() => { if (Settings.Default.InstallBluetoothDongles) { DriverInstaller.InstallBluetoothDongles(); } if (Settings.Default.InstallDualShock3Controllers) { DriverInstaller.InstallDualShock3Controllers(); } if (Settings.Default.InstallDualShock4Controllers) { DriverInstaller.InstallDualShock4Controllers(); } }); installTask.ContinueWith(task => { Log.FatalFormat("Error during driver installation: {0}", task.Exception); Stop(); }, TaskContinuationOptions.OnlyOnFaulted); try { rootHub.Open(); rootHub.Start(); } catch (RootHubAlreadyStartedException rhex) { Log.FatalFormat("Couldn't start the root hub: {0}", rhex.Message); Stop(); return; } ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs3.USB_CLASS_GUID), ref _mDs3Notify, false); ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs4.USB_CLASS_GUID), ref _mDs4Notify, false); ScpDevice.RegisterNotify(_mServiceHandle, new Guid(BthDongle.BTH_CLASS_GUID), ref _mBthNotify, false); }
private void MainWindow_Shown(object sender, EventArgs e) { if (Settings.Default.firstStart) { Settings.Default.Upgrade(); } if (Settings.Default.firstStart) { DriverInstaller.DisplayPrompt(); Settings.Default.firstStart = false; Settings.Default.Save(); } }
//delete the driver: pnputil -f -d oem81.inf //show all drivers: pnputil -e private void VerifyDriverInstallation() { if (!DriversAreInstalled()) { var result = MessageBox.Show("The required drivers for VMSpc are not installed. Do you want to install them now? This will require an " + "internet connection if the installation file is not already available", "Install Drivers", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { if (DriverInstaller.InstallDrivers() && DriversAreInstalled()) { MessageBox.Show("Drivers successfully installed"); } else { MessageBox.Show("Drivers failed to install. Please see instructions on our website or contact support"); } } } }
/// <summary> /// Installs a local print queue that points to this print device. /// </summary> /// <param name="installCheck">if set to <c>true</c> and the driver is already installed, then this will return.</param> /// <example> /// The example below shows how to install a driver and associated queue for a given local print /// device. In this example, all drivers for a given distribution are first loaded, then one /// driver is chosen based on the system architecture. In addition, a port is created that points /// to the target device. The port, driver and platform type for the device are given to the print /// device object when then proceeds to install the driver and queue on the system. /// <code> /// // Load all drivers in the driver package located in the given directory /// PrintDeviceDriverCollection drivers = new PrintDeviceDriverCollection(); /// drivers.LoadFromDirectory(@"\\DriverRepository\5.7.0\UPD\pcl6\winxp_vista_x64", includeAllArchitectures: true); /// if (drivers.Count() > 0) /// { /// // Use the first driver from the distribution that matches this architecture /// PrintDeviceDriver driver = drivers.Where(x => x.Architecture == ProcessorArchitectureInfo.Current).FirstOrDefault(); /// if (driver == null) /// { /// throw new InvalidOperationException("Device driver for this architecture not found in the distribution"); /// } /// // Construct a port that the print queue will use when printing jobs. /// var port = StandardTcpIPPort.CreateRawPortData("15.198.212.221", portName: "IP_15.198.212.221", snmpEnabled: false); /// // Construct a local print device using all of the data built thus far. /// var device = new LocalPrintDevice(driver, port, DevicePlatform.Physical); /// // Install the device, which includes installing the driver and creating the queue /// device.Install(); /// } /// </code></example> /// <remarks>This method goes through a series of calls to incrementally build the queue. It starts by /// installing the driver if not already installed. It then creates the printer port, then /// sets up the configuration file (CFM) if there is one, then applies the printer shortcut /// if it exists. Then it adds the actual print queue, followed by the setup of client rendering /// and then configures the shared queue setting. It then waits until all these steps are complete.</remarks> public void Install() { if (PrintQueueInstaller.IsInstalled(QueueName)) { TraceFactory.Logger.Info("Print queue is already installed"); return; } // Install the print driver CopyDriver(); DriverInstaller.Install(_driver); // Create the Printer Port CreatePort(); // Create the print queue CreatePrintQueue(); // Wait until all the queue creation activity has completed. PrintQueueInstaller.WaitForInstallationComplete(QueueName, _driver.Name); }
/// <summary> /// Installs the designated driver. /// </summary> /// <param name="driver">The driver.</param> /// <param name="forceInstall">if set to <c>true</c> then an install is forced.</param> public void InstallDriver(PrintDeviceDriver driver, bool forceInstall = false) { if (driver == null) { throw new ArgumentNullException("driver"); } DateTime start = DateTime.Now; DateTime end = DateTime.Now; InstallStatusData status = _installStatus.Create(driver.Name); lock (_driverLock) { UpdateStatus("Installing print driver... " + driver.Name); status.Record("DRIVER INSTALL START", out start); DriverInstaller.Install(driver.CreateDetail(), forceInstall); status.Record("DRIVER INSTALL END", out end); _installedDrivers.Add(driver.Name); status.Record("DRIVER INSTALL TOTAL", end.Subtract(start)); } }
/// <summary> /// Installs the PrintDriver With LPR Queue Details as in activity Data /// </summary> private void InstallPrintDriverWithLPRQueue() { DriverDetails driver = CreateDriver(_activityData.PrintDriver, _pluginSettings["PrintDriverServer"]); UpdateStatus($"Installing driver from {driver.InfPath}"); ExecutionServices.SystemTrace.LogDebug($"Installing driver from {driver.InfPath}"); DriverInstaller.Install(driver); UpdateStatus("Driver Installation Completed"); UpdateStatus(string.Format("Creating LPR Port connecting to HPAC Server :{0}, QueueName : {1}", _hpacServerIP, _activityData.LprQueueName)); ExecutionServices.SystemTrace.LogDebug($"Creating LPR Port connecting to HPAC Server :{_hpacServerIP}, QueueName : {_activityData.LprQueueName}"); string portName = string.Format("_IP {0}_{1}", _hpacServerIP, _activityData.LprQueueName); PrintPortManager.AddLprPort(portName, LprPrinterPortInfo.DefaultPortNumber, _hpacServerIP, _activityData.LprQueueName); UpdateStatus("Port Creation Completed"); UpdateStatus(string.Format("Creating LocalPrintDevice with Driver :{0} and port : {1}", driver.Name, portName)); ExecutionServices.SystemTrace.LogDebug(string.Format("Creating LocalPrintDevice with Driver :{0} and port : {1}", driver.Name, portName)); string queueName = string.Format("{0} ({1})", driver.Name, portName); if (!PrintQueueInstaller.IsInstalled(queueName)) { PrintQueueInstaller.CreatePrintQueue(queueName, driver.Name, portName, driver.PrintProcessor); PrintQueueInstaller.WaitForInstallationComplete(queueName, driver.Name); UpdateStatus("Print Device Installation Completed"); } PrintQueue queue = PrintQueueController.GetPrintQueue(queueName); if (_activityData.IsDefaultPrinter) { PrintQueueController.SetDefaultQueue(queue); UpdateStatus("Setting the Installed Print Device as a default Print Device"); } ConfigurePrinterAttributes(queue); UpdateStatus("Printer Attributes Configuration Completed"); }
private void InstallDrivers_Executed(object sender, ExecutedRoutedEventArgs e) { DriverInstaller.InstallDrivers(); }
private void InstallDriversMenuItem_Click(object sender, EventArgs e) { DriverInstaller.DisplayPrompt(); }
protected override void OnStart(string[] args) { var sw = Stopwatch.StartNew(); Log.Info("Scarlet.Crush Productions DSx Service Started"); Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); Log.DebugFormat("Setting working directory to {0}", GlobalConfiguration.AppDirectory); Directory.SetCurrentDirectory(GlobalConfiguration.AppDirectory); _mControlHandler = ServiceControlHandler; _mServiceHandle = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero); var installTask = Task.Factory.StartNew(() => { using (var db = new ScpDb()) { var bthDevices = db.Engine.GetAllDbEntities <WdiDeviceInfo>(ScpDb.TableDevices) .Where(d => d.Value.DeviceType == WdiUsbDeviceType.BluetoothHost) .Select(d => d.Value); if (GlobalConfiguration.Instance.ForceBluetoothDriverReinstallation) { DriverInstaller.InstallBluetoothDongles(bthDevices); } var ds3Devices = db.Engine.GetAllDbEntities <WdiDeviceInfo>(ScpDb.TableDevices) .Where(d => d.Value.DeviceType == WdiUsbDeviceType.DualShock3) .Select(d => d.Value); if (GlobalConfiguration.Instance.ForceDs3DriverReinstallation) { DriverInstaller.InstallDualShock3Controllers(ds3Devices); } var ds4Devices = db.Engine.GetAllDbEntities <WdiDeviceInfo>(ScpDb.TableDevices) .Where(d => d.Value.DeviceType == WdiUsbDeviceType.DualSHock4) .Select(d => d.Value); if (GlobalConfiguration.Instance.ForceDs4DriverReinstallation) { DriverInstaller.InstallDualShock4Controllers(ds4Devices); } } }); installTask.ContinueWith(task => { Log.FatalFormat("Error during driver installation: {0}", task.Exception); Stop(); }, TaskContinuationOptions.OnlyOnFaulted); Log.DebugFormat("Time spent 'till Root Hub start: {0}", sw.Elapsed); var hubStartTask = Task.Factory.StartNew(() => { rootHub.Open(); rootHub.Start(); }); hubStartTask.ContinueWith(task => { Log.FatalFormat("Couldn't start the root hub: {0}", task.Exception); Stop(); }, TaskContinuationOptions.OnlyOnFaulted); Log.DebugFormat("Time spent 'till registering notifications: {0}", sw.Elapsed); ScpDevice.RegisterNotify(_mServiceHandle, UsbDs3.DeviceClassGuid, ref _ds3Notify, false); ScpDevice.RegisterNotify(_mServiceHandle, UsbDs4.DeviceClassGuid, ref _ds4Notify, false); ScpDevice.RegisterNotify(_mServiceHandle, BthDongle.DeviceClassGuid, ref _bthNotify, false); ScpDevice.RegisterNotify(_mServiceHandle, UsbGenericGamepad.DeviceClassGuid, ref _genericNotify, false); Log.DebugFormat("Total Time spent in Service Start method: {0}", sw.Elapsed); }
private async void Button_Click(object sender, RoutedEventArgs e) { MainButton.IsEnabled = !MainButton.IsEnabled; await Task.Run(() => { #region Service tasks Log.InfoFormat("Stopping \"SCP DS3 Service\"..."); StopService("SCP DS3 Service"); Log.InfoFormat("Stopping \"SCP DSx Service\"..."); StopService("SCP DSx Service"); Log.InfoFormat("Searching for running processes..."); foreach (var proc in Process.GetProcessesByName("Ds3Service")) { Log.InfoFormat("Killing process: {0}", proc.ProcessName); proc.Kill(); } foreach (var proc in Process.GetProcessesByName("DsxService")) { Log.InfoFormat("Killing process: {0}", proc.ProcessName); proc.Kill(); } Log.InfoFormat("Removing service..."); Process.Start("sc", "delete Ds3Service").WaitForExit(); Process.Start("sc", "delete DsxService").WaitForExit(); #endregion #region Driver store clean-up Log.InfoFormat("Searching the driver store..."); var storeEntries = DrvStore.EnumeratePackages(); foreach (var entry in storeEntries.Where(dse => dse.DriverPkgProvider.Equals("Scarlet.Crush Productions"))) { Log.InfoFormat("Removing package from driver store: {0} by {1}", entry.DriverPublishedName, entry.DriverPkgProvider); DrvStore.DeletePackage(entry, true); } foreach (var entry in storeEntries.Where(dse => dse.DriverSignerName.Contains("libwdi autogenerated") && dse.DriverPkgProvider.Equals("libusbK"))) { Log.InfoFormat("Removing package from driver store: {0} by {1}", entry.DriverPublishedName, entry.DriverPkgProvider); DrvStore.DeletePackage(entry, true); } foreach (var entry in storeEntries.Where(dse => dse.DriverPkgProvider.Contains("MotioninJoy"))) { Log.InfoFormat("Removing package from driver store: {0} by {1}", entry.DriverPublishedName, entry.DriverPkgProvider); DrvStore.DeletePackage(entry, true); } #endregion #region Driver uninstallation string devPath = string.Empty; string instanceId = string.Empty; bool rebootRequired = false; DriverInstaller.UninstallBluetoothDongles(ref rebootRequired); DriverInstaller.UninstallDualShock3Controllers(ref rebootRequired); DriverInstaller.UninstallDualShock4Controllers(ref rebootRequired); if (Devcon.Find(Guid.Parse("f679f562-3164-42ce-a4db-e7ddbe723909"), ref devPath, ref instanceId)) { if (Devcon.Remove(Guid.Parse("f679f562-3164-42ce-a4db-e7ddbe723909"), devPath, instanceId)) { Difx.Instance.Uninstall(Path.Combine(@".\System\", @"ScpVBus.inf"), DifxFlags.DRIVER_PACKAGE_DELETE_FILES, out rebootRequired); } } while (Devcon.Find(Guid.Parse("2F87C733-60E0-4355-8515-95D6978418B2"), ref devPath, ref instanceId)) { Devcon.Remove(Guid.Parse("2F87C733-60E0-4355-8515-95D6978418B2"), devPath, instanceId); } while (Devcon.Find(Guid.Parse("E2824A09-DBAA-4407-85CA-C8E8FF5F6FFA"), ref devPath, ref instanceId)) { Devcon.Remove(Guid.Parse("E2824A09-DBAA-4407-85CA-C8E8FF5F6FFA"), devPath, instanceId); } while (Devcon.Find(Guid.Parse("2ED90CE1-376F-4982-8F7F-E056CBC3CA71"), ref devPath, ref instanceId)) { Devcon.Remove(Guid.Parse("2ED90CE1-376F-4982-8F7F-E056CBC3CA71"), devPath, instanceId); } Devcon.Refresh(); #endregion #region Cert store clean-up CertStore.Open(OpenFlags.MaxAllowed); foreach (var cert in CertStore.Certificates.Cast <X509Certificate2>().Where(c => c.FriendlyName.Contains("libwdi"))) { Log.InfoFormat("Removing certificate from root certificate store: {0}", cert.SubjectName.Name); CertStore.Remove(cert); } //Close the store. CertStore.Close(); #endregion }); MainButton.IsEnabled = !MainButton.IsEnabled; MessageBox.Show("All steps finished, now try ScpDriverInstaller again! Good luck :)", "Finished", MessageBoxButton.OK, MessageBoxImage.Information); Close(); }
private async void btnUninstall_Click(object sender, EventArgs e) { #region Pre-Uninstallation _saved = Cursor; Cursor = Cursors.WaitCursor; btnInstall.Enabled = false; btnUninstall.Enabled = false; btnExit.Enabled = false; _busDeviceConfigured = false; _busDriverConfigured = false; _ds3DriverConfigured = false; _bthDriverConfigured = false; _scpServiceConfigured = false; pbRunning.Style = ProgressBarStyle.Marquee; #endregion #region Uninstallation await Task.Run(() => { string devPath = string.Empty, instanceId = string.Empty; try { uint result = 0; bool rebootRequired = false; if (cbService.Checked) { IDictionary state = new Hashtable(); var service = new AssemblyInstaller(Directory.GetCurrentDirectory() + @"\ScpService.exe", null); state.Clear(); service.UseNewContext = true; if (Stop(Settings.Default.ScpServiceName)) { Logger(DifxLog.DIFXAPI_INFO, 0, Settings.Default.ScpServiceName + " Stopped."); } service.Uninstall(state); _scpServiceConfigured = true; } if (cbBluetooth.Checked) { DriverInstaller.UninstallBluetoothDongles(ref rebootRequired); _reboot |= rebootRequired; } if (cbDS3.Checked) { DriverInstaller.UninstallDualShock3Controllers(ref rebootRequired); _reboot |= rebootRequired; } if (cbDs4.Checked) { DriverInstaller.UninstallDualShock4Controllers(ref rebootRequired); _reboot |= rebootRequired; } if (cbBus.Checked && Devcon.Find(Settings.Default.Ds3BusClassGuid, ref devPath, ref instanceId)) { if (Devcon.Remove(Settings.Default.Ds3BusClassGuid, devPath, instanceId)) { Logger(DifxLog.DIFXAPI_SUCCESS, 0, "Virtual Bus Removed"); _busDeviceConfigured = true; _installer.Uninstall(Path.Combine(Settings.Default.InfFilePath, @"ScpVBus.inf"), DifxFlags.DRIVER_PACKAGE_DELETE_FILES, out rebootRequired); _reboot |= rebootRequired; } else { Logger(DifxLog.DIFXAPI_ERROR, 0, "Virtual Bus Removal Failure"); } } } catch (InstallException instex) { if (!(instex.InnerException is Win32Exception)) { Log.ErrorFormat("Error during uninstallation: {0}", instex); return; } switch (((Win32Exception)instex.InnerException).NativeErrorCode) { case 1060: // ERROR_SERVICE_DOES_NOT_EXIST Log.Warn("Service doesn't exist, maybe it was uninstalled before"); break; default: Log.ErrorFormat("Win32-Error during uninstallation: {0}", (Win32Exception)instex.InnerException); break; } } catch (Exception ex) { Log.ErrorFormat("Error during uninstallation: {0}", ex); } }); #endregion #region Post-Uninstallation pbRunning.Style = ProgressBarStyle.Continuous; btnInstall.Enabled = true; btnUninstall.Enabled = true; btnExit.Enabled = true; Cursor = _saved; Log.Info("Uninstall Succeeded."); if (_reboot) { Log.Info(" [Reboot Required]"); } Log.Info("-- Uninstall Summary --"); if (_scpServiceConfigured) { Log.Info("SCP DS3 Service uninstalled"); } if (_busDeviceConfigured) { Log.Info("Bus Device uninstalled"); } if (_busDriverConfigured) { Log.Info("Bus Driver uninstalled"); } if (_ds3DriverConfigured) { Log.Info("DS3 USB Driver uninstalled"); } if (_bthDriverConfigured) { Log.Info("Bluetooth Driver uninstalled"); } #endregion }
private async void btnInstall_Click(object sender, EventArgs e) { #region Pre-Installation _saved = Cursor; Cursor = Cursors.WaitCursor; btnInstall.Enabled = false; btnUninstall.Enabled = false; btnExit.Enabled = false; _busDeviceConfigured = false; _busDriverConfigured = false; _ds3DriverConfigured = false; _bthDriverConfigured = false; _scpServiceConfigured = false; pbRunning.Style = ProgressBarStyle.Marquee; #endregion #region Installation await Task.Run(() => { string devPath = string.Empty, instanceId = string.Empty; try { uint result = 0; bool rebootRequired; var flags = DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT; if (cbForce.Checked) { flags |= DifxFlags.DRIVER_PACKAGE_FORCE; } if (cbBus.Checked) { if (!Devcon.Find(Settings.Default.Ds3BusClassGuid, ref devPath, ref instanceId)) { if (Devcon.Create("System", new Guid("{4D36E97D-E325-11CE-BFC1-08002BE10318}"), "root\\ScpVBus\0\0")) { Logger(DifxLog.DIFXAPI_SUCCESS, 0, "Virtual Bus Created"); _busDeviceConfigured = true; } } result = _installer.Install(Path.Combine(Settings.Default.InfFilePath, @"ScpVBus.inf"), flags, out rebootRequired); _reboot |= rebootRequired; if (result == 0) { _busDriverConfigured = true; } } if (cbBluetooth.Checked) { result = DriverInstaller.InstallBluetoothDongles(Handle); if (result > 0) { _bthDriverConfigured = true; } } if (cbDS3.Checked) { result = DriverInstaller.InstallDualShock3Controllers(Handle); if (result > 0) { _ds3DriverConfigured = true; } } if (cbDs4.Checked) { result = DriverInstaller.InstallDualShock4Controllers(Handle); if (result > 0) { _ds4DriverConfigured = true; } } if (cbService.Checked) { IDictionary state = new Hashtable(); var service = new AssemblyInstaller(Directory.GetCurrentDirectory() + @"\ScpService.exe", null); state.Clear(); service.UseNewContext = true; service.Install(state); service.Commit(state); if (Start(Settings.Default.ScpServiceName)) { Logger(DifxLog.DIFXAPI_INFO, 0, Settings.Default.ScpServiceName + " Started."); } else { _reboot = true; } _scpServiceConfigured = true; } } catch (Win32Exception w32Ex) { switch (w32Ex.NativeErrorCode) { case 1073: // ERROR_SERVICE_EXISTS Log.WarnFormat("Service already exists, skipping installation..."); break; default: Log.ErrorFormat("Win32-Error during installation: {0}", w32Ex); break; } } catch (Exception ex) { Log.ErrorFormat("Error during installation: {0}", ex); } }); #endregion #region Post-Installation pbRunning.Style = ProgressBarStyle.Continuous; btnInstall.Enabled = true; btnUninstall.Enabled = true; btnExit.Enabled = true; Cursor = _saved; Log.Info("Install Succeeded."); if (_reboot) { Log.InfoFormat("[Reboot Required]"); } Log.Info("-- Install Summary --"); if (_scpServiceConfigured) { Log.Info("SCP DS3 Service installed"); } if (_busDeviceConfigured) { Log.Info("Bus Device installed"); } if (_busDriverConfigured) { Log.Info("Bus Driver installed"); } if (_ds3DriverConfigured) { Log.Info("DS3 USB Driver installed"); } if (_bthDriverConfigured) { Log.Info("Bluetooth Driver installed"); } if (_ds4DriverConfigured) { Log.Info("DS4 USB Driver installed"); } #endregion }
public MainMenu() { MenuParameters.CreateForms(); IPConfigLog log = new IPConfigLog(); ClassCreateUser user = new ClassCreateUser(); NetBIOSChange zmiana = new NetBIOSChange(); NetBIOSChange domena = new NetBIOSChange(); AddCert cert = new AddCert(); DriverInstaller driver = new DriverInstaller(); SecurityPolicy policy = new SecurityPolicy(); Console.Title = "Log KWP Serwis Installer"; MessageBox.Show("Witaj w programie Instalacyjnym KWP Serwis Installer v0.9\nUpewnij się że komputer " + "jest podłączony do sieci oraz posiada skonfigurowany \nSerwisowy adres IP, by zainstalować wymaganie oprogramowanie. " + "W przypadku podłączenia komputera do domeny, miej ustawiony dynamiczny adres IP", "Powitanie"); MessageBox.Show(Program.Copyright(), "Copyright"); DialogResult connection = MessageBox.Show("Czy chcesz uruchomic program w trybie autonomicznym? (Offline Mode)", "Uwaga", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (connection == DialogResult.Yes) { LocalParameters.netconnection = false; } else if (connection == DialogResult.No) { LocalParameters.netconnection = true; } Installer install = new Installer(LocalParameters.netconnection); // Nazwa tytułu aplikacji this.Text = "KWP Serwis Installer v0.9"; this.Size = new Size(760, 560); this.Icon = new Icon(Environment.CurrentDirectory + @"\policja_lubuska_4lg_icon.ico"); // Załadowanie i wyskalowanie obrazka na stronę tytułową Image titleImage = Image.FromFile(Environment.CurrentDirectory + @"\Logo\obrazek.jpg"); MenuParameters.mainLabel.Left = 120; MenuParameters.mainLabel.Size = new Size(600, 400); MenuParameters.mainLabel.Image = titleImage; //Metody wywołujące.. void ButtonLotusOKClick(object sender, EventArgs ea) { install.LotusInstaller(MenuParameters.lotusList.SelectedIndex); MenuParameters.lotusInstallerMenu.Close(); } void ButtonEKDOKClick(object sender, EventArgs ea) { install.EKDAuthInstaller(MenuParameters.ekdList.SelectedIndex); MenuParameters.ekdInstallerMenu.Close(); } void ButtonOfficeOKClick(object sender, EventArgs ea) { install.OfficeInstaller(MenuParameters.officeList.SelectedIndex); MenuParameters.officeInstallerMenu.Close(); } void ButtonAdminClick(object sender, EventArgs ea) { user.option = 1; LocalParameters.username = MenuParameters.usernameTextbox.Text; LocalParameters.password = MenuParameters.passwordTextbox.Text; user.ShowUser(); MenuParameters.userCreationMenu.Close(); } void ButtonUserClick(object sender, EventArgs ea) { user.option = 2; LocalParameters.username = MenuParameters.usernameTextbox.Text; LocalParameters.password = MenuParameters.passwordTextbox.Text; user.ShowUser(); MenuParameters.userCreationMenu.Close(); } void ButtonIpLogClick(object sender, EventArgs ea) { log.option = 1; LocalParameters.inventoryNumber = MenuParameters.inventoryTextbox.Text; log.GenerateIPConfigLog(); MenuParameters.ipConfigMenu.Close(); } void ButtonChangeDomainClick(object sender, EventArgs ea) { LocalParameters.netBIOSname = MenuParameters.netbiosNameTextbox.Text; zmiana.ChangeNetBIOS(); MenuParameters.domainMenu.Close(); } void ButtonInternetClick(object sender, EventArgs ea) { install.ShitRemover(); Console.WriteLine("Trwa instalacja oprogramowania dla komputera w sieci Internet."); MenuParameters.lotusInstallerMenu.ShowDialog(); MenuParameters.officeInstallerMenu.ShowDialog(); install.InternetInstaller(); DialogResult dialogUser = MessageBox.Show("Czy chcesz utworzyć nowe konto lokalne na komputerze?", "Kreator Konta Użytkownika", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogUser == DialogResult.Yes) { MenuParameters.userCreationMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie tworzenia konta.", "Uwaga"); } DialogResult dialogPolicy = MessageBox.Show("Czy chcesz wgrać poliykę bezpieczeństwa na komputerze?", "Polityka Bezpieczeństwa KWP", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dialogPolicy == DialogResult.Yes) { policy.ApplySecurityPolicy(); } else { MessageBox.Show("Wybrałeś opcję nie instalowania polityki KWP.", "Uwaga"); } DialogResult dIpconfig = MessageBox.Show("Czy chcesz wygenerować loga funkcji ipconfig, Który zostanie zapisany w folderze /LOGI lokacji instalacyjnej programu?", "Ipconfig Log Generator", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dIpconfig == DialogResult.Yes) { MenuParameters.ipConfigMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie tworzenia loga.", "Uwaga"); } DialogResult dNetbios = MessageBox.Show("Czy chcesz dołączyć do domeny? Wybierz Tak, aby dołączyć. Nie aby zmienić tylko nazwę NetBIOS. Anuluj aby pominąć.", "Domain&NetBIOS connector", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dNetbios == DialogResult.Yes) { MenuParameters.domainMenu.ShowDialog(); domena.JoinDomain(); } else if (dNetbios == DialogResult.No) { MenuParameters.domainMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie zmieniania nazwy.", "Uwaga"); } DialogResult dRestart = MessageBox.Show("Czy chcesz uruchomić komputer ponownie, aby zapisać zmiany?", "Restart", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dRestart == DialogResult.Yes) { Program.Thanks(); Process.Start("shutdown", "/r /f /t 0"); Close(); } else if (dRestart == DialogResult.No) { Program.Thanks(); Close(); } } void ButtonPSTDClick(object sender, EventArgs ea) { install.ShitRemover(); Console.WriteLine("Trwa instalacja oprogramowania dla komputera w sieci PSTD."); MenuParameters.lotusInstallerMenu.ShowDialog(); MenuParameters.officeInstallerMenu.ShowDialog(); install.PSTDInstaller(); cert.InstallInfrastrukturaCert("infrastruktura2019.der"); driver.InstallDriver(); MenuParameters.ekdInstallerMenu.ShowDialog(); DialogResult dialogUser = MessageBox.Show("Czy chcesz utworzyć nowe konto lokalne na komputerze?", "Kreator Konta Użytkownika", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogUser == DialogResult.Yes) { MenuParameters.userCreationMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie tworzenia konta.", "Uwaga"); } DialogResult dIpconfig = MessageBox.Show("Czy chcesz wygenerować loga funkcji ipconfig, Który zostanie zapisany w folderze /LOGI lokacji instalacyjnej programu?", "Ipconfig Log Generator", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dIpconfig == DialogResult.Yes) { MenuParameters.ipConfigMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie tworzenia loga.", "Uwaga"); } DialogResult dNetbios = MessageBox.Show("Czy chcesz zmienić nazwę komputera? Wybierz Tak, aby dokonać zmiany. Nie aby zakończyć.", "Domain&NetBIOS connector", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dNetbios == DialogResult.Yes) { MenuParameters.domainMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie zmieniania nazwy.", "Uwaga"); } DialogResult dRestart = MessageBox.Show("Czy chcesz uruchomić komputer ponownie, aby zapisać zmiany?", "Restart", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dRestart == DialogResult.Yes) { Program.Thanks(); Process.Start("shutdown", "/r /f /t 0"); Close(); } else if (dRestart == DialogResult.No) { Program.Thanks(); Close(); } } void ButtonCWIClick(object sender, EventArgs ea) { install.ShitRemover(); MenuParameters.lotusInstallerMenu.ShowDialog(); MenuParameters.officeInstallerMenu.ShowDialog(); install.CWIInstaller(); cert.InstallCWICert("CWI_CERT.cer"); DialogResult dialogUser = MessageBox.Show("Czy chcesz utworzyć nowe konto lokalne na komputerze?", "Kreator Konta Użytkownika", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogUser == DialogResult.Yes) { MenuParameters.userCreationMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie tworzenia konta.", "Uwaga"); } DialogResult dIpconfig = MessageBox.Show("Czy chcesz wygenerować loga funkcji ipconfig, Który zostanie zapisany w folderze /LOGI lokacji instalacyjnej programu?", "Ipconfig Log Generator", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dIpconfig == DialogResult.Yes) { MenuParameters.ipConfigMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie tworzenia konta.", "Uwaga"); } DialogResult dNetbios = MessageBox.Show("Czy chcesz zmienić nazwę komputera? Wybierz Tak, aby dokonać zmiany. Nie aby zakończyć.", "Domain&NetBIOS connector", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dNetbios == DialogResult.Yes) { MenuParameters.domainMenu.ShowDialog(); } else { MessageBox.Show("Wybrałeś opcje nie zmieniania nazwy.", "Uwaga"); } DialogResult dRestart = MessageBox.Show("Czy chcesz uruchomić komputer ponownie, aby zapisać zmiany?", "Restart", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dRestart == DialogResult.Yes) { Program.Thanks(); Process.Start("shutdown", "/r /f /t 0"); Close(); } else if (dRestart == DialogResult.No) { Program.Thanks(); Close(); } } void ButtonCloseClick(object sender, EventArgs ea) { Application.Exit(); } void ButtonFAQClick(object sender, EventArgs ea) { MenuParameters.faqMenu.ShowDialog(); } void ButtonCancelClick(object sender, EventArgs ea) { MenuParameters.lotusInstallerMenu.Close(); } void ButtonCancelEKDClick(object sender, EventArgs ea) { MenuParameters.ekdInstallerMenu.Close(); } void ButtonCancelOfficeClick(object sender, EventArgs ea) { MenuParameters.officeInstallerMenu.Close(); } //Delegowanie metod do eventu przycisku myszy MenuParameters.buttonClose.Click += new EventHandler(ButtonCloseClick); MenuParameters.buttonFaq.Click += new EventHandler(ButtonFAQClick); MenuParameters.buttonInternet.Click += new EventHandler(ButtonInternetClick); MenuParameters.buttonPSTD.Click += new EventHandler(ButtonPSTDClick); MenuParameters.buttonCWI.Click += new EventHandler(ButtonCWIClick); MenuParameters.buttonCancel.Click += new EventHandler(ButtonCancelClick); MenuParameters.buttonCancelEKD.Click += new EventHandler(ButtonCancelEKDClick); MenuParameters.buttonCancelOffice.Click += new EventHandler(ButtonCancelOfficeClick); MenuParameters.buttonOKLotus.Click += new EventHandler(ButtonLotusOKClick); MenuParameters.buttonOKEKD.Click += new EventHandler(ButtonEKDOKClick); MenuParameters.buttonOKOffice.Click += new EventHandler(ButtonOfficeOKClick); MenuParameters.buttonAdmin.Click += new EventHandler(ButtonAdminClick); MenuParameters.buttonUser.Click += new EventHandler(ButtonUserClick); MenuParameters.buttonIpLog.Click += new EventHandler(ButtonIpLogClick); MenuParameters.buttonChangeNetbios.Click += new EventHandler(ButtonChangeDomainClick); // Dopisanie elementów statycznych do forms Controls.Add(MenuParameters.mainLabel); Controls.Add(MenuParameters.buttonInternet); Controls.Add(MenuParameters.buttonPSTD); Controls.Add(MenuParameters.buttonCWI); Controls.Add(MenuParameters.buttonClose); Controls.Add(MenuParameters.buttonFaq); }