Techibee.com

PowerShell: Check if “Show desktop icons” is selected or not

I came across this question sometime back. One of the member in a forum was asking if there is a way to find what is the status of icons visibility status on desktop. That means if the “Show Desktop Icons” option in desktop ->Right Click -> View is selected or not.

I came across answer for this while exploring Shell.Application COM class. It has a method called GetSetting() which can return some of the shell properties. One of them is desktop icons visibility status.

Below small function can help you determine the status.

Code:

function Test-DesktopIconHiddenStatus {            
[CmdletBinding()]            
Param(            
)            

$shell = New-Object -ComObject "Shell.Application"            
if($shell.GetSetting("0x00004000")) {            
 Write-Host "Desktop icons are hidden"            
} else {            
 Write-Host "Desktop icons are visible"            
}            

}

Output:

Happy learning…

Exit mobile version