Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
svenmauch committed Nov 13, 2019
1 parent ba55ef2 commit a0afac6
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 136 deletions.
6 changes: 3 additions & 3 deletions WinSlap/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>
19 changes: 11 additions & 8 deletions WinSlap/HardwareInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ public static String GetProcessorId()
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
String id = String.Empty;
foreach (ManagementObject mo in moc)
foreach (var o in moc)
{
var mo = (ManagementObject) o;

id = mo.Properties["processorID"].Value.ToString();
break;
Expand All @@ -25,8 +26,9 @@ public static String GetHddSerialNo()
ManagementClass mangnmt = new ManagementClass("Win32_LogicalDisk");
ManagementObjectCollection mcol = mangnmt.GetInstances();
string result = "";
foreach (ManagementObject strt in mcol)
foreach (var o in mcol)
{
var strt = (ManagementObject) o;
result += Convert.ToString(strt["VolumeSerialNumber"]);
}
return result;
Expand All @@ -36,8 +38,9 @@ public static string GetMacAddress()
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
string macAddress = String.Empty;
foreach (ManagementObject mo in moc)
foreach (var o in moc)
{
var mo = (ManagementObject) o;
if (macAddress == String.Empty)
{
if ((bool)mo["IPEnabled"] == true) macAddress = mo["MacAddress"].ToString();
Expand All @@ -52,15 +55,15 @@ public static string GetBoardMaker()
{

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_BaseBoard");
foreach (ManagementObject wmi in searcher.Get())
foreach (var o in searcher.Get())
{
var wmi = (ManagementObject) o;
try
{
return wmi.GetPropertyValue("Manufacturer").ToString();
}

catch { }

}

return "Board Maker: Unknown";
Expand All @@ -71,16 +74,16 @@ public static string GetBoardModel()

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_BaseBoard");

foreach (ManagementObject wmi in searcher.Get())
foreach (var o in searcher.Get())
{
var wmi = (ManagementObject) o;
try
{
return wmi.GetPropertyValue("Product").ToString();

}

catch { }

catch {}
}

return "Product: Unknown";
Expand Down
122 changes: 52 additions & 70 deletions WinSlap/MainForm.Designer.cs

Large diffs are not rendered by default.

59 changes: 34 additions & 25 deletions WinSlap/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using System.IO;
using System.Linq;
using System.Windows.Forms;
using WinSlap.Properties;
// TODO: reimplement properly
// using WinSlap.Properties;

namespace WinSlap
{
Expand Down Expand Up @@ -60,7 +61,7 @@ private void Button1_Click(object sender, EventArgs e)

}

public void SlapTweaks(Slapping slapping)
private void SlapTweaks(Slapping slapping)
{
for (int x = 0; x <= checkedListBoxTweaks.CheckedItems.Count; x++)
{
Expand Down Expand Up @@ -325,21 +326,29 @@ public void SlapTweaks(Slapping slapping)
slapping.SetCurrentOp(boxcontent);
Slapper.UninstallXPSWriter();
break;
case "Disable security questions for local accounts":
slapping.SetCurrentOp(boxcontent);
Slapper.DisableSecurityQuestions();
break;
case "Disable app suggestions (e.g. use Edge instead of Firefox)":
slapping.SetCurrentOp(boxcontent);
Slapper.DisableAppSuggestions();
break;
default:
slapping.Hide();
MessageBox.Show("Error 002 in Tweaks (" + boxcontent + ")\nPlease report this bug to [email protected]", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Item not found (" + boxcontent + ")\nPlease report this issue at https://github.com/svenmauch/WinSlap", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
break;
}
}
}

catch (NullReferenceException)
{
slapping.Hide();
MessageBox.Show("Error 001 in \"" + boxcontent + "\"\nPlease report this bug to [email protected]", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
catch (NullReferenceException ex)
{
slapping.Hide();
MessageBox.Show("NullReferenceException in \"" + boxcontent + "\"\nPlease report this issue at https://github.com/svenmauch/WinSlap" + "\n\n" + ex, "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
}

private void SlapAppearance(Slapping slapping)
Expand Down Expand Up @@ -403,21 +412,25 @@ private void SlapAppearance(Slapping slapping)
slapping.SetCurrentOp(boxcontent);
Slapper.UseWin7Volume();
break;
case "Remove Microsoft Edge dekstop shortcut":
case "Remove Microsoft Edge desktop shortcut":
slapping.SetCurrentOp(boxcontent);
Slapper.RemoveEdgeShortcut();
break;
case "Disable Lockscreen Blur":
slapping.SetCurrentOp(boxcontent);
Slapper.DisableLockscreenBlur();
break;
default:
slapping.Hide();
MessageBox.Show("Error 002 in Appearance\nPlease report this bug to [email protected]", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Item not found in Appearance\nPlease report this issue at https://github.com/svenmauch/WinSlap", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
break;
}
}
catch (NullReferenceException)
{
slapping.Hide();
MessageBox.Show("Error 001 in \"" + boxcontent + "\"\nPlease report this bug to [email protected]", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("NullReferenceException in \"" + boxcontent + "\"\nPlease report this issue at https://github.com/svenmauch/WinSlap", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
Expand Down Expand Up @@ -470,15 +483,15 @@ private void SlapSoftware(Slapping slapping)
break;
default:
slapping.Hide();
MessageBox.Show("Error 002 in Software\nPlease report this bug to [email protected]", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Item not found in Software\nPlease report this issue at https://github.com/svenmauch/WinSlap", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
break;
}
}
catch (NullReferenceException)
{
slapping.Hide();
MessageBox.Show("Error 001 in \"" + boxcontent + "\"\nPlease report this bug to [email protected]", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("NullReferenceException in \"" + boxcontent + "\"\nPlease report this issue at https://github.com/svenmauch/WinSlap", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
Expand All @@ -503,15 +516,15 @@ private void SlapAdvanced(Slapping slapping)
break;
default:
slapping.Hide();
MessageBox.Show("Error 002 in Advanced\nPlease report this bug to [email protected]", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Item not found in Advanced\nPlease report this issue at https://github.com/svenmauch/WinSlap", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
break;
}
}
catch (NullReferenceException)
{
slapping.Hide();
MessageBox.Show("Error 001 in \"" + boxcontent + "\"\nPlease report this bug to [email protected]", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("NullReferenceException in \"" + boxcontent + "\"\nPlease report this issue at https://github.com/svenmauch/WinSlap", "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
Expand All @@ -524,7 +537,7 @@ private void WinSlap_Load(object sender, EventArgs e)
AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
Directory.CreateDirectory(Tmpfolder);

labelOS.Text = "Windows 10 (" + Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "").ToString() + ")";
labelOS.Text = "Windows 10 (" + Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "") + ")";
}

private static void RestartNow()
Expand All @@ -540,10 +553,12 @@ private static void RestartNow()

private static void SpendeAutorun()
{
/* TODO: reimplement properly
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\WinSlap\");
File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\WinSlap\" + "Spende.exe", Resources.Spende);
RegistryKey regStartUp = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce", true);
regStartUp.SetValue("WinSlap", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\WinSlap\" + "Spende.exe");
*/
}

private void OnProcessExit(object sender, EventArgs e)
Expand All @@ -569,8 +584,7 @@ private void InitParameterNotice()
private static Boolean ShowDisclaimer()
{
string disclaimer = "- All changes are made at your own risk.\n" +
"- Any potential damage is your own responsibility.\n" +
"- There is no easy way to restore the changes.\n" +
"- There is no easy way to revert the changes.\n" +
"- Your PC will restart immediately after the changes have been made.\n \n" +
"Are you ready to slap?";

Expand Down Expand Up @@ -611,11 +625,6 @@ private void ButtonUncheckAdvanced_Click(object sender, EventArgs e)
CheckAll(checkedListBoxAdvanced, false);
}

private void LabelWinSlap_DoubleClick(object sender, EventArgs e)
{
MessageBox.Show("WinSlap by Sven Mauch (2018)");
}

private void CheckAll(CheckedListBox list, bool check)
{
for (int i = 0; i < list.Items.Count; i++)
Expand Down
3 changes: 1 addition & 2 deletions WinSlap/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand All @@ -10,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WinSlap")]
[assembly: AssemblyCopyright("Copyright © Sven Mauch 2017")]
[assembly: AssemblyCopyright("Copyright © Sven Mauch 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
12 changes: 1 addition & 11 deletions WinSlap/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions WinSlap/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@
<data name="delapps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\delapps.ps1;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<!-- TODO: reimplement properly
<data name="Spende" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Spende.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
-->
<data name="preventpreinstallingapps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\preventpreinstallingapps.ps1;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
Expand Down
22 changes: 9 additions & 13 deletions WinSlap/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed WinSlap/Resources/Spende.exe
Binary file not shown.
22 changes: 21 additions & 1 deletion WinSlap/Slapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using WinSlap.Properties;
using System.Management.Automation;
using System.Text;
using System.Windows.Forms;

namespace WinSlap
{
Expand Down Expand Up @@ -155,6 +154,25 @@ public static void DisableWPAD()
myKey.SetValue("UseDomainNameDevolution", "0", RegistryValueKind.DWord);
}

public static void DisableLockscreenBlur()
{
RegistryKey myKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Policies\Microsoft\Windows\System", true);
myKey.SetValue("DisableAcrylicBackgroundOnLogon", "1", RegistryValueKind.DWord);
}

public static void DisableSecurityQuestions()
{
RegistryKey myKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Policies\Microsoft\Windows\System", true);
myKey.SetValue("NoLocalPasswordResetQuestions", "1", RegistryValueKind.DWord);
}

// note: "Anywhere" actually means disabled
public static void DisableAppSuggestions()
{
RegistryKey myKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer", true);
myKey.SetValue("AicEnabled", "Anywhere", RegistryValueKind.String);
}

public static void DisableGameDvr()
{
RegistryKey myKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR", true);
Expand All @@ -174,8 +192,10 @@ public static void DisableGameDvr()
RegistryKey myKey4 = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Microsoft\Windows", true);
myKey4.SetValue("AllowgameDVR", "0", RegistryValueKind.DWord);

/* TODO: doesn't work anymore as of 1909
RegistryKey myKey5 = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\xbgm", true);
myKey5.SetValue("Start", "4", RegistryValueKind.DWord);
*/

RegistryKey myKey6 = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\XblAuthManager", true);
myKey6.SetValue("Start", "4", RegistryValueKind.DWord);
Expand Down
Loading

0 comments on commit a0afac6

Please sign in to comment.