-1

I want to be able to read and later set the Group Policy settings via a MFC program.

Here's what I would do manually. Run gpedit.msc as administrator and in the "Local Group Policy Editor" I'll go to

Computer Configuration->Administrative Templates->windows Components->Windows Update->Specify intranet Microsoft update service location

and set the update service location http://192.168.1.1:8530

Is there any way to do the same form a MFC program? Any code samples would be greatly appricated!

Ken White
  • 123,280
  • 14
  • 225
  • 444
hitman.star
  • 73
  • 10
  • There's an API for working with Group Policy. You can find details about it at [MSDN](http://msdn.microsoft.com). You're not going to like it; it's pretty complex for such a simple task. You'll be better off simply pushing a group policy to your users instead. We don't answer broad, *can someone please find me some code samples* questions here. (And if your question is about MFC, and you've not mentioned anything other than running a command from the command prompt, what is the purpose of the 'batch-file' tag? MFC isn't related to batch scripting.) – Ken White Jun 29 '16 at 00:06
  • If it is possible to running a command from the command prompt, it can be resolved with system() function. – hitman.star Jun 29 '16 at 00:27
  • Your command line isn't doing anything except launching the Group Policy management console. Sure, you can do that using `system`, but that still leaves you making the changes in the dialog just like you are now. As I said, you can find the Group Policy API at MSDN. (Oh, look - I've even given you the search phrase.) We're not your personal research assistants. – Ken White Jun 29 '16 at 00:29
  • Well, I found GetGPOList() function, but it only retrieves the list of GPOs for the specified user or computer. That's not what I want to. Is there any function to set the list of GPOs? – hitman.star Jun 29 '16 at 01:01
  • Look at the index of functions on the left side of [that page](https://msdn.microsoft.com/en-us/library/aa373520(v=vs.85).aspx). There are at least a dozen other functions listed there, including those that set GPOs. (I warned you that you weren't going to like it; it's not a simple task to work with GPOs in code.) – Ken White Jun 29 '16 at 01:07
  • Group policy is normally managed centrally. Why would you want to do what you ask? – David Heffernan Jun 29 '16 at 05:08
  • I want to change update server ip address freely. – hitman.star Jun 29 '16 at 06:35
  • So don't control that setting with group policy then! – David Heffernan Jun 29 '16 at 08:11
  • So, I have corrected registry like this: [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate] "WUServer"="http://192.168.1.1:8530" "WUStatusServer"="http://192.168.1.1:8530" [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU] "UseWUServer"=dword:00000001 "NoAutoUpdate"=dword:00000001 "AUOptions"=dword:00000003 But it's only available when I must reboot my PC. Is there any other ways without reboot my PC? – hitman.star Jun 30 '16 at 00:52

1 Answers1

-3

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\UseWuServer: REG_DWORD set to 1

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUServer: REG_SZ set to http://192.168.1.1:8530

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUStatusServer: REG_SZ set to http://192.168.1.1:8530

i run gpedit.msc and look (under debugger and in regedit finally, on several windows versions(from xp up to win 10)) what is doing if Microsoft update service location set - new 2 keys created(if yet not exist) - HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate and HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU and WUServer, WUStatusServer, UseWuServer is set enter image description here enter image description here than by key/value names - found this - Configure Automatic Updates using Registry Editor

RbMm
  • 31,280
  • 3
  • 35
  • 56
  • Unattributed. No reference to authoritative sources. Suggestion to modify registry rather than API. It is seldom enough to post a couple of reg keys without providing text to explain. Who is going to learn anything from this. It is just voodoo. – David Heffernan Jun 29 '16 at 07:27
  • You need to edit the answer to explain. Adding links with no explanation in the comments is not what we are looking for here. We are wanting high quality answers with explanatory text. For sure include references, but also summarise what we will find when we follow them. In this case the link starts, "If you do not want to use Group Policy to manage Automatic Updates" which somewhat goes against the question's stated desire to control group policy! – David Heffernan Jun 29 '16 at 08:12