自动完全更新 Windows
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16180265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Automatically update Windows fully
提问by aeinstein
I'm working on a project where the goal is to be able to update a windows computer 100%. That means a program or a script that updates windows automatically with no user interaction at all. Ideally a standalone script that can be run from another script.
我正在从事一个项目,其目标是能够 100% 更新 Windows 计算机。这意味着无需用户交互即可自动更新窗口的程序或脚本。理想情况下,可以从另一个脚本运行的独立脚本。
The reason: I need to update a lot of computers in my line of work. They can be at any patch level and everything from Windows XP to Windows 8. My goal is to start a script, wait/do something else and then find a fully patched computer.
原因:我需要更新我的工作中的很多计算机。它们可以在任何补丁级别,从 Windows XP 到 Windows 8。我的目标是启动一个脚本,等待/做其他事情,然后找到一台完全打好补丁的计算机。
I've solved a lot by finding ZTIWindowsUpdate.wsf in the MDTTask Sequence.
我通过在MDT任务序列中找到 ZTIWindowsUpdate.wsf 解决了很多问题。
This can be used like this from an admin cmd:
这可以从管理员 cmd 中像这样使用:
cssript.exe ZTIWindowsUpdate.wsf
My problem so far is that the computer requires a reboot between some of the updates. Probably because of dependencies. ZTIWindowsUpdate.wsf needs to be run as administrator and i can't seem to find a solution to start it as administrator at reboot. Additionally if I get the script to run on startup, how do I stop it, and how do I know when its timeto stop it?
到目前为止,我的问题是计算机需要在某些更新之间重新启动。可能是因为依赖。ZTIWindowsUpdate.wsf 需要以管理员身份运行,我似乎找不到在重新启动时以管理员身份启动它的解决方案。此外,如果我让脚本在启动时运行,我该如何停止它,我怎么知道什么时候停止它?
Can someone help med with a foolproof solution to this problem?
有人可以帮助解决这个问题的万无一失的解决方案吗?
Thanks!
谢谢!
采纳答案by Harry Johnston
The simplest solution to the problem you're describing is to get your script to configure automatic logon for the built-in Administrator account, then add itself to the Startup folder. You do need to know (or reset) the Administrator account password to use this option.
您所描述的问题的最简单解决方案是让您的脚本为内置管理员帐户配置自动登录,然后将其自身添加到启动文件夹中。您确实需要知道(或重置)管理员帐户密码才能使用此选项。
There are many other possibilities, some examples are: use a startup script and psexec; use srvany to create a service that runs your script; use task scheduler to schedule your script to run automatically, either interactively or non-interactively; disable WUA, configure automatic logon for the account you're using, and add your script to the Startup folder.
还有很多其他的可能性,一些例子是:使用启动脚本和 psexec;使用 srvany 创建一个运行你的脚本的服务;使用任务调度程序来安排您的脚本自动运行,无论是交互式还是非交互式;禁用 WUA,为您使用的帐户配置自动登录,并将您的脚本添加到启动文件夹。
Note that you'll save time and bandwidth if you can set up a WSUS server or (even simpler, and cheaper if you don't already have a Windows server) a transparent caching proxy. However this won't avoid the need to reboot during the update sequence.
请注意,如果您可以设置 WSUS 服务器或(如果您还没有 Windows 服务器,则更简单,更便宜)透明缓存代理,您将节省时间和带宽。但是,这不会避免在更新序列期间需要重新启动。
You may find my scriptuseful as an alternative starting point to ZTIWindowsUpdate.wsf, if only because it is smaller and simpler to understand.
您可能会发现我的脚本作为 ZTIWindowsUpdate.wsf 的替代起点很有用,因为它更小且更易于理解。
回答by ElektroStudios
Don't need to FULL update a Windows OS, most of the updates are not needed, most updates are not relationated with security and we can survive without they, you need to read the description of each update to understand what changes made. FULLY updating a Windows can be negative point of performance in several scenarios.
不需要完全更新 Windows 操作系统,大多数更新都不需要,大多数更新与安全无关,没有它们我们也可以生存,您需要阅读每个更新的说明以了解所做的更改。在多种情况下,完全更新 Windows 可能会对性能产生负面影响。
All that you need is to download your desired updates, then store it in a folder with this batch script:
您只需要下载所需的更新,然后将其存储在包含此批处理脚本的文件夹中:
@Echo off
For %%# in (*.msu) Do (
Echo: Installing update: %%#
Wusa "%%#" /quiet /norestart
)
Echo Windows Update finished.
Pause&Exit
Also you can compress the folder (the updates + the script) into a Self executable with winrar to distribute it as a standalone file.
您也可以使用 winrar 将文件夹(更新 + 脚本)压缩为 Self 可执行文件,以将其作为独立文件分发。
Info:
信息:
Wusa.exe is the Windows Update commandlineapplication.
Wusa.exe 是Windows Update 命令行应用程序。
The files are processed one by one, not all at once.
文件是一个一个处理的,而不是一次全部处理。
The quietswitch makes the installation silent.
该安静的开关使得安装无声。
The norestartswitch don't restart after installing the update even if needed.
该norestart更新日志文件开关如果需要的话,甚至在安装更新后不重新启动。
If a update is installed in the OS then is not installed again, without getting an error window or stopping the execution of the script.
如果操作系统中安装了更新,则不会再次安装,不会出现错误窗口或停止执行脚本。
PS: See Wusa /?for more switches.
PS:见乌萨/?更多开关。
I hope this helps.
我希望这有帮助。
UPDATE:
更新:
Another alternative is to download and install ALL the updates with WSUSutility.
另一种选择是使用WSUS实用程序下载并安装所有更新。
http://download.wsusoffline.net/
http://download.wsusoffline.net/
The updates for Win7 x64 (for example) are stored here: "...\wsusoffline\client\w61-x64\glb"
Win7 x64 的更新(例如)存储在此处:“...\wsusoffline\client\w61-x64\glb”
PS: The "DoUpdate.cmd" batch file in the "CMD" dir of the application is what you need if need to automate the task in "background".
PS:如果需要在“后台”自动执行任务,则应用程序“CMD”目录中的“DoUpdate.cmd”批处理文件是您所需要的。
回答by Jeffrey L. Roberts
To run
跑步
cssript.exe ZTIWindowsUpdate.wsf
as Administrator after reboots, you can create a Task in the Task Scheduler with the proper permissions and to run on boot. =]
重新启动后,作为管理员,您可以在具有适当权限的任务计划程序中创建任务并在启动时运行。=]
回答by Julia Ambrews
An automated way is, WuInstall. I'm using it for 1 year now and it's perfect, it actually does what it should. It's a command line tool which automatically searches, downloads and installs the updates. There are several "switches" that let you allow to customize the process. Thanks to the rebootcycle-switch for instance, updating a newly setup PC is done with ease - in one go.
一种自动化的方式是WuInstall。我现在使用它 1 年了,它是完美的,它实际上做了它应该做的。它是一个命令行工具,可自动搜索、下载和安装更新。有几个“开关”可让您自定义流程。例如,多亏了rebootcycle-switch,更新新设置的PC 很容易 - 一次完成。
回答by EzR
Here's another way ------ Perform instructions below at your own risk: To automate windows update these instructions may or may not work for your system however it appears to work to an extent for Windows 7 as these instructions were tested on Windows 7.
这是另一种方式 ------ 执行以下说明,风险自负:要自动更新 Windows,这些说明可能适用于您的系统,也可能不适用于您的系统,但它似乎在一定程度上适用于 Windows 7,因为这些说明已在 Windows 7 上进行了测试.
MUST READ: 1. If the step below does not work verify then you are most likely part of a domain and your security policy may not allow you to perform steps below! 2. UAC prompts were also disabled for the duration of the windows updates so the batch files can run without interruption; be careful to restore this to default when done
必读: 1. 如果以下步骤不起作用,请验证您很可能是域的一部分,并且您的安全策略可能不允许您执行以下步骤!2.在Windows更新期间也禁用了UAC提示,因此批处理文件可以不间断地运行;完成后小心将其恢复为默认值
Caution this step will make your computer less secure, immediately remove this after your computer is completely up to date. Set a reminder for 24 hours later if need be:
注意此步骤会降低您的计算机的安全性,请在您的计算机完全更新后立即将其删除。如果需要,设置 24 小时后的提醒:
1.First you will have to make sure your computer automatically logs into a user. You can do this by clicking start menu, type "netplwiz", press enter or open the wizard, under the users tab, select your username, and un-check "require password", type your password, close this window.
1.首先,您必须确保您的计算机自动登录到用户。您可以通过单击开始菜单,键入“netplwiz”,按回车键或打开向导,在用户选项卡下,选择您的用户名,然后取消选中“需要密码”,输入您的密码,关闭此窗口来完成此操作。
2.Create 3 batch files to start the automated process. (Open notepad paste each code into a separate notepad and perform a save as corresponding_file_name.bat)
2.创建 3 个批处理文件以启动自动化过程。(打开记事本将每个代码粘贴到单独的记事本中并执行另存为对应的文件名.bat)
One. Save as: any_name.bat then copy this batch file to your startup folder for the user you made auto login. (Click start > All Programs > Startup)
一。另存为:any_name.bat 然后将此批处理文件复制到您自动登录的用户的启动文件夹中。(单击开始 > 所有程序 > 启动)
start "" c:\autoupdate1.bat
exit
Two. Save as: autoupdate1.bat then copy this to C:\ drive
二。另存为:autoupdate1.bat 然后将其复制到 C:\ 驱动器
wuauclt /detectnow
wuauclt /updatenow
reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" > nul && shutdown -r -t 0
start "" c:\autoupdate2.bat
exit
Three. Save as: autoupdate2.bat then copy this to C:\ drive
三。另存为:autoupdate2.bat 然后将其复制到 C:\ 驱动器
ping 127.0.0.1 -n 61 > nul
start "" c:\autoupdate1.bat
exit
Restart or open the batch file in the startup folder and watch the magic begin!
重新启动或打开启动文件夹中的批处理文件并观看魔术开始!
3.When it is completely done updating just delete the batch files from the startup folder & c:\ drive
3.完成更新后,只需从启动文件夹和 c:\ 驱动器中删除批处理文件
Once again follow these instructions at your own risk as it can create an endless loop if you do not know how to stop this process by removing it from the startup folder or going into windows under safe-mode to remove the batch files
再次按照这些说明进行操作,风险自负,因为如果您不知道如何通过从启动文件夹中删除它或在安全模式下进入 Windows 以删除批处理文件来停止此过程,它可能会创建一个无限循环
Final notes: If you run into issues running the batch files chances are you may have to look up how to disable UAC prompts for your Windows version
最后说明:如果您在运行批处理文件时遇到问题,您可能需要查看如何为您的 Windows 版本禁用 UAC 提示
回答by Wolfgang Stelzhammer
The moast time consuming thing of a WindowsUpadate procedere is the download of the Setupfiles for the Updates. You should look into a lokaly in the network installed WUS (Window Update Server) and make sure the PC updates from the WUS. If the PCs are all in a ActiveDirectory Domain then the needed settings are very easy to manage. But if not this setting could make a simple batch-script which uses the normal windows update routine.
Windows更新程序最耗时的事情是下载更新的安装文件。您应该查看安装在网络中的 WUS(窗口更新服务器),并确保 PC 从 WUS 更新。如果 PC 都在 ActiveDirectory 域中,那么所需的设置就很容易管理。但如果不是,这个设置可以制作一个简单的批处理脚本,它使用普通的 Windows 更新例程。
Another solution would be to make batch-scripts where you install the predownloaded updateFiles with the silent-switch. Allmoast every setup.exe has such a silent switch. If a update isn't needed the update stops for this upload automatically. I'm using such a batch-script wizzardy now for quiet a time now.
另一种解决方案是制作批处理脚本,您可以使用静默开关安装预下载的更新文件。Allmoast 每个 setup.exe 都有这样一个静音开关。如果不需要更新,此上传的更新会自动停止。我现在正在安静地使用这样一个批处理脚本 wizzardy。
PS: If the Computer were from one/your compagny you should "thank" your predecessor for many hours of work to the far future.
PS:如果计算机来自一个/您的公司,您应该“感谢”您的前任为遥远的未来付出了许多小时的工作。
PPS: By the way XP and Vista should be phased out. They are now realy old and for XP the already extended supporttime is axed by Microsoft next year and should only used if it is realy realy needed for one small situation where a Windows 7 isn't a solution in any way possible.
PPS:顺便说一下,XP 和 Vista 应该被淘汰。它们现在已经很老了,对于 XP 已经延长的支持时间将在明年被微软削减,并且只有在真正需要 Windows 7 不是任何可能的解决方案的小情况时才应该使用它。