我和我的同事正在開發一組腳本,與 Windows 成像器和配置設計器 (WICD) 結合使用,為新 PC 提供自定義軟體并去除一堆討厭的東西。我們讓所有組件都獨立作業,我們只需要將它們串在一起,這樣它們就可以同時運行,幾乎不需要用戶干預。以下是其作業原理的細分:
Get to OOBE experience where you select region
Plug in USB drive with provisioning package at the root of the USB drive
Let things run
First script (install) creates working directories, downloads scripts from github repo, skips OOBE turning off everything, creates admin user and password, enables auto logon, uses a run once registry key to run second script.
Second script (cleanup) Waits 30 seconds to let the registry populate
Resets privacy settings, disables auto logon, deletes stored credentials, installs a piece of software, and lastly runs another script which installs more software and strips a bunch of bloatware out of Windows.
或者,至少它應該運行最后一個腳本。這是我唯一沒有作業的事情。我可以通過日志檔案和輸出判斷它試圖運行腳本,但它所做的只是啟動腳本,然后在沒有任何輸出、回溯或任何表明它失敗的情況下退出,除了 PowerShell 提示。下面是清理腳本的清理和編輯版本。為了讓這個其他腳本運行,我做錯了什么嗎?有沒有另一種方式我應該接近這個。任何幫助是極大的贊賞。
如果您愿意,我還可以發布安裝腳本和 Windows 清理程式。第 24 行是我遇到障礙的地方。
Start-Transcript -Append C:\Support\Logs\PostDeploymentCleanupLog.txt
#Wait for registry to populate
Start-Sleep -s 30
# Reset Privacy settings to default
reg delete HKLM\SOFTWARE\Policies\Microsoft\Windows\OOBE /v DisablePrivacyExperience /f
# Disable autoLogon
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 0 /f
# Remove stored credentials
REG DELETE "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /f
# Start SomeSoftware installer in quiet mode
Function Install-SomeSoftware {...} #End Function Install-SomeSoftware
Install-SomeSoftware -Server '<redacted>' -LocationID <redacted> -Token '<redacted>' -Silent -Force -Transcript
# Run WindowsSetup2_0-WIP
# Forked from SomeGuy's GitHub repo
PowerShell.exe -ExecutionPolicy Bypass -File C:\Support\Scripts\WindowsSetup2_0.ps1
#Remove unneeded directories
Remove-Item -Path C:\\Support\\Scripts -Recurse -Verbose
Remove-Item -Path C:\\Support\\Installers -Recurse -Verbose
Stop-Transcript
uj5u.com熱心網友回復:
我在我的 WindowsSetup 腳本中發現了一個錯誤,它導致 cmd 實體打開而不是關閉,因此破壞了腳本。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/392529.html
