Skip to content

Commit

Permalink
Update and New functions
Browse files Browse the repository at this point in the history
Added network reset and stuff, also more regedit stuff. Won't be making a GUI edition because it is pointless.
  • Loading branch information
scrim-dev committed Jun 6, 2024
1 parent 64a9be0 commit 15b0c44
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 35 deletions.
1 change: 1 addition & 0 deletions VRC-Deep-Clean/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:VRC_Deep_Clean.Program.Main(System.String[])")]
[assembly: SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "<Pending>", Scope = "member", Target = "~M:VRC_Deep_Clean.Program.Main(System.String[])")]
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:VRC_Deep_Clean.Utils.CleanerUtils.RegDelete(System.String)")]
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>", Scope = "member", Target = "~M:VRC_Deep_Clean.Utils.CustomLog._Thread(System.Boolean)")]
22 changes: 6 additions & 16 deletions VRC-Deep-Clean/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ internal class Program
{
private static void Main(string[] args)
{
//Entry
Console.Title = string.Empty;
Console.OutputEncoding = Encoding.UTF8;
#pragma warning disable CS8622

AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
#pragma warning restore CS8622

Console.SetWindowSize(120, 35);

Expand All @@ -21,7 +21,7 @@ private static void Main(string[] args)
Batch.Create();

VRC.KillPotentialProcesses();
Thread.Sleep(3000);
Thread.Sleep(3500);

MainMenu: //Default jump
Console.Clear();
Expand All @@ -30,18 +30,11 @@ private static void Main(string[] args)
CustomLog.Msg("Welcome! Please select an option:");

CustomLog.Msg("↓↓↓\n\n[1] Delete and Clean up ALL of VRChat | [2] Delete, Uninstall, Clean ALL of VRChat and Reinstall | " +
"[3] Simple Reinstall");

/*
* CustomLog.Msg("↓↓↓\n\n[1] Delete and Clean up ALL of VRChat | [2] Delete, Uninstall, Clean ALL of VRChat and Reinstall | " +
"[3] Simple Reinstall | [4] Use GUI");
*/
"[3] Simple Reinstall | [4] Check for Updates");

try
{
#pragma warning disable CS8604
int selection = int.Parse(Console.ReadLine());
#pragma warning restore CS8604
switch (selection)
{
case 1:
Expand Down Expand Up @@ -103,9 +96,8 @@ private static void Main(string[] args)
Quit();
break;
case 4:
//Will do in a later update
Console.Clear();
Thread.Sleep(1);
//Swapped out the GUI edition cuz its kinda pointless
UpdateUtils.Check();
goto MainMenu;
default:
Console.Clear();
Expand All @@ -131,12 +123,10 @@ private static void Main(string[] args)
Quit();
}

//Better quit than just clicking X
private static void OnProcessExit(object sender, EventArgs e) { Quit(); }

private static void Quit()
{
CustomLog.SaveLogs();
CustomLog.SetWorkingTitle("Shutting down app...");
Console.Clear();
CustomLog.Warn("Goodbye! :D");
Expand Down
41 changes: 29 additions & 12 deletions VRC-Deep-Clean/Utils/Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ namespace VRC_Deep_Clean.Utils
{
internal class Batch
{
private static int VRCid { get; } = 0;
public static readonly string BatchFolder = Directory.GetCurrentDirectory() + "\\Bat";
public static readonly string StartVRCBatNoVR = BatchFolder + "\\StartVRC_NoVR.bat";
public static readonly string StartVRCBatVR = BatchFolder + "\\StartVRC_VR.bat";
public static readonly string InstallVRC = BatchFolder + "\\Install.bat";
public static readonly string UninstallVRC = BatchFolder + "\\Uninstall.bat";
public static readonly string OpenGH = BatchFolder + "\\GH.bat";

public static void Create()
{
Expand All @@ -30,61 +32,76 @@ public static void Create()
//novr
try
{
File.WriteAllText(StartVRCBatNoVR, "start steam://rungameid/438100 -novr");
File.WriteAllText(StartVRCBatNoVR, $"start steam://rungameid/{VRCid} -novr");

if(File.Exists(StartVRCBatNoVR))
{
CustomLog.Log("Batch file 1/4 created");
CustomLog.Log("Batch file 1/5 created");
}
}
catch
{
CustomLog.Error("Failed to write batch file 1/4");
CustomLog.Error("Failed to write batch file 1/5");
}

//vrmode
try
{
File.WriteAllText(StartVRCBatVR, "start steam://rungameid/438100 -vrmode");
File.WriteAllText(StartVRCBatVR, $"start steam://rungameid/{VRCid} -vrmode");

if (File.Exists(StartVRCBatVR))
{
CustomLog.Log("Batch file 2/4 created");
CustomLog.Log("Batch file 2/5 created");
}
}
catch
{
CustomLog.Error("Failed to write batch file 2/4");
CustomLog.Error("Failed to write batch file 2/5");
}

//Install
try
{
File.WriteAllText(InstallVRC, "start steam://install/438100");
File.WriteAllText(InstallVRC, $"start steam://install/{VRCid}");

if (File.Exists(InstallVRC))
{
CustomLog.Log("Batch file 3/4 created");
CustomLog.Log("Batch file 3/5 created");
}
}
catch
{
CustomLog.Error("Failed to write batch file 3/4");
CustomLog.Error("Failed to write batch file 3/5");
}

//Uninstall
try
{
File.WriteAllText(UninstallVRC, "start steam://uninstall/438100");
File.WriteAllText(UninstallVRC, $"start steam://uninstall/{VRCid}");

if (File.Exists(UninstallVRC))
{
CustomLog.Log("Batch file 4/4 created");
CustomLog.Log("Batch file 4/5 created");
}
}
catch
{
CustomLog.Error("Failed to write batch file 4/4");
CustomLog.Error("Failed to write batch file 4/5");
}

//Github redirect
try
{
File.WriteAllText(OpenGH, $"start https://github.com/scrim-dev/VRC-Deep-Clean/releases");

if (File.Exists(OpenGH))
{
CustomLog.Log("Batch file 5/5 created");
}
}
catch
{
CustomLog.Error("Failed to write batch file 5/5");
}

CustomLog.SetWorkingTitle(string.Empty);
Expand Down
4 changes: 1 addition & 3 deletions VRC-Deep-Clean/Utils/CleanerUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public static void RegDelete(string key)
try
{
Registry.CurrentUser.DeleteSubKeyTree(key);
bool keyExists = Registry.CurrentUser.OpenSubKey(key) != null;

if (!keyExists)
if (Registry.CurrentUser.OpenSubKey(key) != null)
{
CustomLog.Log("Registry key deleted / removed!");
}
Expand Down
4 changes: 0 additions & 4 deletions VRC-Deep-Clean/Utils/CustomLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ internal class CustomLog
{
//255, 41, 126 - secondary color
//187, 28, 255 - main color
public static void SaveLogs()
{
//Need to fix this later
}

public static string ConsoleTitle { get; set; } = "VRC Deep Clean";
private static string? ConsoleWorkTitleThing { get; set; }
Expand Down
50 changes: 50 additions & 0 deletions VRC-Deep-Clean/Utils/NetworkUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VRC_Deep_Clean.Utils
{
internal class NetworkUtils
{
public static void Reset()
{
DoCommand("ipconfig /release");
DoCommand("ipconfig /renew");
DoCommand("netsh winsock reset");
DoCommand("netsh int ip reset");
}

private static void DoCommand(string command)
{
CustomLog.Warn("Doing a network reset...");
CustomLog.Log($"Command: {command}");

ProcessStartInfo PSI = new("cmd", "/c " + command)
{
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};

using Process process = new();
process.StartInfo = PSI;
process.Start();

string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();

process.WaitForExit();

if (process.ExitCode != 0)
{
CustomLog.Error($"{command} failed!\nError: {error}");
}

CustomLog.Log(output);
}
}
}
24 changes: 24 additions & 0 deletions VRC-Deep-Clean/Utils/UpdateUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VRC_Deep_Clean.Utils
{
internal class UpdateUtils
{
public static void Check()
{
//Manual cuz I'm lowkey lazy
Console.Clear();
CustomLog.Logo();
CustomLog.SetWorkingTitle("Redirecting to github...");
CustomLog.Log("Opening github...");
try { Process.Start(Batch.OpenGH); }
catch { CustomLog.Error("Failed to redirect to github please visit manually at my website or: https://github.com/scrim-dev/VRC-Deep-Clean/releases"); }
Thread.Sleep(4000);
}
}
}
29 changes: 29 additions & 0 deletions VRC-Deep-Clean/Utils/VRC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ public static void Clean()
#endregion

#region Local

if (Directory.Exists(LocalPath + "\\log"))
{
CustomLog.Warn($"Found: Logging local path, attempting to delete...");
CleanerUtils.Delete(LocalPath + "\\log");
}
else
{
CustomLog.Error("Logging local folder doesn't exist (it's probably deleted already or missing)");
}

if (Directory.Exists(LocalPath + "\\CrashDumps"))
{
CustomLog.Warn($"Found: CrashDumper local path, attempting to delete...");
CleanerUtils.Delete(LocalPath + "\\CrashDumps");
}
else
{
CustomLog.Error("CrashDumper local folder doesn't exist (it's probably deleted already or missing)");
}

if (Directory.Exists(LocalPath + "\\VRChatCreatorCompanion"))
{
CustomLog.Warn($"Found: VRCCC (Creator Companion) local path, attempting to delete...");
Expand Down Expand Up @@ -194,9 +215,17 @@ public static void Clean()

CleanerUtils.RegDelete(@"Software\VRChat");
Thread.Sleep(1000);
CleanerUtils.RegDelete(@"Software\VCC");
Thread.Sleep(1000);
CleanerUtils.RegDelete(@"Software\Unity\UnityEditor\DefaultCompany");
Thread.Sleep(1000);
CleanerUtils.RegDelete(@"Software\Valve\Steam\Apps\438100"); //438100 - VRChat App ID
Thread.Sleep(1000);

CustomLog.Warn("Flushing DNS...");
FlushDNS();
CustomLog.Warn("Doing other network resets...");
NetworkUtils.Reset();

CustomLog.Log("Clean up completed!");
Thread.Sleep(4500);
Expand Down
8 changes: 8 additions & 0 deletions VRC-Deep-Clean/VRC-Deep-Clean.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<FileVersion>0.0.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;8604;8622;8622</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>1701;1702;8604;8622;8622</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Remove="VRCDeepCleanLogo.png" />
</ItemGroup>
Expand Down

0 comments on commit 15b0c44

Please sign in to comment.