高分求解:如何编程修改本地计算机策略(组策略),达到自动修改Windows升级服务器位置
我想在Intranet内设立一台Windows升级服务器(已实现),然后将客户机的Windows升级源都指到这一台服务器。手工修改策略的方法是:
1、用gpedit.msc打开组策略编辑器,确认左边树形菜单中“本地计算机”策略--计算机配置--管理模板--Windows组件 是否有Windows Update。
2、如果没有,则在上述的“管理模板”上点右键选择“添加/删除模板”,然后选择“添加”wuau.adm,然后将出现Windows Update。
3、在Windows Update下设置“配置自动更新”、“指定Intranet Microsoft更新服务位置”。
但考虑到以上办法太麻烦,因此想编程实现。
通过查找特征值,我想通过修改注册表来实现,但未能成功,代码如下:
//停止Windows Automatic Updates服务
winexec(PChar('net stop wuauserv'), SW_HIDE);
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.DeleteKey('\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update');
if Reg.OpenKey('\Software\Policies\Microsoft\Windows\WindowsUpdate', True) then
begin
Reg.WriteString('WUServer','http://10.151.18.114');
Reg.WriteString('WUStatusServer','http://10.151.18.114');
if Reg.OpenKey('\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU', True) then
begin
Reg.WriteInteger('AUOptions',3);
Reg.WriteInteger('NoAutoUpdate',0);
Reg.WriteInteger('ScheduledInstallDay',0);
Reg.WriteInteger('ScheduledInstallTime',3);
Reg.WriteInteger('UseWUServer',1);
Reg.WriteInteger('NoAutoRebootWithLoggedOnUsers',1);
Reg.WriteInteger('RescheduleWaitTime',1);
end;
end;
finally
Reg.CloseKey;
Reg.Free;
end;
//开启Windows Automatic Updates服务
winexec(PChar('net start bits'), SW_HIDE);
winexec(PChar('net start wuauserv'), SW_HIDE);
1、用gpedit.msc打开组策略编辑器,确认左边树形菜单中“本地计算机”策略--计算机配置--管理模板--Windows组件 是否有Windows Update。
2、如果没有,则在上述的“管理模板”上点右键选择“添加/删除模板”,然后选择“添加”wuau.adm,然后将出现Windows Update。
3、在Windows Update下设置“配置自动更新”、“指定Intranet Microsoft更新服务位置”。
但考虑到以上办法太麻烦,因此想编程实现。
通过查找特征值,我想通过修改注册表来实现,但未能成功,代码如下:
//停止Windows Automatic Updates服务
winexec(PChar('net stop wuauserv'), SW_HIDE);
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.DeleteKey('\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update');
if Reg.OpenKey('\Software\Policies\Microsoft\Windows\WindowsUpdate', True) then
begin
Reg.WriteString('WUServer','http://10.151.18.114');
Reg.WriteString('WUStatusServer','http://10.151.18.114');
if Reg.OpenKey('\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU', True) then
begin
Reg.WriteInteger('AUOptions',3);
Reg.WriteInteger('NoAutoUpdate',0);
Reg.WriteInteger('ScheduledInstallDay',0);
Reg.WriteInteger('ScheduledInstallTime',3);
Reg.WriteInteger('UseWUServer',1);
Reg.WriteInteger('NoAutoRebootWithLoggedOnUsers',1);
Reg.WriteInteger('RescheduleWaitTime',1);
end;
end;
finally
Reg.CloseKey;
Reg.Free;
end;
//开启Windows Automatic Updates服务
winexec(PChar('net start bits'), SW_HIDE);
winexec(PChar('net start wuauserv'), SW_HIDE);
...全文
相关推荐
本地安全策略和本地组策略编辑器命令
本地组策略编辑器(gpedit.msc)本地组策略编辑器是一个强大的管理工具,用于修改Windows计算机上的组策略设置。
Windows组策略修改工具LGPO
Windows组策略修改工具LGPO是一款专门用于自动化管理Windows操作系统本地组策略的对象(Local Group Policy Objects, LGPO)的工具。
Windows脚本系列之三——使用脚本批量修改本地管理员密码
GPO(组策略):GPO 是 Windows 中的一种策略机制,用于管理和配置计算机和用户设置。4. VBS(VBScript):VBS 是一种脚本语言,用于自动化Windows操作系统的管理任务。
AD域组策略部署软件
而已指派的部署方式允许将软件部署到用户或计算机,软件会自动安装,无需用户交互,适用于需要强制安装的应用。在配置过程中,管理员需在组策略编辑器中选择正确的部署类型,指定安装包的位置,并设置相应的策略。
组策略配置策略及运行脚本
#### 环境准备- **域控制器**: Windows Server 2008 R2 SP1- **域成员服务器**: 3台 Windows Server 2008 R2 SP1#### 组策略设置步骤首先


Windows SDK/API
