Skip to content

Commit bcea276

Browse files
committed
Add some optimizations for SandboxTest
1 parent cd3016b commit bcea276

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

Tools/SandboxTest.ps1

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -767,26 +767,56 @@ New-Item -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Associa
767767
New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Associations' -Name 'ModRiskFileTypes' -Type 'String' -Value '.bat;.exe;.reg;.vbs;.chm;.msi;.js;.cmd' | Out-Null
768768
769769
Write-Host @'
770-
Tip: you can type 'Update-EnvironmentVariables' to update your environment variables, such as after installing a new software.
771-
'@
772-
773-
Write-Host @'
774-
775770
--> Fixing slow MSI package installers
776771
'@
777772
778-
reg add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy" /v "VerifiedAndReputablePolicyState" /t REG_DWORD /d 0 /f # See: https://github.com/microsoft/Windows-Sandbox/issues/68#issuecomment-2754867968
773+
reg add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy" /v "VerifiedAndReputablePolicyState" /t REG_DWORD /d 0 /f | Out-Null # See: https://github.com/microsoft/Windows-Sandbox/issues/68#issuecomment-2754867968
779774
CiTool.exe --refresh --json | Out-Null # Refreshes policy. Use json output param or else it will prompt for confirmation, even with Out-Null
780775
781776
Write-Host @'
777+
--> Disabling background services
778+
'@
779+
780+
# Disable Search Indexing to prevent performance issues during installation of packages with many files
781+
Stop-Service WSearch
782+
Set-Service WSearch -StartupType Disabled
783+
784+
# Disable Superfetch since we don't need to optimize disk access patterns in a disposable environment
785+
Stop-Service SysMain
786+
Set-Service SysMain -StartupType Disabled
787+
788+
# Disable Windows Update since it can't be used in the sandbox
789+
Stop-Service wuauserv
790+
Set-Service wuauserv -StartupType Disabled
791+
792+
# Disable Scheduled Tasks
793+
schtasks /Change /TN "\Microsoft\Windows\DiskCleanup\SilentCleanup" /Disable | Out-Null
794+
schtasks /Change /TN "\Microsoft\Windows\Defrag\ScheduledDefrag" /Disable | Out-Null
782795
796+
# Disable Telemetry since it isn't needed in a disposable environment
797+
Stop-Service DiagTrack
798+
Set-Service DiagTrack -StartupType Disabled
799+
800+
# Disable the Print Spooler
801+
Stop-Service Spooler
802+
Set-Service Spooler -StartupType Disabled
803+
804+
# Disable Edge Background Processes
805+
reg add "HKLM\Software\Policies\Microsoft\Edge" /v BackgroundModeEnabled /t REG_DWORD /d 0 /f | Out-Null
806+
807+
Write-Host @'
783808
--> Configuring Winget
784809
'@
785810
winget settings --Enable LocalManifestFiles
786811
winget settings --Enable LocalArchiveMalwareScanOverride
787812
Get-ChildItem -Filter 'settings.json' | Copy-Item -Destination C:\Users\WDAGUtilityAccount\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
788813
Set-WinHomeLocation -GeoID $($script:HostGeoID)
789814
815+
Write-Host @'
816+
817+
Tip: you can type 'Update-EnvironmentVariables' to update your environment variables, such as after installing a new software.
818+
'@
819+
790820
`$manifestFolder = (Get-ChildItem `$pwd -Directory).Where({Get-ChildItem `$_ -Filter '*.yaml'}).FullName | Select-Object -First 1
791821
if (`$manifestFolder) {
792822
Write-Host @"

0 commit comments

Comments
 (0)