├── .gitattributes
├── .gitignore
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── InputDialog.xaml
├── InputDialog.xaml.cs
├── LICENSE
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Prompt.xaml
├── Prompt.xaml.cs
├── Properties
└── PublishProfiles
│ └── FolderProfile.pubxml
├── README.md
├── WinContextTweaker.csproj
├── app.manifest
└── assets
├── WinContextTweaker.ico
├── WinContextTweaker.png
├── screenshot1.png
├── screenshot2.png
└── screenshot3.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | # but not Directory.Build.rsp, as it configures directory-level build defaults
86 | !Directory.Build.rsp
87 | *.sbr
88 | *.tlb
89 | *.tli
90 | *.tlh
91 | *.tmp
92 | *.tmp_proj
93 | *_wpftmp.csproj
94 | *.log
95 | *.tlog
96 | *.vspscc
97 | *.vssscc
98 | .builds
99 | *.pidb
100 | *.svclog
101 | *.scc
102 |
103 | # Chutzpah Test files
104 | _Chutzpah*
105 |
106 | # Visual C++ cache files
107 | ipch/
108 | *.aps
109 | *.ncb
110 | *.opendb
111 | *.opensdf
112 | *.sdf
113 | *.cachefile
114 | *.VC.db
115 | *.VC.VC.opendb
116 |
117 | # Visual Studio profiler
118 | *.psess
119 | *.vsp
120 | *.vspx
121 | *.sap
122 |
123 | # Visual Studio Trace Files
124 | *.e2e
125 |
126 | # TFS 2012 Local Workspace
127 | $tf/
128 |
129 | # Guidance Automation Toolkit
130 | *.gpState
131 |
132 | # ReSharper is a .NET coding add-in
133 | _ReSharper*/
134 | *.[Rr]e[Ss]harper
135 | *.DotSettings.user
136 |
137 | # TeamCity is a build add-in
138 | _TeamCity*
139 |
140 | # DotCover is a Code Coverage Tool
141 | *.dotCover
142 |
143 | # AxoCover is a Code Coverage Tool
144 | .axoCover/*
145 | !.axoCover/settings.json
146 |
147 | # Coverlet is a free, cross platform Code Coverage Tool
148 | coverage*.json
149 | coverage*.xml
150 | coverage*.info
151 |
152 | # Visual Studio code coverage results
153 | *.coverage
154 | *.coveragexml
155 |
156 | # NCrunch
157 | _NCrunch_*
158 | .*crunch*.local.xml
159 | nCrunchTemp_*
160 |
161 | # MightyMoose
162 | *.mm.*
163 | AutoTest.Net/
164 |
165 | # Web workbench (sass)
166 | .sass-cache/
167 |
168 | # Installshield output folder
169 | [Ee]xpress/
170 |
171 | # DocProject is a documentation generator add-in
172 | DocProject/buildhelp/
173 | DocProject/Help/*.HxT
174 | DocProject/Help/*.HxC
175 | DocProject/Help/*.hhc
176 | DocProject/Help/*.hhk
177 | DocProject/Help/*.hhp
178 | DocProject/Help/Html2
179 | DocProject/Help/html
180 |
181 | # Click-Once directory
182 | publish/
183 |
184 | # Publish Web Output
185 | *.[Pp]ublish.xml
186 | *.azurePubxml
187 | # Note: Comment the next line if you want to checkin your web deploy settings,
188 | # but database connection strings (with potential passwords) will be unencrypted
189 | *.pubxml
190 | *.publishproj
191 |
192 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
193 | # checkin your Azure Web App publish settings, but sensitive information contained
194 | # in these scripts will be unencrypted
195 | PublishScripts/
196 |
197 | # NuGet Packages
198 | *.nupkg
199 | # NuGet Symbol Packages
200 | *.snupkg
201 | # The packages folder can be ignored because of Package Restore
202 | **/[Pp]ackages/*
203 | # except build/, which is used as an MSBuild target.
204 | !**/[Pp]ackages/build/
205 | # Uncomment if necessary however generally it will be regenerated when needed
206 | #!**/[Pp]ackages/repositories.config
207 | # NuGet v3's project.json files produces more ignorable files
208 | *.nuget.props
209 | *.nuget.targets
210 |
211 | # Microsoft Azure Build Output
212 | csx/
213 | *.build.csdef
214 |
215 | # Microsoft Azure Emulator
216 | ecf/
217 | rcf/
218 |
219 | # Windows Store app package directories and files
220 | AppPackages/
221 | BundleArtifacts/
222 | Package.StoreAssociation.xml
223 | _pkginfo.txt
224 | *.appx
225 | *.appxbundle
226 | *.appxupload
227 |
228 | # Visual Studio cache files
229 | # files ending in .cache can be ignored
230 | *.[Cc]ache
231 | # but keep track of directories ending in .cache
232 | !?*.[Cc]ache/
233 |
234 | # Others
235 | ClientBin/
236 | ~$*
237 | *~
238 | *.dbmdl
239 | *.dbproj.schemaview
240 | *.jfm
241 | *.pfx
242 | *.publishsettings
243 | orleans.codegen.cs
244 |
245 | # Including strong name files can present a security risk
246 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
247 | #*.snk
248 |
249 | # Since there are multiple workflows, uncomment next line to ignore bower_components
250 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
251 | #bower_components/
252 |
253 | # RIA/Silverlight projects
254 | Generated_Code/
255 |
256 | # Backup & report files from converting an old project file
257 | # to a newer Visual Studio version. Backup files are not needed,
258 | # because we have git ;-)
259 | _UpgradeReport_Files/
260 | Backup*/
261 | UpgradeLog*.XML
262 | UpgradeLog*.htm
263 | ServiceFabricBackup/
264 | *.rptproj.bak
265 |
266 | # SQL Server files
267 | *.mdf
268 | *.ldf
269 | *.ndf
270 |
271 | # Business Intelligence projects
272 | *.rdl.data
273 | *.bim.layout
274 | *.bim_*.settings
275 | *.rptproj.rsuser
276 | *- [Bb]ackup.rdl
277 | *- [Bb]ackup ([0-9]).rdl
278 | *- [Bb]ackup ([0-9][0-9]).rdl
279 |
280 | # Microsoft Fakes
281 | FakesAssemblies/
282 |
283 | # GhostDoc plugin setting file
284 | *.GhostDoc.xml
285 |
286 | # Node.js Tools for Visual Studio
287 | .ntvs_analysis.dat
288 | node_modules/
289 |
290 | # Visual Studio 6 build log
291 | *.plg
292 |
293 | # Visual Studio 6 workspace options file
294 | *.opt
295 |
296 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
297 | *.vbw
298 |
299 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
300 | *.vbp
301 |
302 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
303 | *.dsw
304 | *.dsp
305 |
306 | # Visual Studio 6 technical files
307 | *.ncb
308 | *.aps
309 |
310 | # Visual Studio LightSwitch build output
311 | **/*.HTMLClient/GeneratedArtifacts
312 | **/*.DesktopClient/GeneratedArtifacts
313 | **/*.DesktopClient/ModelManifest.xml
314 | **/*.Server/GeneratedArtifacts
315 | **/*.Server/ModelManifest.xml
316 | _Pvt_Extensions
317 |
318 | # Paket dependency manager
319 | .paket/paket.exe
320 | paket-files/
321 |
322 | # FAKE - F# Make
323 | .fake/
324 |
325 | # CodeRush personal settings
326 | .cr/personal
327 |
328 | # Python Tools for Visual Studio (PTVS)
329 | __pycache__/
330 | *.pyc
331 |
332 | # Cake - Uncomment if you are using it
333 | # tools/**
334 | # !tools/packages.config
335 |
336 | # Tabs Studio
337 | *.tss
338 |
339 | # Telerik's JustMock configuration file
340 | *.jmconfig
341 |
342 | # BizTalk build output
343 | *.btp.cs
344 | *.btm.cs
345 | *.odx.cs
346 | *.xsd.cs
347 |
348 | # OpenCover UI analysis results
349 | OpenCover/
350 |
351 | # Azure Stream Analytics local run output
352 | ASALocalRun/
353 |
354 | # MSBuild Binary and Structured Log
355 | *.binlog
356 |
357 | # NVidia Nsight GPU debugger configuration file
358 | *.nvuser
359 |
360 | # MFractors (Xamarin productivity tool) working folder
361 | .mfractor/
362 |
363 | # Local History for Visual Studio
364 | .localhistory/
365 |
366 | # Visual Studio History (VSHistory) files
367 | .vshistory/
368 |
369 | # BeatPulse healthcheck temp database
370 | healthchecksdb
371 |
372 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
373 | MigrationBackup/
374 |
375 | # Ionide (cross platform F# VS Code tools) working folder
376 | .ionide/
377 |
378 | # Fody - auto-generated XML schema
379 | FodyWeavers.xsd
380 |
381 | # VS Code files for those working on multiple tools
382 | .vscode/*
383 | !.vscode/settings.json
384 | !.vscode/tasks.json
385 | !.vscode/launch.json
386 | !.vscode/extensions.json
387 | *.code-workspace
388 |
389 | # Local History for Visual Studio Code
390 | .history/
391 |
392 | # Windows Installer files from build outputs
393 | *.cab
394 | *.msi
395 | *.msix
396 | *.msm
397 | *.msp
398 |
399 | # JetBrains Rider
400 | *.sln.iml
401 |
--------------------------------------------------------------------------------
/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace WinContextTweaker
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/InputDialog.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/InputDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace WinContextTweaker
6 | {
7 | public partial class InputDialog : Window
8 | {
9 | public InputDialog(string question, string defaultAnswer = "")
10 | {
11 | InitializeComponent();
12 | lblQuestion.Content = question;
13 | txtAnswer.Text = defaultAnswer;
14 | }
15 |
16 | private void Button_DialogOkClick(object sender, RoutedEventArgs e)
17 | {
18 | DialogResult = true;
19 | }
20 |
21 | private void Window_ContentRendered(object sender, EventArgs e)
22 | {
23 | txtAnswer.Focus();
24 | txtAnswer.SelectionStart = txtAnswer.Text.Length;
25 | txtAnswer.SelectionLength = 0;
26 | }
27 |
28 | public string Answer
29 | {
30 | get { return txtAnswer.Text; }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 zWolfrost
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
27 |
30 |
32 |
33 |
34 |
35 |
37 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
52 |
53 |
54 |
55 |
57 |
60 |
63 |
66 |
69 |
70 |
71 |
72 |
74 |
75 |
80 |
81 |
82 |
85 |
89 |
93 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 | using System.Windows.Controls;
10 | using System.Windows.Data;
11 | using System.Windows.Documents;
12 | using System.Windows.Input;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 | using System.Windows.Navigation;
16 | using System.Windows.Shapes;
17 | using System.Security.Principal;
18 | using Microsoft.Win32;
19 | using System.Diagnostics;
20 | using System.Windows.Media.Media3D;
21 | using System.Linq.Expressions;
22 | using System.Xml.Linq;
23 |
24 | using System.Text.RegularExpressions;
25 |
26 | namespace WinContextTweaker
27 | {
28 | public partial class MainWindow : Window
29 | {
30 | public string? path;
31 | public string? selectedScript;
32 |
33 | public MainWindow()
34 | {
35 | if (IsElevated())
36 | {
37 | InitializeComponent();
38 |
39 | CanEdit(false);
40 | CanSee(false);
41 | cmbContext.SelectedIndex = 0;
42 | }
43 | else
44 | {
45 | MessageBox.Show("You need to run this program with Elevated Permissions to edit the Registry!");
46 | this.Close();
47 | }
48 | }
49 |
50 |
51 | static private bool IsElevated()
52 | {
53 | bool isElevated;
54 | using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
55 | {
56 | WindowsPrincipal principal = new WindowsPrincipal(identity);
57 | isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator);
58 | }
59 |
60 | return isElevated;
61 | }
62 |
63 |
64 |
65 | private void UpdateOptions()
66 | {
67 | RegistryKey? script = OpenRootSubKey(path + "shell\\" + selectedScript);
68 |
69 | if (script != null)
70 | {
71 | foreach (CheckBox checkbox in stkOptions.Children)
72 | {
73 | checkbox.IsChecked = script.GetValue(checkbox.DataContext as string) != null;
74 | }
75 | }
76 | }
77 | private void UpdateScripts()
78 | {
79 | lstScripts.Items.Clear();
80 |
81 | if (path != null)
82 | {
83 | string[] subKeyNames = OpenRootSubKey(path + "shell\\")?.GetSubKeyNames() ?? [];
84 |
85 | //Debug.WriteLine(string.Join(" ", subKeyNames));
86 |
87 | foreach (string name in subKeyNames)
88 | {
89 | if (GetRootScriptCommand(path + "shell\\" + name) != null)
90 | {
91 | lstScripts.Items.Add(name);
92 | }
93 | }
94 |
95 | lblNoScriptFound.Visibility = lstScripts.HasItems ? Visibility.Collapsed : Visibility.Visible;
96 | }
97 | }
98 | private void CanSee(bool allow)
99 | {
100 | Visibility visibility = allow ? Visibility.Visible : Visibility.Collapsed;
101 |
102 | stkCommand.Visibility = visibility;
103 | stkOptions.Visibility = visibility;
104 | }
105 | private void CanEdit(bool allow)
106 | {
107 | txtCommand.IsEnabled = allow;
108 | stkOptions.IsEnabled = allow;
109 | btnRenameScript.IsEnabled = allow;
110 | btnDeleteScript.IsEnabled = allow;
111 | }
112 |
113 |
114 |
115 | static private RegistryKey? OpenRootSubKey(string name, bool writable = false)
116 | {
117 | return Registry.ClassesRoot.OpenSubKey(name, writable);
118 | }
119 | static private RegistryKey? CreateRootSubKey(string path, string key)
120 | {
121 | return OpenRootSubKey(path, true)?.CreateSubKey(key);
122 | }
123 | static private void DeleteRootSubKeyTree(string path, string key)
124 | {
125 | OpenRootSubKey(path, true)?.DeleteSubKeyTree(key);
126 | }
127 |
128 |
129 | static private string? GetRootScriptCommand(string path)
130 | {
131 | RegistryKey? key = OpenRootSubKey(path + "\\command");
132 |
133 | if (key == null) return null;
134 |
135 | return key.GetValue("") as string ?? "";
136 | }
137 | static private void SetRootScriptCommand(string path, string command)
138 | {
139 | OpenRootSubKey(path + "\\command", true)?.SetValue("", command);
140 | }
141 | static private void RenameRootScript(string path, string oldKey, string newKey)
142 | {
143 | RegistryKey? oldScript = OpenRootSubKey(path + oldKey);
144 |
145 | if (oldScript != null)
146 | {
147 | RegistryKey? newScript = CreateRootSubKey(path, newKey);
148 | CreateRootSubKey(path, newKey + "\\command");
149 |
150 | if (newScript != null)
151 | {
152 | string command = GetRootScriptCommand(path + oldKey) ?? "";
153 | SetRootScriptCommand(path + newKey, command);
154 |
155 | string[] enabledOptions = oldScript.GetValueNames();
156 | foreach (string name in enabledOptions)
157 | {
158 | newScript.SetValue(name, "");
159 | }
160 |
161 | DeleteRootSubKeyTree(path, oldKey);
162 | }
163 | }
164 | }
165 | static private void SwitchScriptOption(string path, string option, bool enable, string value = "")
166 | {
167 | RegistryKey? script = OpenRootSubKey(path, true);
168 |
169 | if (script != null)
170 | {
171 | if (enable)
172 | {
173 | script.SetValue(option, value);
174 | }
175 | else if (script.GetValue(option) != null)
176 | {
177 | script.DeleteValue(option);
178 | }
179 | }
180 | }
181 |
182 |
183 | static private bool IsValidRegexKeyName(string str)
184 | {
185 | const string invalidChars = """\""";
186 |
187 | Regex InvalidCharsRegex = new Regex($"[{Regex.Escape(invalidChars)}]");
188 |
189 | if (InvalidCharsRegex.IsMatch(str) || str.Length == 0) return false;
190 | return true;
191 | }
192 |
193 |
194 |
195 | private void MainWindow_OnKeyDown(object sender, KeyEventArgs e)
196 | {
197 | switch (e.Key)
198 | {
199 | case Key.F5:
200 | UpdateScripts();
201 | UpdateOptions();
202 | break;
203 | }
204 | }
205 |
206 | private void Context_SelectionChanged(object sender, SelectionChangedEventArgs e)
207 | {
208 | CanEdit(false);
209 |
210 | ComboBoxItem? selectedItem = e.AddedItems[0] as ComboBoxItem;
211 |
212 | if (selectedItem == null) return;
213 |
214 | path = selectedItem.DataContext as string;
215 |
216 | if (path == "SystemFileAssociations\\")
217 | {
218 | lstScripts.Items.Clear();
219 |
220 | InputDialog inputDialog = new InputDialog("Enter the file extension (WITH A POINT)", ".");
221 |
222 | if (inputDialog.ShowDialog() == true)
223 | {
224 | path += inputDialog.Answer + "\\";
225 | lblSelectedExtension.Content = inputDialog.Answer;
226 |
227 | CreateRootSubKey("SystemFileAssociations", inputDialog.Answer);
228 |
229 | UpdateScripts();
230 |
231 | lblSelectedExtension.Content = inputDialog.Answer;
232 | lblSelectedExtension.Visibility = Visibility.Visible;
233 | }
234 | else
235 | {
236 | cmbContext.SelectedIndex = 0;
237 | }
238 | }
239 | else
240 | {
241 | lblSelectedExtension.Visibility = Visibility.Collapsed;
242 |
243 | UpdateScripts();
244 | }
245 | }
246 |
247 | private void List_ScriptChanged(object sender, EventArgs e)
248 | {
249 | selectedScript = lstScripts.SelectedItem as string;
250 |
251 | if (selectedScript == null)
252 | {
253 | CanEdit(false);
254 | CanSee(false);
255 | }
256 | else
257 | {
258 | CanSee(true);
259 |
260 | try
261 | {
262 | UpdateOptions();
263 |
264 | string? command = GetRootScriptCommand(path + "shell\\" + selectedScript);
265 | txtCommand.Text = command;
266 |
267 | CanEdit(true);
268 | }
269 | catch
270 | {
271 | CanEdit(false);
272 | }
273 | }
274 | }
275 |
276 | private void Checkbox_SwitchScriptOption(object sender, EventArgs e)
277 | {
278 | CheckBox element = (CheckBox)sender;
279 | bool state = element.IsChecked ?? false;
280 | string? option = element.DataContext as string;
281 |
282 | if (option == null) return;
283 |
284 | string value = "";
285 | if (option == "MultiSelectModel") value = "player";
286 |
287 | SwitchScriptOption(path + "shell\\" + selectedScript, option, state, value);
288 |
289 | if (option == "Icon" && state == true)
290 | {
291 | element.IsChecked = false;
292 |
293 | OpenFileDialog openFileDialog = new OpenFileDialog();
294 |
295 | openFileDialog.InitialDirectory = "%userprofile%";
296 | openFileDialog.Filter = "Icon Files (*.ico, *.exe)|*.ico;*.exe";
297 | openFileDialog.FilterIndex = 0;
298 | openFileDialog.RestoreDirectory = true;
299 |
300 | if (openFileDialog.ShowDialog() == true)
301 | {
302 | string iconPath = openFileDialog.FileName;
303 |
304 | OpenRootSubKey(path + "shell\\" + selectedScript, true)?.SetValue(option, iconPath);
305 |
306 | element.IsChecked = true;
307 | }
308 | }
309 | }
310 |
311 | private void Text_CommandChanged(object sender, EventArgs e)
312 | {
313 | string command = txtCommand.Text;
314 |
315 | SetRootScriptCommand(path + "shell\\" + selectedScript, command);
316 | }
317 |
318 |
319 |
320 | private void Button_NewScript(object sender, EventArgs e)
321 | {
322 | const string defaultCommand = "cmd /c \"echo Hello World && pause\"";
323 |
324 | InputDialog inputDialog = new InputDialog("Enter the new script's name:", "");
325 |
326 | if (inputDialog.ShowDialog() == true && path != null)
327 | {
328 | if (IsValidRegexKeyName(inputDialog.Answer))
329 | {
330 | CreateRootSubKey(path, $"shell\\{inputDialog.Answer}\\command");
331 | SetRootScriptCommand(path + "shell\\" + inputDialog.Answer, defaultCommand);
332 | UpdateScripts();
333 | }
334 | }
335 | }
336 |
337 | private void Button_DeleteScript(object sender, EventArgs e)
338 | {
339 | Prompt prompt = new Prompt("Are you sure you want to delete this script?");
340 |
341 | if (prompt.ShowDialog() == true && path != null && selectedScript != null)
342 | {
343 | DeleteRootSubKeyTree(path + "shell\\", selectedScript);
344 | UpdateScripts();
345 | }
346 | }
347 |
348 | private void Button_RenameScript(object sender, EventArgs e)
349 | {
350 | if (selectedScript == null) return;
351 |
352 | InputDialog inputDialog = new InputDialog("Enter the script's new name:", selectedScript);
353 |
354 | if (inputDialog.ShowDialog() == true && path != null && selectedScript != null)
355 | {
356 | if (IsValidRegexKeyName(inputDialog.Answer))
357 | {
358 | RenameRootScript(path + "shell\\", selectedScript, inputDialog.Answer);
359 | UpdateScripts();
360 | }
361 | }
362 | }
363 | }
364 | }
--------------------------------------------------------------------------------
/Prompt.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Prompt.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 |
4 | namespace WinContextTweaker
5 | {
6 | public partial class Prompt : Window
7 | {
8 | public Prompt(string question)
9 | {
10 | InitializeComponent();
11 | lblQuestion.Content = question;
12 | }
13 |
14 | private void Button_DialogYesClick(object sender, RoutedEventArgs e)
15 | {
16 | DialogResult = true;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | Release
8 | Any CPU
9 | C:\Users\zwolfrost\Desktop\WinContextTweaker
10 | FileSystem
11 | <_TargetId>Folder
12 | net6.0-windows
13 | false
14 | win-x64
15 | true
16 | false
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WinContextTweaker
2 | [](https://github.com/zWolfrost/WinContextTweaker/releases/latest)
3 | [](LICENSE)
4 |
5 | Free and Open-source Right Click Context Menu Editor for Windows.
6 | You can download it in the releases tab.
7 |
8 | If you are using Windows 7 or 8.1, remember to install the ".NET Framework 6.0" and its [dependencies](https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net60#additional-deps).
9 |
10 | ## Features
11 | - Creation and deletion of context menu items, along with their scripts.
12 | - Adding scripts only for files, folders and/or specific file types.
13 | - Support for registry options (Shift only, Add icon...).
14 |
15 | ## Tips
16 | - Hover options to show a tooltip with more information.
17 |
18 | - There are multiple command line variables. The ones that are most useful (and consistent) are:
19 | - "%V" – The selected item (file or folder).
20 | - "%W" – The working directory. Usually, this is the directory of the right-click, but not necessarily the selected item's parent folder (for example, when right-clicking shortcuts, "%V" returns the path of the actual item, while "%W" returns the shortcut's folder).
21 |
22 | - When selecting multiple files, the specified command will run *individually* for each file selected.
23 |
24 | - If you are making changes using the actual Registry, you can update the scripts in the program by pressing "F5".
25 |
26 |
27 | ## Screenshots (as of v1.3.0)
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | ## Changelog
40 | _Note that any version might include a number of stylistic changes, which are often not documented to avoid cluttering the changelog_
41 |
42 | - **v1.0.0**:
43 |
- First release.
44 |
45 | - **v1.1.0**:
46 |
- Added "Icon" (with icon selection) and "No Working Directory" options.
47 |
- Added "Text", "Document", "Image", "Video", "Audio" and "by extension" files context menus.
48 |
- Fixed crashes and bugs.
49 |
50 | - **v1.2.0**:
51 |
- Added an "Hello World" default command.
52 |
- Added informative tooltips.
53 |
- Changed the elements padding to be more organized.
54 |
55 | - **v1.3.0**:
56 |
- Added a "No scripts was found" text.
57 |
- Added an "F5" "Update" keybinding, for debugging purposes.
58 |
- Changed the way a file extension gets selected.
59 |
- Fixed bug where creating or renaming a script with an invalid name would crash the program.
60 |
- Fixed bug where creating a script for a file extension that had no registry entry would not work.
61 |
62 | - **v1.4.0**:
63 |
- Added a "Classify as Player" option.
64 |
- Changed the command's font to a monospace one.
--------------------------------------------------------------------------------
/WinContextTweaker.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net6.0-windows
6 | enable
7 | true
8 | preview
9 | app.manifest
10 | assets\WinContextTweaker.ico
11 | False
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
54 |
62 |
63 |
64 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/assets/WinContextTweaker.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zWolfrost/WinContextTweaker/df915854689622978d5a12f491219f7e640229ca/assets/WinContextTweaker.ico
--------------------------------------------------------------------------------
/assets/WinContextTweaker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zWolfrost/WinContextTweaker/df915854689622978d5a12f491219f7e640229ca/assets/WinContextTweaker.png
--------------------------------------------------------------------------------
/assets/screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zWolfrost/WinContextTweaker/df915854689622978d5a12f491219f7e640229ca/assets/screenshot1.png
--------------------------------------------------------------------------------
/assets/screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zWolfrost/WinContextTweaker/df915854689622978d5a12f491219f7e640229ca/assets/screenshot2.png
--------------------------------------------------------------------------------
/assets/screenshot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zWolfrost/WinContextTweaker/df915854689622978d5a12f491219f7e640229ca/assets/screenshot3.png
--------------------------------------------------------------------------------