drewnaylor / hidesettingspages Goto Github PK
View Code? Open in Web Editor NEWGUI to set a Registry key value to hide individual pages in the Windows 10 Settings app on the Creators Update and newer.
License: GNU General Public License v3.0
GUI to set a Registry key value to hide individual pages in the Windows 10 Settings app on the Creators Update and newer.
License: GNU General Public License v3.0
This can use similar code to UXL Launcher's "Always On Top" menubar button.
By allowing this, people can just apply a string they copied and pasted from elsewhere online or a text document they made as a backup for whatever their preferred Settings app page configuration is. This could be in the File menu, possibly as "File>Directly apply key value...". Clicking on it will open a dialog similar to the Windows "Run" dialog but instead of running a program, whatever they type into the box will be written to the proper Registry key value when they click "Apply". There will then be a messagebox asking the user if they're sure they want to apply the key value (which can be turned off in the Options window once it exists, or maybe just a dropdown on the menubar.) If they choose to apply the key value, UAC will show up asking for the admin password and apply the key value with hsp_registry-helper.exe.
I find it annoying that it opens two web pages along with the System Properties page if the user clicks "Yes" in the restore point reminder message.
This would be implemented via a window that kinda looks like the layout below:
The textbox and the "browse..." button will be disabled if the user has the "use current folder" radio button selected. The "prefer current folder" checkbox will also be disabled if "use current folder" is selected.
The text on the side in the light yellow boxes is going to be used with some changes as tooltips for each of their respective controls.
The "test settings" button is going to try to see if hsp_registry-helper.exe exists in the folder the user chose via FileExists() just like I mentioned in #43:
This probably won't need admin permissions to run as it's just reading a Registry key in HKLM.
Important things to include in the configuration document:
Also, try to have an option to load the current key from the Registry.
This'll be a button in the Options menu called "Reset options to default". First it'll ask the user if they want to reset the HideSettingsPages options to default. If the user says yes, it'll then check/uncheck the menubar buttons in the Options menu according to the defaults and save the settings to My.Settings.
There's a way to do this probably with ProcessStartOptions, but I don't know what it is exactly so I'll have to figure it out.
This can be a button that says "Copy from main window" somewhere on the "Directly apply key value" window, or maybe they can have it copy over if they hold the "Shift" key while opening the window.
Another way to do it would be to have an option that says, "Always copy selections into Directly apply key value window". There can be a label that describes this setting that says, "If this is disabled, selections can still be copied over by holding "Shift" while opening the Directly apply key value window."
Also don't complain about missing or invalid command-line args anymore because the default will be "/help".
WinAero has a list of Settings pages that I'm planning on using so that people can easily hide almost all the pages in the Windows 10 Settings app.
List: http://winaero.com/blog/ms-settings-commands-windows-10/
Archived list: https://web.archive.org/web/20170515053239/http://winaero.com/blog/ms-settings-commands-windows-10/
This would make it easier to modify the current page visibility settings.
I'm currently using a Try/Catch block, but this way is better:
https://msdn.microsoft.com/en-us/library/y1036s54(v=vs.100).aspx
If it cannot be found, direct them to download a new copy of HideSettingsPages.
Basically, this means the processstartinfo would be "\hsp_registry-helper.exe /apply hide:about" and would look better to most people. This would have to be changed at the bottom of aaformMainWindow.vb as well as the hsp_registry-helper main file.
The way this can be handled is, the helper program will accept a file path as an argument after /export
, and the UI will offer a file browse dialog to select a folder to export to.
There can also be a /import
command which also accepts a file path (with a file browse dialog provided by the UI for ease of use), and this one directly applies a Registry key value from a properly-formatted file as long as it has permission to do so.
These UI menu items can be Import directly to Registry from file
and Export current Registry key value to file
. Maybe adding a submenu for Import
and Export
would help it be a little less cluttered.
This allows people to copy it directly while taking up less space if it's long. This window should be resizable and have vertical scrollbars.
This way I don't have to keep making and changing strings. Instead of this:
If sArgs.Length = 0 Then
'If there are no arguments, print app info and
' tell the user what arguments are accepted.
argsOutput.noOrInvalidCommandLineArgs("No arguments passed.")
ElseIf sArgs.Length = 1 Then
' If there's only one argument and /apply is being used, complain.
If sArgs(0) = "/apply" Then
argsOutput.noOrInvalidCommandLineArgs("<key value> must be available if trying to use /apply as <action>.")
ElseIf Not sArgs(0) = "/apply" Then
' If the argument isn't /apply, don't complain and set the first arg correctly.
actionToTake = sArgs(0)
fullKeyValue = ""
' Output current args.
argsOutput.passCommandLineArgs()
End If
Else
' Change value of commandline arguments if both of them exist. Doesn't matter if /apply is being used
' or not with this code.
actionToTake = sArgs(0)
fullKeyValue = sArgs(1)
' Output current args.
argsOutput.passCommandLineArgs()
End If
I can do this:
If sArgs.Length = 0 Then
'If there are no arguments, print app info and
' tell the user what arguments are accepted.
argsOutput.noOrInvalidCommandLineArgs("No arguments passed.")
ElseIf sArgs.Length = 1 Then
' If there's only one argument and /apply is being used, complain.
If sArgs(0) = "/apply" Then
argsOutput.noOrInvalidCommandLineArgs("<key value> must be available if trying to use /apply as <action>.")
ElseIf Not sArgs(0) = "/apply" Then
' If the argument isn't /apply, don't complain and set the first arg correctly.
' Output current args.
argsOutput.passCommandLineArgs(sArgs(0), "")
End If
Else
' Change value of commandline arguments if both of them exist. Doesn't matter if /apply is being used
' or not with this code.
' Output current args.
argsOutput.passCommandLineArgs(sArgs(0), sArgs(1))
End If
.
.
.
.
In the argsOutput.passCommandlineArgs sub, instead of this:
Friend Shared Sub passCommandLineArgs()
Console.WriteLine(actionToTake)
Console.WriteLine(fullKeyValue)
MessageBox.Show("This is the full Registry key value.")
MessageBox.Show("Stop.")
If actionToTake = "/verify" Then
regkeyvalue_Verify.runVerification()
ElseIf actionToTake = "/undo" Then
regkeyvalue_Undo.runDeletion()
ElseIf actionToTake = "/apply" Then
regkeyvalue_Apply.runApplying()
End If
End Sub
I can do this:
Friend Shared Sub passCommandLineArgs(actionToTake As String, fullKeyValue As String)
Console.WriteLine(actionToTake)
Console.WriteLine(fullKeyValue)
MessageBox.Show("This is the full Registry key value.")
MessageBox.Show("Stop.")
If actionToTake = "/verify" Then
regkeyvalue_Verify.runVerification()
ElseIf actionToTake = "/undo" Then
regkeyvalue_Undo.runDeletion()
ElseIf actionToTake = "/apply" Then
regkeyvalue_Apply.runApplying(fullKeyValue)
End If
End Sub
.
.
.
.
Then in the applying class, instead of this:
Public Class regkeyvalue_Apply
' If the user chooses to /apply the Registry key value,
' create or edit the proper key value if it exists.
' I'm using a solution based on this thread:
' https://social.msdn.microsoft.com/Forums/en-US/7272f987-bfb5-4bac-a72c-dfde5745832f/how-to-use-add-read-change-delete-registry-keys-with-vbnet?forum=Vsexpressvb
Friend Shared Sub runApplying()
MessageBox.Show("/apply was chosen.")
Dim tempVal As String = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer", "SettingsPageVisibility", Nothing)
' First see if there's a key value to edit.
If tempVal IsNot Nothing Then
' Next, if the user is admin, edit the key value. Using a try/catch because I don't know
' how to do it properly. Can't find any examples in VB.
' Now we can edit the key value.
' Code from:
' https://social.msdn.microsoft.com/Forums/en-US/7272f987-bfb5-4bac-a72c-dfde5745832f/how-to-use-add-read-change-delete-registry-keys-with-vbnet?forum=Vsexpressvb
Try
Dim editFrom As RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer", True)
' Now edit the Registry key value.
editFrom.SetValue("SettingsPageVisibility", fullKeyValue)
editFrom.Close()
Catch ex As Security.SecurityException
' Tell the user if they're not elevated.
MessageBox.Show("The Registry key value cannot be edited because the app isn't running as Administrator. Please elevate and try again.")
End Try
End If
End Sub
End Class
I can do this:
Public Class regkeyvalue_Apply
' If the user chooses to /apply the Registry key value,
' create or edit the proper key value if it exists.
' I'm using a solution based on this thread:
' https://social.msdn.microsoft.com/Forums/en-US/7272f987-bfb5-4bac-a72c-dfde5745832f/how-to-use-add-read-change-delete-registry-keys-with-vbnet?forum=Vsexpressvb
Friend Shared Sub runApplying(fullKeyValue As String)
MessageBox.Show("/apply was chosen.")
Dim tempVal As String = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer", "SettingsPageVisibility", Nothing)
' First see if there's a key value to edit.
If tempVal IsNot Nothing Then
' Next, if the user is admin, edit the key value. Using a try/catch because I don't know
' how to do it properly. Can't find any examples in VB.
' Now we can edit the key value.
' Code from:
' https://social.msdn.microsoft.com/Forums/en-US/7272f987-bfb5-4bac-a72c-dfde5745832f/how-to-use-add-read-change-delete-registry-keys-with-vbnet?forum=Vsexpressvb
Try
Dim editFrom As RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer", True)
' Now edit the Registry key value.
editFrom.SetValue("SettingsPageVisibility", fullKeyValue)
editFrom.Close()
Catch ex As Security.SecurityException
' Tell the user if they're not elevated.
MessageBox.Show("The Registry key value cannot be edited because the app isn't running as Administrator. Please elevate and try again.")
End Try
End If
End Sub
End Class
I may have to modify this a little, but this is generally what should be done. Also, global string variables can be removed from the code where they're defined.
These are the entries that aren't on the list in each of the Settings app categories. Mostly things that can be opened by clicking a link while inside the Settings app or those that hide the main page such as the following:
windowsupdate-action
windowsupdate-history
windowsupdate-options
windowsupdate-restartoptions
There may be others like these, but these are the ones I've noticed so far that hide the main Windows Update page when selected on build 15063.
Originally mentioned in #13, I want to show a messagebox after the Registry key value is applied or removed to tell the user if the operation was successful or not AND tell them to "start or restart the Settings app to see the changes."
I was using Chrome while the window disappeared and now I can't get it back. I could probably fix this by using an issue solution from UXL Launcher: DrewNaylor/UXL-Launcher#53.
This allows me to remove the code to stop it from crashing if there's no arg in one area.
Here are some pages that I can look at later.
http://stackoverflow.com/questions/9206172/delete-key-from-registery
The page list I used seems to not have all the Windows 10 Settings app pages, so here's a much larger list: http://winaero.com/blog/ms-settings-commands-windows-10/
This would mean that the page list would be read from a text file that could be updated by the user at any time. The way to check for updates would use a simple XML file in this repository with the following fields:
<HideSettingsPages_Page_List_Updater>
<lastUpdated>(last updated date in UTC)</lastUpdated>
<currentVersion>(current page list version, used to tell the user if there's an update; something like:) 1.0.0.1</currentVersion>
<updateUrl>(url of the text document; something like:) https://github.com/DrewNaylor/HideSettingsPages/blob/master/HideSettingsPages/page-list-updates/current-page-list.txt</updateUrl>
<sha256Hash>(SHA256 checksum of text file to ensure there's no tampering by comparing this text to the SHA256 checksum of the page list text document)</sha256Hash>
</HideSettingsPages_Page_List_Updater>
This updater xml document would be saved onto the user's computer so that the updater code can compare the version number in the file on the user's computer and the one in the repository the next time there's an update. If the version number in the repository's copy of the update xml document is newer than the version in the update document on the user's computer, the user will be told there's an update, the new update version, their current version, the date (in UTC) the newest version says it was updated on, and be asked if they want to download the newest copy. However, if the SHA256 checksums don't match between the copy in the repository and the field in the update xml document in the repository, the user will be made aware of this and the update will not complete unless the user wants to ignore the checksum mismatch.
In a configuration dialog, the user should be allowed to choose whether or not they want to ignore the checksum mismatch and use a preinstalled copy of the page list (in My.Resources) instead of one in a text document.
This has been tested on Windows 10 builds 15063 and 16193 and the Settings app crashed when all the pages were set to "hide" and I tried to open the System category. I also tried rebooting but that didn't make a difference.
I'm thinking I could make another executable that runs with admin permissions and gets the necessary variables as startup arguments. Maybe something like having the first argument be the full Registry key and the second be "apply" or "undo," where "apply" is triggered from the Apply button at the bottom of the window and "undo" is triggered by the Undo button. Then, in the other EXE, I can have it be like, first command line argument is "fullRegistryKeyValue" and the other one is "applyOrUndo." If applyOrUndo is = "apply," then we'll take "fullRegistryKeyValue" and try to write it into the proper string in the Registry. If it's = "undo," then we'll try to delete the Registry key instead if it currently exists.
Maybe the other EXE file can be named "hsp_apply-key.exe"
This way I can update the string at any time.
Here's a list of pages from Microsoft which include pages I don't have listed in HideSettingsPages: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-settings-app#ms-settings-uri-scheme-reference
Basically, it'll be a messagebox asking them if they want to continue and apply the key value they've chosen.
For example, take the currently-existing info on hsp_registry-helper and place it below the section on HideSettingsPages and separate both of them with a line or something.
I usually do this with UXL Launcher's releases, but I forgot to until just now.
This way I won't have to deal with formatting text via code and can update the details at any time without making sure the text all looks good.
I'm copying this to my UXL Launcher repo as well.
Potential solution: Put a "Recompute Registry Key" button in the File menu so that there's a way to ensure the Registry key is properly updated before the user applies the key to their system. This really should be figured out as soon as possible with a real solution, though.
This arg will output something like the About box in HideSettingsPages with the version number for hsp_registry-helper as well as its copyright and boilerplate text telling the user about the GPL like in HideSettingsPages.
Basically, this would be a messagebox saying, "Are you sure you want to write [page list user chose] to [registry key value]?" After writing the key value, use the GetValue method and try to see if the value exists. If it does, have a messagebox say, "Successfully applied page list to Registry key value. Start or restart the Settings app to see your changes."
It's actually quite easy. MSDN link:
This message can be turned off like the rest of them from the Options
menu.
My.Application.Info.Version.Major.ToString would allow me to do this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.