mirror of
https://github.com/theitaliandeveloper/Perfect11.git
synced 2025-12-06 09:02:03 +00:00
Theme fixes
This commit is contained in:
36
Perfect11/Form1.Designer.cs
generated
36
Perfect11/Form1.Designer.cs
generated
@@ -97,7 +97,7 @@
|
|||||||
this.pages.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.pages.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.pages.Location = new System.Drawing.Point(3, 28);
|
this.pages.Location = new System.Drawing.Point(3, 28);
|
||||||
this.pages.Name = "pages";
|
this.pages.Name = "pages";
|
||||||
this.pages.SelectedIndex = 0;
|
this.pages.SelectedIndex = 1;
|
||||||
this.pages.Size = new System.Drawing.Size(1323, 732);
|
this.pages.Size = new System.Drawing.Size(1323, 732);
|
||||||
this.pages.TabIndex = 1;
|
this.pages.TabIndex = 1;
|
||||||
this.pages.UseSelectable = true;
|
this.pages.UseSelectable = true;
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
this.welcomePage.Controls.Add(this.poisonLabel1);
|
this.welcomePage.Controls.Add(this.poisonLabel1);
|
||||||
this.welcomePage.HorizontalScrollbarBarColor = true;
|
this.welcomePage.HorizontalScrollbarBarColor = true;
|
||||||
this.welcomePage.HorizontalScrollbarHighlightOnWheel = false;
|
this.welcomePage.HorizontalScrollbarHighlightOnWheel = false;
|
||||||
this.welcomePage.HorizontalScrollbarSize = 6;
|
this.welcomePage.HorizontalScrollbarSize = 9;
|
||||||
this.welcomePage.Location = new System.Drawing.Point(4, 38);
|
this.welcomePage.Location = new System.Drawing.Point(4, 38);
|
||||||
this.welcomePage.Name = "welcomePage";
|
this.welcomePage.Name = "welcomePage";
|
||||||
this.welcomePage.Size = new System.Drawing.Size(1315, 690);
|
this.welcomePage.Size = new System.Drawing.Size(1315, 690);
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
this.welcomePage.Text = "Welcome";
|
this.welcomePage.Text = "Welcome";
|
||||||
this.welcomePage.VerticalScrollbarBarColor = true;
|
this.welcomePage.VerticalScrollbarBarColor = true;
|
||||||
this.welcomePage.VerticalScrollbarHighlightOnWheel = false;
|
this.welcomePage.VerticalScrollbarHighlightOnWheel = false;
|
||||||
this.welcomePage.VerticalScrollbarSize = 31;
|
this.welcomePage.VerticalScrollbarSize = 51;
|
||||||
//
|
//
|
||||||
// editionLabel
|
// editionLabel
|
||||||
//
|
//
|
||||||
@@ -128,9 +128,10 @@
|
|||||||
this.editionLabel.BackColor = System.Drawing.Color.Transparent;
|
this.editionLabel.BackColor = System.Drawing.Color.Transparent;
|
||||||
this.editionLabel.Location = new System.Drawing.Point(16, 656);
|
this.editionLabel.Location = new System.Drawing.Point(16, 656);
|
||||||
this.editionLabel.Name = "editionLabel";
|
this.editionLabel.Name = "editionLabel";
|
||||||
this.editionLabel.Size = new System.Drawing.Size(183, 20);
|
this.editionLabel.Size = new System.Drawing.Size(175, 19);
|
||||||
this.editionLabel.TabIndex = 4;
|
this.editionLabel.TabIndex = 4;
|
||||||
this.editionLabel.Text = "Perfect11 Community Edition";
|
this.editionLabel.Text = "Perfect11 Community Edition";
|
||||||
|
this.editionLabel.UseCustomBackColor = true;
|
||||||
//
|
//
|
||||||
// poisonLabel2
|
// poisonLabel2
|
||||||
//
|
//
|
||||||
@@ -138,11 +139,12 @@
|
|||||||
this.poisonLabel2.BackColor = System.Drawing.Color.Transparent;
|
this.poisonLabel2.BackColor = System.Drawing.Color.Transparent;
|
||||||
this.poisonLabel2.Location = new System.Drawing.Point(416, 379);
|
this.poisonLabel2.Location = new System.Drawing.Point(416, 379);
|
||||||
this.poisonLabel2.Name = "poisonLabel2";
|
this.poisonLabel2.Name = "poisonLabel2";
|
||||||
this.poisonLabel2.Size = new System.Drawing.Size(492, 40);
|
this.poisonLabel2.Size = new System.Drawing.Size(465, 38);
|
||||||
this.poisonLabel2.TabIndex = 3;
|
this.poisonLabel2.TabIndex = 3;
|
||||||
this.poisonLabel2.Text = "Perfect11 is a tool made by a guy who loves to optimize Windows.\r\nIt allows to in" +
|
this.poisonLabel2.Text = "Perfect11 is a tool made by a guy who loves to optimize Windows.\r\nIt allows to in" +
|
||||||
"stalls apps, remove bloatware, configure services and even more.";
|
"stalls apps, remove bloatware, configure services and even more.";
|
||||||
this.poisonLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.poisonLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.poisonLabel2.UseCustomBackColor = true;
|
||||||
//
|
//
|
||||||
// pictureBox1
|
// pictureBox1
|
||||||
//
|
//
|
||||||
@@ -165,6 +167,7 @@
|
|||||||
this.poisonLabel1.TabIndex = 2;
|
this.poisonLabel1.TabIndex = 2;
|
||||||
this.poisonLabel1.Text = "Welcome to Perfect11, the tool that makes Windows 11 almost perfect.";
|
this.poisonLabel1.Text = "Welcome to Perfect11, the tool that makes Windows 11 almost perfect.";
|
||||||
this.poisonLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.poisonLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.poisonLabel1.UseCustomBackColor = true;
|
||||||
//
|
//
|
||||||
// debloatPage
|
// debloatPage
|
||||||
//
|
//
|
||||||
@@ -180,7 +183,7 @@
|
|||||||
this.debloatPage.Controls.Add(this.LstUWP);
|
this.debloatPage.Controls.Add(this.LstUWP);
|
||||||
this.debloatPage.HorizontalScrollbarBarColor = true;
|
this.debloatPage.HorizontalScrollbarBarColor = true;
|
||||||
this.debloatPage.HorizontalScrollbarHighlightOnWheel = false;
|
this.debloatPage.HorizontalScrollbarHighlightOnWheel = false;
|
||||||
this.debloatPage.HorizontalScrollbarSize = 6;
|
this.debloatPage.HorizontalScrollbarSize = 9;
|
||||||
this.debloatPage.Location = new System.Drawing.Point(4, 38);
|
this.debloatPage.Location = new System.Drawing.Point(4, 38);
|
||||||
this.debloatPage.Name = "debloatPage";
|
this.debloatPage.Name = "debloatPage";
|
||||||
this.debloatPage.Size = new System.Drawing.Size(1315, 690);
|
this.debloatPage.Size = new System.Drawing.Size(1315, 690);
|
||||||
@@ -188,7 +191,7 @@
|
|||||||
this.debloatPage.Text = "Debloat";
|
this.debloatPage.Text = "Debloat";
|
||||||
this.debloatPage.VerticalScrollbarBarColor = true;
|
this.debloatPage.VerticalScrollbarBarColor = true;
|
||||||
this.debloatPage.VerticalScrollbarHighlightOnWheel = false;
|
this.debloatPage.VerticalScrollbarHighlightOnWheel = false;
|
||||||
this.debloatPage.VerticalScrollbarSize = 19;
|
this.debloatPage.VerticalScrollbarSize = 31;
|
||||||
//
|
//
|
||||||
// BtnRunUninstaller
|
// BtnRunUninstaller
|
||||||
//
|
//
|
||||||
@@ -226,7 +229,7 @@
|
|||||||
this.ChkShowUWPSystem.AutoSize = true;
|
this.ChkShowUWPSystem.AutoSize = true;
|
||||||
this.ChkShowUWPSystem.Location = new System.Drawing.Point(5, 650);
|
this.ChkShowUWPSystem.Location = new System.Drawing.Point(5, 650);
|
||||||
this.ChkShowUWPSystem.Name = "ChkShowUWPSystem";
|
this.ChkShowUWPSystem.Name = "ChkShowUWPSystem";
|
||||||
this.ChkShowUWPSystem.Size = new System.Drawing.Size(134, 17);
|
this.ChkShowUWPSystem.Size = new System.Drawing.Size(123, 15);
|
||||||
this.ChkShowUWPSystem.TabIndex = 8;
|
this.ChkShowUWPSystem.TabIndex = 8;
|
||||||
this.ChkShowUWPSystem.Text = "Show System Apps";
|
this.ChkShowUWPSystem.Text = "Show System Apps";
|
||||||
this.ChkShowUWPSystem.UseSelectable = true;
|
this.ChkShowUWPSystem.UseSelectable = true;
|
||||||
@@ -244,7 +247,10 @@
|
|||||||
this.LstUWPRemove.TabIndex = 7;
|
this.LstUWPRemove.TabIndex = 7;
|
||||||
this.LstUWPRemove.TileSize = new System.Drawing.Size(348, 20);
|
this.LstUWPRemove.TileSize = new System.Drawing.Size(348, 20);
|
||||||
this.LstUWPRemove.UseCompatibleStateImageBehavior = false;
|
this.LstUWPRemove.UseCompatibleStateImageBehavior = false;
|
||||||
|
this.LstUWPRemove.UseCustomBackColor = true;
|
||||||
|
this.LstUWPRemove.UseCustomForeColor = true;
|
||||||
this.LstUWPRemove.UseSelectable = true;
|
this.LstUWPRemove.UseSelectable = true;
|
||||||
|
this.LstUWPRemove.UseStyleColors = true;
|
||||||
this.LstUWPRemove.View = System.Windows.Forms.View.Tile;
|
this.LstUWPRemove.View = System.Windows.Forms.View.Tile;
|
||||||
//
|
//
|
||||||
// removeAllButton
|
// removeAllButton
|
||||||
@@ -300,11 +306,13 @@
|
|||||||
this.LstUWP.OwnerDraw = true;
|
this.LstUWP.OwnerDraw = true;
|
||||||
this.LstUWP.Size = new System.Drawing.Size(518, 579);
|
this.LstUWP.Size = new System.Drawing.Size(518, 579);
|
||||||
this.LstUWP.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
this.LstUWP.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||||
this.LstUWP.Style = ReaLTaiizor.Enum.Poison.ColorStyle.Black;
|
|
||||||
this.LstUWP.TabIndex = 2;
|
this.LstUWP.TabIndex = 2;
|
||||||
this.LstUWP.TileSize = new System.Drawing.Size(348, 20);
|
this.LstUWP.TileSize = new System.Drawing.Size(348, 20);
|
||||||
this.LstUWP.UseCompatibleStateImageBehavior = false;
|
this.LstUWP.UseCompatibleStateImageBehavior = false;
|
||||||
|
this.LstUWP.UseCustomBackColor = true;
|
||||||
|
this.LstUWP.UseCustomForeColor = true;
|
||||||
this.LstUWP.UseSelectable = true;
|
this.LstUWP.UseSelectable = true;
|
||||||
|
this.LstUWP.UseStyleColors = true;
|
||||||
this.LstUWP.View = System.Windows.Forms.View.Tile;
|
this.LstUWP.View = System.Windows.Forms.View.Tile;
|
||||||
//
|
//
|
||||||
// tweaksPage
|
// tweaksPage
|
||||||
@@ -313,7 +321,7 @@
|
|||||||
this.tweaksPage.Controls.Add(this.tweaksList);
|
this.tweaksPage.Controls.Add(this.tweaksList);
|
||||||
this.tweaksPage.HorizontalScrollbarBarColor = true;
|
this.tweaksPage.HorizontalScrollbarBarColor = true;
|
||||||
this.tweaksPage.HorizontalScrollbarHighlightOnWheel = false;
|
this.tweaksPage.HorizontalScrollbarHighlightOnWheel = false;
|
||||||
this.tweaksPage.HorizontalScrollbarSize = 6;
|
this.tweaksPage.HorizontalScrollbarSize = 9;
|
||||||
this.tweaksPage.Location = new System.Drawing.Point(4, 38);
|
this.tweaksPage.Location = new System.Drawing.Point(4, 38);
|
||||||
this.tweaksPage.Name = "tweaksPage";
|
this.tweaksPage.Name = "tweaksPage";
|
||||||
this.tweaksPage.Size = new System.Drawing.Size(1315, 690);
|
this.tweaksPage.Size = new System.Drawing.Size(1315, 690);
|
||||||
@@ -321,7 +329,7 @@
|
|||||||
this.tweaksPage.Text = "Tweak";
|
this.tweaksPage.Text = "Tweak";
|
||||||
this.tweaksPage.VerticalScrollbarBarColor = true;
|
this.tweaksPage.VerticalScrollbarBarColor = true;
|
||||||
this.tweaksPage.VerticalScrollbarHighlightOnWheel = false;
|
this.tweaksPage.VerticalScrollbarHighlightOnWheel = false;
|
||||||
this.tweaksPage.VerticalScrollbarSize = 7;
|
this.tweaksPage.VerticalScrollbarSize = 12;
|
||||||
//
|
//
|
||||||
// runTweaks
|
// runTweaks
|
||||||
//
|
//
|
||||||
@@ -336,6 +344,7 @@
|
|||||||
//
|
//
|
||||||
// tweaksList
|
// tweaksList
|
||||||
//
|
//
|
||||||
|
this.tweaksList.AllowSorting = true;
|
||||||
this.tweaksList.Font = new System.Drawing.Font("Segoe UI", 12F);
|
this.tweaksList.Font = new System.Drawing.Font("Segoe UI", 12F);
|
||||||
this.tweaksList.FullRowSelect = true;
|
this.tweaksList.FullRowSelect = true;
|
||||||
this.tweaksList.Location = new System.Drawing.Point(0, 0);
|
this.tweaksList.Location = new System.Drawing.Point(0, 0);
|
||||||
@@ -345,12 +354,15 @@
|
|||||||
this.tweaksList.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
this.tweaksList.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||||
this.tweaksList.TabIndex = 2;
|
this.tweaksList.TabIndex = 2;
|
||||||
this.tweaksList.UseCompatibleStateImageBehavior = false;
|
this.tweaksList.UseCompatibleStateImageBehavior = false;
|
||||||
|
this.tweaksList.UseCustomBackColor = true;
|
||||||
|
this.tweaksList.UseCustomForeColor = true;
|
||||||
this.tweaksList.UseSelectable = true;
|
this.tweaksList.UseSelectable = true;
|
||||||
|
this.tweaksList.UseStyleColors = true;
|
||||||
this.tweaksList.Resize += new System.EventHandler(this.tweaksList_Resize);
|
this.tweaksList.Resize += new System.EventHandler(this.tweaksList_Resize);
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(41)))), ((int)(((byte)(50)))));
|
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(41)))), ((int)(((byte)(50)))));
|
||||||
this.ClientSize = new System.Drawing.Size(1329, 788);
|
this.ClientSize = new System.Drawing.Size(1329, 788);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using ReaLTaiizor.Enum.Poison;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -50,6 +51,11 @@ namespace Perfect11
|
|||||||
tweaksList.Theme = ThemeStyle.Dark;
|
tweaksList.Theme = ThemeStyle.Dark;
|
||||||
runTweaks.Theme = ThemeStyle.Dark;
|
runTweaks.Theme = ThemeStyle.Dark;
|
||||||
editionLabel.Theme = ThemeStyle.Dark;
|
editionLabel.Theme = ThemeStyle.Dark;
|
||||||
|
LstUWP.BackColor = Color.FromArgb(17, 17, 17);
|
||||||
|
LstUWPRemove.BackColor = Color.FromArgb(17, 17, 17);
|
||||||
|
tweaksList.BackColor = Color.FromArgb(17, 17, 17);
|
||||||
|
poisonLabel1.ForeColor = Color.FromArgb(255, 255, 255);
|
||||||
|
poisonLabel2.ForeColor = Color.FromArgb(255, 255, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -73,6 +79,9 @@ namespace Perfect11
|
|||||||
tweaksList.Theme = ThemeStyle.Light;
|
tweaksList.Theme = ThemeStyle.Light;
|
||||||
runTweaks.Theme = ThemeStyle.Light;
|
runTweaks.Theme = ThemeStyle.Light;
|
||||||
editionLabel.Theme = ThemeStyle.Light;
|
editionLabel.Theme = ThemeStyle.Light;
|
||||||
|
LstUWP.BackColor = Color.FromArgb(255,255,255);
|
||||||
|
LstUWPRemove.BackColor = Color.FromArgb(255,255,255);
|
||||||
|
tweaksList.BackColor = Color.FromArgb(255,255,255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void Form1_Load(object sender, EventArgs e)
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
@@ -80,6 +89,16 @@ namespace Perfect11
|
|||||||
pages.SelectedTab = welcomePage; // Always start from the first tab
|
pages.SelectedTab = welcomePage; // Always start from the first tab
|
||||||
editionLabel.Text = AppEdition;
|
editionLabel.Text = AppEdition;
|
||||||
theme.Text = AppEdition;
|
theme.Text = AppEdition;
|
||||||
|
LstUWP.View = View.Details;
|
||||||
|
LstUWP.Columns.Clear();
|
||||||
|
LstUWP.Columns.Add("App Name", -2, HorizontalAlignment.Left);
|
||||||
|
LstUWPRemove.View = View.Details;
|
||||||
|
LstUWPRemove.Columns.Clear();
|
||||||
|
LstUWPRemove.Columns.Add("App Name", -2, HorizontalAlignment.Left);
|
||||||
|
int totalWidth1 = LstUWP.ClientSize.Width;
|
||||||
|
int totalWidth2 = LstUWPRemove.ClientSize.Width;
|
||||||
|
LstUWP.Columns[0].Width = totalWidth1;
|
||||||
|
LstUWPRemove.Columns[0].Width = totalWidth2;
|
||||||
}
|
}
|
||||||
private void GetUWP()
|
private void GetUWP()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,15 +40,8 @@ Microsoft.Windows.XGpuEjectDialog
|
|||||||
Windows.CBSPreview
|
Windows.CBSPreview
|
||||||
windows.immersivecontrolpanel
|
windows.immersivecontrolpanel
|
||||||
Windows.PrintDialog
|
Windows.PrintDialog
|
||||||
Microsoft.WindowsAppRuntime.1.3
|
Microsoft.WindowsAppRuntime
|
||||||
Microsoft.WindowsAppRuntime.1.5
|
Microsoft.UI.Xaml
|
||||||
Microsoft.WindowsAppRuntime.1.6
|
|
||||||
Microsoft.WindowsAppRuntime.1.7
|
|
||||||
Microsoft.WindowsAppRuntime.1.8
|
|
||||||
Microsoft.WindowsAppRuntime.CBS
|
|
||||||
Microsoft.WindowsAppRuntime.CBS.1.6
|
|
||||||
Microsoft.UI.Xaml.2.8
|
|
||||||
Microsoft.UI.Xaml.CBS
|
|
||||||
Microsoft.StorePurchaseApp
|
Microsoft.StorePurchaseApp
|
||||||
Microsoft.Windows.StartMenuExperienceHost
|
Microsoft.Windows.StartMenuExperienceHost
|
||||||
Microsoft.Windows.PrintQueueActionCenter
|
Microsoft.Windows.PrintQueueActionCenter
|
||||||
@@ -57,16 +50,13 @@ Microsoft.DesktopAppInstaller
|
|||||||
Microsoft.SecHealthUI
|
Microsoft.SecHealthUI
|
||||||
Microsoft.StartExperiencesApp
|
Microsoft.StartExperiencesApp
|
||||||
Microsoft.Windows.AugLoop.CBS
|
Microsoft.Windows.AugLoop.CBS
|
||||||
MicrosoftWindows.Client.AIX
|
MicrosoftWindows.Client
|
||||||
MicrosoftWindows.Client.CBS
|
|
||||||
MicrosoftWindows.Client.Core
|
|
||||||
MicrosoftWindows.Client.FileExp
|
|
||||||
MicrosoftWindows.Client.OOBE
|
|
||||||
MicrosoftWindows.Client.Photon
|
|
||||||
MicrosoftWindows.Client.WebExperience
|
|
||||||
MicrosoftWindows.CrossDevice
|
MicrosoftWindows.CrossDevice
|
||||||
MicrosoftWindows.UndockedDevKit
|
MicrosoftWindows.UndockedDevKit
|
||||||
Microsoft.LanguageExperiencePack
|
Microsoft.LanguageExperiencePack
|
||||||
Microsoft.XboxIdentityProvider
|
Microsoft.XboxIdentityProvider
|
||||||
Microsoft.Xbox.TCUI
|
Microsoft.Xbox.TCUI
|
||||||
Microsoft.Edge.GameAssist
|
Microsoft.Edge.GameAssist
|
||||||
|
Microsoft.Ink.Handwriting
|
||||||
|
Kaspersky.ShellEx
|
||||||
|
Microsoft.DirectXRuntime
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
<ProjectReference Include="..\..\Perfect11.TweaksInterface\Perfect11.TweaksInterface.csproj">
|
<ProjectReference Include="..\..\Perfect11.TweaksInterface\Perfect11.TweaksInterface.csproj">
|
||||||
<Project>{b3f8761a-b4b2-4378-9fe8-06bbfc39fce6}</Project>
|
<Project>{b3f8761a-b4b2-4378-9fe8-06bbfc39fce6}</Project>
|
||||||
<Name>Perfect11.TweaksInterface</Name>
|
<Name>Perfect11.TweaksInterface</Name>
|
||||||
|
<Private>False</Private>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|||||||
@@ -17,70 +17,70 @@ namespace Perfect11.Inbox.ManageTelemetry
|
|||||||
{
|
{
|
||||||
void ControlService(string serviceName, string action)
|
void ControlService(string serviceName, string action)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
|
||||||
using (ServiceController sc = new ServiceController(serviceName))
|
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Service '{serviceName}' current status: {sc.Status}");
|
using (ServiceController sc = new ServiceController(serviceName))
|
||||||
|
|
||||||
switch (action.ToLower())
|
|
||||||
{
|
{
|
||||||
case "start":
|
Console.WriteLine($"Service '{serviceName}' current status: {sc.Status}");
|
||||||
if (sc.Status == ServiceControllerStatus.Stopped)
|
|
||||||
{
|
|
||||||
sc.Start();
|
|
||||||
sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10));
|
|
||||||
Console.WriteLine("Service started successfully.");
|
|
||||||
}
|
|
||||||
else Console.WriteLine("Service is already running.");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "stop":
|
switch (action.ToLower())
|
||||||
if (sc.Status == ServiceControllerStatus.Running)
|
{
|
||||||
{
|
case "start":
|
||||||
sc.Stop();
|
if (sc.Status == ServiceControllerStatus.Stopped)
|
||||||
sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
|
{
|
||||||
Console.WriteLine("Service stopped successfully.");
|
sc.Start();
|
||||||
}
|
sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10));
|
||||||
else Console.WriteLine("Service is not running.");
|
Console.WriteLine("Service started successfully.");
|
||||||
break;
|
}
|
||||||
|
else Console.WriteLine("Service is already running.");
|
||||||
|
break;
|
||||||
|
|
||||||
case "restart":
|
case "stop":
|
||||||
if (sc.Status == ServiceControllerStatus.Running)
|
if (sc.Status == ServiceControllerStatus.Running)
|
||||||
{
|
{
|
||||||
sc.Stop();
|
sc.Stop();
|
||||||
sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
|
sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
|
||||||
sc.Start();
|
Console.WriteLine("Service stopped successfully.");
|
||||||
sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10));
|
}
|
||||||
Console.WriteLine("Service restarted successfully.");
|
else Console.WriteLine("Service is not running.");
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
|
||||||
sc.Start();
|
|
||||||
sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10));
|
|
||||||
Console.WriteLine("Service started successfully.");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
case "restart":
|
||||||
Console.WriteLine("Invalid action. Use start | stop | restart");
|
if (sc.Status == ServiceControllerStatus.Running)
|
||||||
break;
|
{
|
||||||
|
sc.Stop();
|
||||||
|
sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
|
||||||
|
sc.Start();
|
||||||
|
sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10));
|
||||||
|
Console.WriteLine("Service restarted successfully.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sc.Start();
|
||||||
|
sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10));
|
||||||
|
Console.WriteLine("Service started successfully.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Invalid action. Use start | stop | restart");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
throw new Exception($"Service '{serviceName}' not found or cannot be controlled: {ex.Message}");
|
||||||
|
}
|
||||||
|
catch (System.ServiceProcess.TimeoutException)
|
||||||
|
{
|
||||||
|
throw new Exception("Operation timed out.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception(ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException ex)
|
|
||||||
{
|
|
||||||
throw new Exception($"Service '{serviceName}' not found or cannot be controlled: {ex.Message}");
|
|
||||||
}
|
|
||||||
catch (System.ServiceProcess.TimeoutException)
|
|
||||||
{
|
|
||||||
throw new Exception("Operation timed out.");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new Exception(ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void SetServiceStartupType(string serviceName, string startupType)
|
void SetServiceStartupType(string serviceName, string startupType)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user