Skip to content

Commit f332a67

Browse files
committed
v1.0
1 parent f6a5956 commit f332a67

4 files changed

Lines changed: 152 additions & 112 deletions

File tree

DisableSearchBoxSuggestions/DisableSearchBoxSuggestions.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@
3232
<ErrorReport>prompt</ErrorReport>
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
35+
<PropertyGroup />
3536
<PropertyGroup>
36-
<ApplicationManifest>app1.manifest</ApplicationManifest>
37+
<ApplicationIcon>Win.ico</ApplicationIcon>
3738
</PropertyGroup>
3839
<PropertyGroup>
39-
<ApplicationIcon>Win.ico</ApplicationIcon>
40+
<ApplicationManifest>app.manifest</ApplicationManifest>
4041
</PropertyGroup>
4142
<ItemGroup>
4243
<Reference Include="System" />
@@ -55,7 +56,6 @@
5556
<ItemGroup>
5657
<None Include="App.config" />
5758
<None Include="app.manifest" />
58-
<None Include="app1.manifest" />
5959
</ItemGroup>
6060
<ItemGroup>
6161
<Content Include="Win.ico" />

DisableSearchBoxSuggestions/Program.cs

Lines changed: 147 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Security.Principal;
4+
using System.Threading;
5+
using Microsoft.Win32;
36

