-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
94 lines (81 loc) · 3.85 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Diagnostics;
using System.Threading;
using SHDocVw;
using Microsoft.Win32;
namespace OldExplorer
{
class Program
{
[STAThread]
static void Main(string[] args)
{
string myExe = System.Reflection.Assembly.GetExecutingAssembly().Location;
string Folder = @"\";
string baseKey = @"Software\Classes\CLSID\{52205FD8-5DFB-447D-801A-D0B52F2E83E1}";
string cmdKey = $@"{baseKey}\shell\OpenNewWindow\command";
bool defAdd = false;
bool defDel = false;
bool exitApp = false;
for (int i = 0; i < args.Length; i++)
{
string a = args[i].ToLower();
if (a == "/d+") { defAdd = true; }
else if (a == "/d-") { defDel = true; }
else if (a == "/x") { exitApp = true; }
else Folder = args[i];
}
Folder = Folder.Replace("\"", "\\"); //Ensure trailing backslash is not escaped as quote
if (defDel)
{
Registry.CurrentUser.DeleteSubKeyTree(baseKey, throwOnMissingSubKey: false);
}
if (defAdd)
{
Registry.SetValue($@"HKEY_CURRENT_USER\{cmdKey}", "", $"\"{myExe}\" \"{Folder}\"");
Registry.SetValue($@"HKEY_CURRENT_USER\{cmdKey}", "DelegateExecute", "");
}
if (exitApp) { return; }
string f = Folder.ToLower();
if (f == "desktop") { Folder = "shell:desktop"; }
if (f == "documents") { Folder = "shell:::{A8CDFF1C-4878-43BE-B5FD-F8091C1C60D0}"; }
if (f == "downloads") { Folder = "shell:downloads"; }
if (f == "favorites") { Folder = "shell:::{323CA680-C24D-4099-B94D-446DD2D7249E}"; }
if (f == "frequent") { Folder = "shell:::{3936E9E4-D92C-4EEE-A85A-BC16D5EA0819}"; }
if (f == "home") { Folder = "shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}"; }
if (f == "libraries") { Folder = "shell:libraries"; }
if (f == "music") { Folder = "shell:::{3DFDF296-DBEC-4FB4-81D1-6A3438BCF4DE}"; }
if (f == "onedrive") { Folder = "shell:::{018D5C66-4533-4307-9B53-224DE2ED1FE6}"; }
if (f == "pictures") { Folder = "shell:::{24ad3ad4-a569-4530-98e1-ab02f9417aa8}"; }
if (f == "public") { Folder = "shell:public"; }
if (f == "recent") { Folder = "shell:recent"; }
if (f == "recycle bin") { Folder = "shell:::{645FF040-5081-101B-9F08-00AA002F954E}"; }
if (f == "this pc") { Folder = "shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"; }
if (f == "userprofile") { Folder = "shell:::{59031A47-3F72-44A7-89C5-5595FE6B30EE}"; }
if (f == "videos") { Folder = "shell:::{A0953C92-50DC-43BF-BE83-3742FED03C9C}"; }
Process.Start(new ProcessStartInfo
{
FileName = @"shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\0\::{4336A54D-038B-4685-AB02-99BB52D3FB8B}",
UseShellExecute = true,
Verb = "open"
});
string publicPath = Environment.GetEnvironmentVariable("PUBLIC").Replace("\\", "/");
ShellWindows shellWindows = new ShellWindows();
bool windowFound = false;
for (int i = 1; i < 20; i++)
{
Thread.Sleep(80);
foreach (InternetExplorer window in shellWindows)
{
if (window.LocationURL == $"file:///{publicPath}")
{
window.Navigate(Folder);
windowFound = true;
break;
}
}
if (windowFound) { break; }
}
}
}
}