Manasaurus
Beginner
I wanted the notifications in windows 10 to be turned off whenever I connect it to an external display using HDMI, without using an external application. This is what I have been able to come up so far:
- used Task Scheduler to create a task
- checked the Event Viewer when the external display was connected. The details came out to be -
Log: Microsoft-Windows-DeviceSetupManager/Admin
Source: DeviceSetupManager
Event ID: 112
- Now had to write a script to run when the event was triggered
- ChatGPT suggested a powershell script but it doesnt seem to work.
- I have checked the registry editor to figure out what needed to be done but can't figure it out.
Any suggestions? Or should I scrape the whole thing off and try a different approach? Here's the code chatGPT gave:
# Disable Windows 10 notifications
# Check if running with administrator privileges
$isAdmin = ([Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544"
if (-not $isAdmin) {
Write-Host "Please run this script with administrator privileges."
exit
}
# Disable notifications
Write-Host "Disabling Windows 10 notifications..."
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" -Name ToastEnabled -Value 0 -PropertyType DWORD -Force | Out-Null
Write-Host "Notifications disabled successfully."
# Prompt to restart Explorer for changes to take effect
$restartExplorer = Read-Host "Do you want to restart Explorer to apply changes? (Y/N)"
if ($restartExplorer -eq 'Y' -or $restartExplorer -eq 'y') {
Stop-Process -Name explorer -Force
Start-Process explorer
Write-Host "Explorer restarted."
} else {
Write-Host "Changes will take effect after the next system restart or Explorer restart."
}
- used Task Scheduler to create a task
- checked the Event Viewer when the external display was connected. The details came out to be -
Log: Microsoft-Windows-DeviceSetupManager/Admin
Source: DeviceSetupManager
Event ID: 112
- Now had to write a script to run when the event was triggered
- ChatGPT suggested a powershell script but it doesnt seem to work.
- I have checked the registry editor to figure out what needed to be done but can't figure it out.
Any suggestions? Or should I scrape the whole thing off and try a different approach? Here's the code chatGPT gave:
# Disable Windows 10 notifications
# Check if running with administrator privileges
$isAdmin = ([Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544"
if (-not $isAdmin) {
Write-Host "Please run this script with administrator privileges."
exit
}
# Disable notifications
Write-Host "Disabling Windows 10 notifications..."
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" -Name ToastEnabled -Value 0 -PropertyType DWORD -Force | Out-Null
Write-Host "Notifications disabled successfully."
# Prompt to restart Explorer for changes to take effect
$restartExplorer = Read-Host "Do you want to restart Explorer to apply changes? (Y/N)"
if ($restartExplorer -eq 'Y' -or $restartExplorer -eq 'y') {
Stop-Process -Name explorer -Force
Start-Process explorer
Write-Host "Explorer restarted."
} else {
Write-Host "Changes will take effect after the next system restart or Explorer restart."
}