47
namespace DisableSearchBoxSuggestions
58
{
@@ -29,9 +32,18 @@ Disable Search Box Suggestions
2932
by KilLo
3033
github.com/KilLo445";
3134

35+
public static bool ExplorerRunning = true;
36+
37+
public static bool IsAdministrator()
38+
{
39+
var identity = WindowsIdentity.GetCurrent();
40+
var principal = new WindowsPrincipal(identity);
41+
return principal.IsInRole(WindowsBuiltInRole.Administrator);
42+
}
43+
3244
static void Main(string[] args)
3345
{
34-
Console.Title = "Disable Search Box Suggestions";
46+
Console.Title = "Disable Search Box Suggestions by KilLo";
3547

3648
Console.WriteLine(asciiArt);
3749
Console.WriteLine();
@@ -41,17 +53,145 @@ static void Main(string[] args)
4153
Console.WriteLine();
4254
Console.WriteLine("[1] Disable Search Box Suggestions");
4355
Console.WriteLine("[2] Enable Search Box Suggestions");
44-
Console.WriteLine("[3] Open DSBS GitHub");
56+
Console.WriteLine("[3] About DSBS");
57+
Console.WriteLine("[4] Open DSBS GitHub");
4558
Console.WriteLine();
4659
Console.Write("Enter choice: ");
4760
string userInput = Console.ReadLine();
4861
Console.WriteLine();
49-
if (userInput == "1") { }
50-
if (userInput == "2") { }
51-
if (userInput == "3") { Console.WriteLine("Opening GitHub link..."); Process.Start(githubLink); }
62+
Console.WriteLine("--------------------------------------------------");
63+
Console.WriteLine();
64+
if (userInput == "1") { DSBS(); PressAnyKeyToExit(); }
65+
if (userInput == "2") { ESBS(); PressAnyKeyToExit(); }
66+
if (userInput == "3") { AboutDSBS(); PressAnyKeyToExit(); }
67+
if (userInput == "4") { Console.WriteLine("Opening GitHub link..."); Process.Start(githubLink); }
68+
if (userInput != "1" || userInput != "2" || userInput != "3" || userInput != "4") { Console.WriteLine("Unknown command..."); PressAnyKeyToExit(); }
69+
PressAnyKeyToExit();
70+
}
71+
72+
public static void DSBS()
73+
{
74+
Console.WriteLine("Checking for permission...");
75+
Thread.Sleep(100);
76+
if (IsAdministrator()) { Console.WriteLine("Permission granted!"); }
77+
else { Console.WriteLine("No permission, please run as administrator and try again!"); PressAnyKeyToExit(); }
78+
Thread.Sleep(100);
79+
Console.WriteLine();
80+
Console.WriteLine("Checking for registry key HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer...");
81+
Thread.Sleep(100);
82+
RegistryKey keyExp = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Policies\Microsoft\Windows\Explorer", true);
83+
if (keyExp == null)
84+
{
85+
Console.WriteLine("Key does not exist! Creating it...");
86+
Thread.Sleep(100);
87+
try
88+
{
89+
RegistryKey keyWin = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Microsoft\Windows\Explorer");
90+
Console.WriteLine("Key created! Closing registry...");
91+
keyWin.Close();
92+
}
93+
catch (Exception e) { ExceptionMSG(e); }
94+
}
95+
else { Console.WriteLine("Key found!"); }
96+
try
97+
{
98+
Thread.Sleep(100);
99+
Console.WriteLine("Creating DWORD value DisableSearchBoxSuggestions...");
100+
keyExp.SetValue("DisableSearchBoxSuggestions", "1", RegistryValueKind.DWord);
101+
Thread.Sleep(100);
102+
Console.WriteLine("Value created!");
103+
}
104+
catch (Exception e) { ExceptionMSG(e); }
105+
Thread.Sleep(100);
106+
Console.WriteLine("Closing registry...");
107+
keyExp.Close();
108+
Thread.Sleep(100);
109+
RestartExplorer();
110+
return;
111+
}
112+
113+
public static void ESBS()
114+
{
115+
Console.WriteLine("Checking for permission...");
116+
Thread.Sleep(100);
117+
if (IsAdministrator()) { Console.WriteLine("Permission granted!"); }
118+
else { Console.WriteLine("No permission, please run as administrator and try again!"); PressAnyKeyToExit(); }
119+
Console.WriteLine();
120+
Thread.Sleep(100);
121+
Console.WriteLine("Checking for registry key HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer...");
122+
RegistryKey keyExp = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Policies\Microsoft\Windows\Explorer", true);
123+
if (keyExp == null) { Console.WriteLine("Search box suggestions are not enabled."); }
124+
else { Console.WriteLine("Key found!"); }
125+
try
126+
{
127+
Thread.Sleep(100);
128+
if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer", "DisableSearchBoxSuggestions", null) == null) { Console.WriteLine("Search box suggestions are not enabled."); }
129+
else
130+
{
131+
Console.WriteLine("Deleting DWORD value DisableSearchBoxSuggestions...");
132+
keyExp.DeleteValue("DisableSearchBoxSuggestions");
133+
Thread.Sleep(100);
134+
Console.WriteLine("Value deleted!");
135+
}
136+
}
137+
catch (Exception e) { ExceptionMSG(e); }
138+
Thread.Sleep(100);
139+
Console.WriteLine("Closing registry...");
140+
keyExp.Close();
141+
Thread.Sleep(100);
142+
RestartExplorer();
143+
return;
144+
}
145+
146+
public static void RestartExplorer()
147+
{
148+
Console.WriteLine("Restarting explorer...");
149+
if (Process.GetProcessesByName("explorer").Length > 0)
150+
{
151+
ExplorerRunning = true;
152+
try
153+
{
154+
Process[] explorer = Process.GetProcessesByName("explorer");
155+
foreach (Process process in explorer) { process.Kill(); ExplorerRunning = false; }
156+
}
157+
catch (Exception e) { ExceptionMSG(e); }
158+
}
159+
Thread.Sleep(500);
160+
if (Process.GetProcessesByName("explorer").Length < 0)
161+
{
162+
try
163+
{
164+
Process.Start("explorer");
165+
}
166+
catch (Exception e) { ExceptionMSG(e); }
167+
}
168+
while (!ExplorerRunning)
169+
{
170+
Console.WriteLine("Waiting for explorer...");
171+
if (Process.GetProcessesByName("explorer").Length > 0) { ExplorerRunning = true; }
172+
else { ExplorerRunning = false; }
173+
Thread.Sleep(500);
174+
}
175+
Thread.Sleep(100);
176+
if (ExplorerRunning) { Console.WriteLine("Explorer running!"); }
177+
return;
178+
}
179+
180+
public static void AboutDSBS() { Console.WriteLine("DisableSearchBoxSuggestions, or DSBS is a simple tool created by KilLo (github.com/KilLo445) that disables the annoying web-searches and Copilot in the Windows 11 Start Menu, allowing you to only search for files and run commands."); }
181+
182+
public static void ExceptionMSG(Exception ex)
183+
{
184+
Console.WriteLine();
185+
Console.WriteLine("An error occured...");
186+
Console.WriteLine($"{ex}");
187+
PressAnyKeyToExit();
188+
}
189+
190+
public static void PressAnyKeyToExit()
191+
{
52192
Console.WriteLine();
53-
Console.WriteLine("Press any key to exit...");
54-
Console.ReadLine();
193+
Console.Write("Press any key to exit...");
194+
Console.ReadKey();
55195
Environment.Exit(0);
56196
}
57197
}

DisableSearchBoxSuggestions/app.manifest

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,17 @@
44
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
55
<security>
66
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7-
<!--<requestedexecutionlevel level="highestavailable" uiaccess="false" />-->
8-
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
7+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
98
</requestedPrivileges>
109
</security>
1110
</trustInfo>
1211

1312
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
1413
<application>
15-
16-
<!-- Windows 10 -->
14+
<!-- Windows 10 -->
1715
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
18-
1916
</application>
2017
</compatibility>
21-
22-
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
23-
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
24-
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
25-
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
26-
27-
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
28-
<!--
29-
<application xmlns="urn:schemas-microsoft-com:asm.v3">
30-
<windowsSettings>
31-
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
32-
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
33-
</windowsSettings>
34-
</application>
35-
-->
36-
37-
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
3818
<dependency>
3919
<dependentAssembly>
4020
<assemblyIdentity
@@ -47,5 +27,4 @@
4727
/>
4828
</dependentAssembly>
4929
</dependency>
50-
5130
</assembly>

DisableSearchBoxSuggestions/app1.manifest

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)