ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Windows Update Controller

(1/2) > >>

This project started as an entry for NANY 2017, but because of issues detailed in the thread, I didn't feel great releasing it.

As I already have the app ready to go, and just need to iron out said issues, I figured I could workshop it here with some others if anyone was willing.  I'm also going to add a couple of other features around Windows Update and controlling it, so I figured I'd change the name.

To the primary issue- when I set the correct registry keys, the Windows UI for Active Hours does not register the change, though the registry keys are set correctly.  Not only does it not register the change, it changes back to the default.  I also made a change in the windows UI, and it does affect the registry keys that I expect, and saves the changes.  I've tried it on 4 different machines, and the behavior is the same on all of them, so I don't think it's anything machine-based.  They are all Windows 10 Home (1607/14393.576).

I figured that a picture is worth a thousand words.

First, the interface.

Basically, if you set the active hours for longer than 12 hours, it will find a 12 hour window that works based on your current time, and set the config file to be the whole length, and the registry keys to be that 12 hours.  I was working on this very early in the morning, so when I set the span from 8AM to 11PM, it saved that to the application config (the bottom controls), and set windows to the computed span, i.e. 8AM to 8PM.

Then, the registry.

As you can see, the ActiveHoursStart key is set to 8, and the ActiveHoursEnd key is set to 20, as I expected.

Then I open the active hours dialog.

It was set to 10AM to 10PM before this, but as you can see, it reset the dialog to 8AM to 5PM.

The registry still shows the correct thing.  But will it honor the registry?  I don't know.  I've set 3 of my computers to never reboot unless I manually reboot, so I only have one computer to test on.  I have it currently set in the registry to active hours that do not overlap the 8-5 timespan, so I guess if I'm paying attention at the time, I'll see.  But the kicker is that I have to be paying attention.

The code to make the change is quite simple:

--- Code: C# ---public void SaveData(){        if (this.DataHasChanged)        {                this._LoadingData = true;                 try                {                        using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\WindowsUpdate\UX\Settings", true))                        {                                var activeHours = this.GetActiveHours(Convert.ToDateTime(this.UserActiveHoursBegin).Hour,                                                             Convert.ToDateTime(this.UserActiveHoursEnd).Hour);                                registryKey.SetValue("ActiveHoursStart", activeHours.Item1);                                registryKey.SetValue("ActiveHoursEnd", activeHours.Item2);                        }                        this.Config.AppSettings.Settings["ProgrammedActiveHoursBegin"].Value = Convert.ToDateTime(this.UserActiveHoursBegin).Hour.ToString();                        this.Config.AppSettings.Settings["ProgrammedActiveHoursEnd"].Value = Convert.ToDateTime(this.UserActiveHoursEnd).Hour.ToString();                        this.Config.Save(System.Configuration.ConfigurationSaveMode.Modified);                }                finally                {                        this._LoadingData = false;                        this.DataHasChanged = false;                }                this.LoadData();        }}
Any thoughts?

Interesting project.. It's always tricky to test programs that depend on wall clock time because you have to spend so much time waiting for things to trigger.
Even more so in this case because you're dealing with events that don't happen often.

A virtual machine is a great tool for this kind of problem, because you can mess with the time and date so easily, easily set up a virtual machine that needs updates, easily save snapshots so you can keep repeating a scenario, and not risk messing with your actual machine.

Have you tried using virtual machine for testing?

Have you tried using virtual machine for testing?
-mouser (January 03, 2017, 01:55 AM)
--- End quote ---

Nope.  Mostly because with Windows 10, I haven't really figured out how to get a licensed version into a VM since I don't have a version of windows 10 for it. :(

Nope.  Mostly because with Windows 10, I haven't really figured out how to get a licensed version into a VM since I don't have a version of windows 10 for it. :(-wraith808 (January 03, 2017, 08:14 AM)
--- End quote ---

You can get a free, direct-from-Microsoft, time-limited (expires in April), Windows 10 VM here:

Thanks!  I'll have to check that out!  :Thmbsup:


[0] Message Index

[#] Next page

Go to full version