简体   繁体   中英

Disable Windows Update during long running processes

Occasionally I have to run long running processes on one of my windows server 2012 servers. the processes can sometimes run for over a week. Windows update terminates this processes when it has to reboot.

I am looking for a way to stop the windows updates service programatically while one of these processes is running and re enable windows update after the process is finished. (instead of just disabling windows update on the server).

I have 2 Ideas on possible approaches:

1)use the ServiceController class

2)call PowerShell commands from my program.

I am not sure on what would be the best solution. or if there is a better option that I am not seeing.

2 years ago I had to implement such a feature.

the way to do it is through the windows registry.

you have to edit registry values.

I do remember that Microsoft documentation does not expose all capabilities, has some mistakes and they changed some things between windows versions.

*to apply the behaviour, they edit some values and sometime add/delete some(on some of OS you also need to restart the WUA).

this link (at automatic updates configuration paragraph) contains more information about the registry values.

to solve those problems I played with the windows update agent, by the time i monitored the WUA with Procmon

That's how I found most of the problems.

to interact with the registry do:

        using (var hive = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,RegistryView.Default))
        using (var key = hive.OpenSubKey(@"put the key there (in most of the operation systems the key is not where microsoft documented)",true))
        {
            //do your logic
        }

I can't give you more information because that's will be NDA violation....

hints: after you done I recommend you to force WUA by using the API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM