DrEmpiricism/Optimize-Offline

After Running Set-Additional.cmd Settings Network & Internet Won't Open

KedarWolf opened this issue · 1 comments

It works before running the script but after I get a stack based buffer overrun error linked in the picture below.

Also, when I click on Devices in Settings it just closes.

Untitled

Edit
Added a missing quote-mark in line 3 of first script and clarified the solution.

Certain per-user services are required to run in order for the "Network & Internet" immersive control panel to show
This issue emerged with 20H1 Build 19041 and continues with 20H2 Build 19042.

** Test if yours is broken**
Paste into Windows explorer address bar or run in a Command Prompt: explorer ms-settings:network-status

== Two steps to fix this issue==

Manual Step 1

  • Open Regedit
  • Check for and delete any "UserServiceFlags" values in these three keys
    (If the values are not there, move on to Step 2)
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MessagingService
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OneSyncSvc
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WpnService

PowerShell - Step 2
Save the following script as 'per-user-fix.ps1' preferably using a better text editor than plain Windows Notepad. Something like the free Notepad++.
Run the script with Administrator privileges.
A restart is required.

#<# ## @@ conservative @@ ##
Write-Output ''
Write-Output "Fixing eleven per-user 'stub' services."
Write-Output ''

Write-Output "Fixing seven total services. Returning six to the 'Startup Type' of Manual (3) and applying the CDPUserSvc modification to Manual from Auto"
@("AarSvc", "CaptureService", "CDPUserSvc", "MessagingService","PimIndexMaintenanceSvc", "UnistoreSvc", "UserDataSvc") | ForEach {
	If (Test-Path -Path "HKLM:SYSTEM\CurrentControlSet\Services\$($_)")
	{
		Set-ItemProperty -LiteralPath "HKLM:SYSTEM\CurrentControlSet\Services\$($_)" -Name "Start" -Value 3 -Type DWord -ErrorAction SilentlyContinue
	}
}

Write-Output ''
Write-Output "Returning three sevices to the 'Startup Type' of automatic (2)"
@( "OneSyncSvc", "WpnService", "WpnUserService") | ForEach {
	If (Test-Path -Path "HKLM:SYSTEM\CurrentControlSet\Services\$($_)")
	{
		Set-ItemProperty -LiteralPath "HKLM:SYSTEM\CurrentControlSet\Services\$($_)" -Name "Start" -Value 2 -Type DWord -ErrorAction SilentlyContinue
	}
}

Write-Output ''
Write-Output "Returning seven sevices to an 'available' state by setting 'UserServiceFlags' to 3"
@("AarSvc", "CaptureService", "CDPUserSvc", "PimIndexMaintenanceSvc", "UnistoreSvc", "UserDataSvc", "WpnUserService") | ForEach {
	If (Test-Path -Path "HKLM:SYSTEM\CurrentControlSet\Services\$($_)")
	{
		Set-ItemProperty -LiteralPath "HKLM:SYSTEM\CurrentControlSet\Services\$($_)" -Name "UserServiceFlags" -Value 3 -Type DWord -ErrorAction SilentlyContinue
	}
}

Background to Issue and Future Problem Avoidance

Background
Seven per-user services disabled by 'Set-Additional.ps1'

*CDPUserSvc* << You can safely set this to Manual and still see the "Network & Internet" panel
*OneSyncSvc* << (!) From Build 19041, this service must remain "Automatic" to see "Network & Internet" panel
*PimIndexMaintenanceSvc* << OK 
*UnistoreSvc* << OK 
*UserDataSvc*<< OK 
*RetailDemo* << I don't consider this per-user, but I could be wrong. I leave mine set to Manual.
*WpnUserService* <<  (!) From Build 19041, this service must remain "Automatic" to see "Network & Internet" panel

Goal
What you're aiming for:
Includes all the per-user services I'm aware of up to 20H2 Build 19042.

Note:
(1) I only tested disabling the four per-user services shown below.
(2) The two per-user services set as "Automatic" and "Running" are required for "Network & Internet" immersive control panel.
(3) I disable Clipboard User Service which Set-Additional.ps1 leaves alone. I don't need it, but you might want to keep it.

