本帖最后由 smss 于 2020-12-8 13:17 编辑
文本A- # Enable automatic restart after Windows Update installation
- Function EnableUpdateRestart {
- Write-Output "Enabling Windows Update automatic restart..."
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MusNotification.exe" -Name "Debugger" -ErrorAction SilentlyContinue
- }
- # Disable nightly wake-up for Automatic Maintenance and Windows Updates
- Function DisableMaintenanceWakeUp {
- Write-Output "Disabling nightly wake-up for Automatic Maintenance..."
- If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) {
- New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null
- }
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -Type DWord -Value 0
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\Maintenance" -Name "WakeUp" -Type DWord -Value 0
- }
- #不多还有500条BUG...
复制代码 提取Write-Output "之间的字符" 我的方法不好 正则表达式太难了
生成文本B- powershell "(Gc A.txt) -match 'Write-Output \"(.+?)\"'>B.txt;"
复制代码
- powershell "if(((Gc A.txt) -join \"`r`n\") -match 'Write-Output \"(.+?)\"'){$matches[1]>3.txt};"
复制代码 为什么只有一条 都说ps真香好用 无奈只能用BAT
生成文本C- (for /f "tokens=1,2 delims=-" %%a in (B.txt)do set n=%%b&Echo !n:~8,-1!)>C.txt
复制代码
- Enabling Windows Update automatic restart...
- Disabling nightly wake-up for Automatic Maintenance...
复制代码 翻译文本C得到文本D- 正在启用Windows Update自动重启...
- 禁用夜间唤醒以进行自动维护...
复制代码 文本D替换掉文本A Write-Output "要翻译的部分" |