mirror of
https://github.com/theitaliandeveloper/Perfect11.git
synced 2025-12-06 09:02:03 +00:00
Making big changes
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AD55727D-A52C-459D-A316-3459AA80050A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Perfect11.Inbox.UninstallOneDrive</RootNamespace>
|
||||
<AssemblyName>Perfect11.Inbox.UninstallOneDrive</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Tweak.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Perfect11.TweaksInterface\Perfect11.TweaksInterface.csproj">
|
||||
<Project>{b3f8761a-b4b2-4378-9fe8-06bbfc39fce6}</Project>
|
||||
<Name>Perfect11.TweaksInterface</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Perfect11 Inbox Plugins")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Vichingo455")]
|
||||
[assembly: AssemblyProduct("Perfect11")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025 Vichingo455")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ad55727d-a52c-459d-a316-3459aa80050a")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
172
tweaks/Perfect11.Inbox.UninstallOneDrive/Tweak.cs
Normal file
172
tweaks/Perfect11.Inbox.UninstallOneDrive/Tweak.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using Microsoft.Win32;
|
||||
using Perfect11.TweaksInterface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Perfect11.Inbox.UninstallOneDrive
|
||||
{
|
||||
public class Tweak : IPlugin
|
||||
{
|
||||
public string Name => "Uninstall OneDrive";
|
||||
public string Description => "Remove OneDrive from the system.";
|
||||
public void Execute()
|
||||
{
|
||||
// --- Step 0: Check if OneDrive exists ---
|
||||
bool Exists()
|
||||
{
|
||||
bool regExists = false;
|
||||
try
|
||||
{
|
||||
using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
|
||||
{
|
||||
if (key != null)
|
||||
regExists = key.GetSubKeyNames().Any(n => n.ToLower().Contains("onedrive"));
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return regExists;
|
||||
}
|
||||
|
||||
if (!Exists())
|
||||
{
|
||||
throw new Exception("OneDrive not found, cannot continue!");
|
||||
}
|
||||
// --- Step 1: Check if OneDrive folders contain files ---
|
||||
string usersRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System).Substring(0, 3), "Users");
|
||||
foreach (var dir in Directory.GetDirectories(usersRoot))
|
||||
{
|
||||
string oneDrivePath = Path.Combine(dir, "OneDrive");
|
||||
if (Directory.Exists(oneDrivePath) && Directory.EnumerateFileSystemEntries(oneDrivePath).Any())
|
||||
{
|
||||
throw new Exception("OneDrive files found, cannot continue!");
|
||||
}
|
||||
}
|
||||
|
||||
// --- Step 2: Kill OneDrive process ---
|
||||
foreach (var proc in Process.GetProcessesByName("OneDrive"))
|
||||
try { proc.Kill(); } catch { }
|
||||
|
||||
// --- Step 3: Uninstall OneDrive executables ---
|
||||
foreach (string setupPath in new[]
|
||||
{
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "System32", "OneDriveSetup.exe"),
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "SysWOW64", "OneDriveSetup.exe")
|
||||
})
|
||||
{
|
||||
if (File.Exists(setupPath))
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = setupPath,
|
||||
Arguments = "/uninstall",
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false
|
||||
})?.WaitForExit(5000);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Step 4: Remove folders ---
|
||||
void TryDelete(string path, bool isDir)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isDir && Directory.Exists(path)) Directory.Delete(path, true);
|
||||
else if (!isDir && File.Exists(path)) File.Delete(path);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
TryDelete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Microsoft", "OneDrive"), true);
|
||||
TryDelete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "OneDrive"), true);
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(usersRoot))
|
||||
{
|
||||
TryDelete(Path.Combine(dir, "AppData", "Local", "Microsoft", "OneDrive"), true);
|
||||
TryDelete(Path.Combine(dir, "OneDrive"), true);
|
||||
TryDelete(Path.Combine(dir, "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", "OneDrive.lnk"), false);
|
||||
}
|
||||
|
||||
// --- Step 5: Clean registry (HKLM + HKU) ---
|
||||
try
|
||||
{
|
||||
using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager", true))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
foreach (var sub in key.GetSubKeyNames().Where(k => k.Contains("OneDrive")).ToArray())
|
||||
key.DeleteSubKeyTree(sub, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
foreach (string userHive in Registry.Users.GetSubKeyNames())
|
||||
{
|
||||
if (!userHive.StartsWith("S-")) continue;
|
||||
|
||||
string[] paths =
|
||||
{
|
||||
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\BannerStore",
|
||||
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers",
|
||||
@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths",
|
||||
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||
};
|
||||
|
||||
foreach (string p in paths)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var key = Registry.Users.OpenSubKey($"{userHive}\\{p}", true))
|
||||
{
|
||||
if (key == null) continue;
|
||||
foreach (var sub in key.GetSubKeyNames().Where(n => n.Contains("OneDrive")).ToArray())
|
||||
key.DeleteSubKeyTree(sub, false);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Registry.SetValue($@"HKEY_USERS\{userHive}\SOFTWARE\Classes\CLSID\{{018D5C66-4533-4307-9B53-224DE2ED1FE6}}", "System.IsPinnedToNameSpaceTree", 0, RegistryValueKind.DWord);
|
||||
Registry.SetValue($@"HKEY_USERS\{userHive}\SOFTWARE\Classes\WOW6432Node\CLSID\{{018D5C66-4533-4307-9B53-224DE2ED1FE6}}", "System.IsPinnedToNameSpaceTree", 0, RegistryValueKind.DWord);
|
||||
Registry.Users.DeleteSubKeyTree($"{userHive}\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\{{018D5C66-4533-4307-9B53-224DE2ED1FE6}}", false);
|
||||
|
||||
using (var env = Registry.Users.OpenSubKey(userHive + "\\Environment", true))
|
||||
env?.DeleteValue("OneDrive", false);
|
||||
|
||||
using (var run = Registry.Users.OpenSubKey(userHive + @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true))
|
||||
run?.DeleteValue("OneDriveSetup", false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
// --- Step 6: Remove scheduled tasks ---
|
||||
void DeleteTask(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "schtasks",
|
||||
Arguments = $"/delete /tn \"{name}\" /f",
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false
|
||||
});
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
DeleteTask(@"\OneDrive Reporting Task");
|
||||
DeleteTask(@"\OneDrive Standalone Update Task");
|
||||
|
||||
Console.WriteLine("OneDrive has been completely removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user