PoshInternals
PoshInternals copied to clipboard
Close desktop
Hello, Running into a problem--but it could also just be my limited understanding of these functions. Anyway, I am trying to close (delete) the desktop after using 'New-Desktop' . I have tried numerous different things, but to no avail... Get-Desktop continues to list the created desktop. I even tried this (completely built off your work):
function Close-Desktop
{
[CmdletBinding()]
param(
[Parameter(Mandatory, ValueFromPipeLine=$true, ParameterSetName="Desktop")]
[PSObject]$Desktop,
[Parameter(Mandatory, ValueFromPipeLine=$true, ParameterSetName="Name", Position=0)]
[string]$Name
)
Process
{
if ($Desktop -eq $null)
{
$Desktop = Get-Desktop -Name $Name
}
if ($Desktop -eq $null)
{
Write-Error "Failed to find desktop"
return
}
if (-not [PoshInternals.User32]::CloseDesktop($Desktop.Handle))
{
throw (New-Object System.ComponentModel.Win32Exception)
}
}
}
Any ideas on how to destroy the desktop?
Same here, been trying all sorts of wacky stuff with the [PoshInternals.User32]::CloseDesktop() method with no luck, I'll look again and see if I can figure it out