Name                                     StartType  Status DisplayName                                  
----                                     ---------  ------ -----------                                  
AarSvc_XXXXX                                Manual Stopped Agent Activation Runtime_XXXXX               
BcastDVRUserService_XXXXX                   Manual Stopped GameDVR and Broadcast User Service_XXXXX     
BluetoothUserService_XXXXX                  Manual Stopped Bluetooth User Support Service_XXXXX         
CaptureService_XXXXX                        Manual Stopped CaptureService_XXXXX
cbdhsvc_XXXXX      I KILL this        Manual Running Clipboard User Service_XXXXX
CDPUserSvc_XXXXX        SWITCH from Auto to Manual Stopped Connected Devices Platform User Service_XXXXX
ConsentUxUserSvc_XXXXX                      Manual Stopped ConsentUX_XXXXX                              
CredentialEnrollmentManagerUserSvc_XXXXX    Manual Stopped CredentialEnrollmentManagerUserSvc_XXXXX     
DeviceAssociationBrokerSvc_XXXXX            Manual Stopped DeviceAssociationBroker_XXXXX                
DevicePickerUserSvc_XXXXX                   Manual Stopped DevicePicker_XXXXX                           
DevicesFlowUserSvc_XXXXX                    Manual Stopped DevicesFlow_XXXXX                            
MessagingService_XXXXX                      Manual Stopped MessagingService_XXXXX                       
OneSyncSvc_XXXXX                         Automatic Running Sync Host_XXXXX                              
PimIndexMaintenanceSvc_XXXXX   KILL         Manual Stopped Contact Data_XXXXX                           
PrintWorkflowUserSvc_XXXXX                  Manual Stopped PrintWorkflow_XXXXX                          
UdkUserSvc_XXXXX                            Manual Stopped Udk User Service_XXXXX                       
UnistoreSvc_XXXXX              KILL         Manual Stopped User Data Storage_XXXXX                      
UserDataSvc_XXXXX              KILL         Manual Stopped User Data Access_XXXXX                       
WpnUserService_XXXXX                     Automatic Running Windows Push Notifications User Service_XXXXX

Future Problem Avoidance
Either fix the the per-user services section in 'Set-Additional.ps1' or
Delete the per-user services section in 'Set-Additional.ps1' and use the AlternativeOnline.ps1 script provided below.

AlternativeOnline.ps1 script
Save the following script as 'AlternativeOnline.ps1' preferably using a better text editor than plain Windows Notepad. Something like the free Notepad++.
Run the script with Administrator privileges.
A restart is required.

Note
The below script contains code to disable the Clipboard User Service
Delete the word "cbdhsvc" in two places if you want to keep that service active.

#<# ## @@ conservative @@ ##
Write-Output ''
Write-Output "Slightly modifying selected per-user 'stub' service activity."

Write-Output ''
Write-Output "Change the 'Startup Type' for a few per-user services to 4 (disabled)"
@("cbdhsvc", "PimIndexMaintenanceSvc", "UnistoreSvc", "UserDataSvc") | ForEach {
	If (Test-Path -Path "HKLM:SYSTEM\CurrentControlSet\Services\$($_)")
	{
		Set-ItemProperty -LiteralPath "HKLM:SYSTEM\CurrentControlSet\Services\$($_)" -Name "Start" -Value 4 -Type DWord -ErrorAction SilentlyContinue
	}
}

Write-Output ''
Write-Output "Prevent a few per-user services from OS start-up creation by setting 'UserServiceFlags' to 0"
@("cbdhsvc", "PimIndexMaintenanceSvc", "UnistoreSvc", "UserDataSvc") | ForEach {
	If (Test-Path -Path "HKLM:SYSTEM\CurrentControlSet\Services\$($_)")
	{
		Set-ItemProperty -LiteralPath "HKLM:SYSTEM\CurrentControlSet\Services\$($_)" -Name "UserServiceFlags" -Value 0 -Type DWord -ErrorAction SilentlyContinue
	}
}

Write-Output ''
Write-Output "Changing the Startup type for CDPUserSvc from Auto to Manaul aka '3'"
@("CDPUserSvc") | ForEach {
	If (Test-Path -Path "HKLM:SYSTEM\CurrentControlSet\Services\$($_)")
	{
		Set-ItemProperty -LiteralPath "HKLM:SYSTEM\CurrentControlSet\Services\$($_)" -Name "Start" -Value 3 -Type DWord -ErrorAction SilentlyContinue
	}
}