Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RecycleBinDeleteConfirmation
- {
- param
- (
- [Parameter()]
- [switch]
- $Enable,
- [Parameter()]
- [switch]
- $Disable
- )
- if ($Enable.IsPresent)
- {
- $ShellState = Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState
- $ShellState[4] = 51
- }
- if ($Disable.IsPresent)
- {
- $ShellState = Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState
- $ShellState[4] = 55
- }
- New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState -PropertyType Binary -Value $ShellState -Force
- $UpdateDesktop = @{
- Namespace = "WinAPI"
- Name = "UpdateDesktop"
- Language = "CSharp"
- MemberDefinition = @"
- private static readonly IntPtr hWnd = new IntPtr(65535);
- private const int Msg = 273;
- // Virtual key ID of the F5 in File Explorer
- // Виртуальный код клавиши F5 в проводнике
- private static readonly UIntPtr UIntPtr = new UIntPtr(41504);
- [DllImport("user32.dll", SetLastError=true)]
- public static extern int PostMessageW(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
- public static void PostMessage()
- {
- // F5 pressing simulation to refresh the desktop
- // Симуляция нажатия F5 для обновления рабочего стола
- PostMessageW(hWnd, Msg, UIntPtr, IntPtr.Zero);
- }
- "@
- }
- if (-not ("WinAPI.UpdateDesktop" -as [type]))
- {
- Add-Type @UpdateDesktop
- }
- # Send F5 pressing simulation to refresh the desktop
- # Симулировать нажатие F5 для обновления рабочего стола
- [WinAPI.UpdateDesktop]::PostMessage()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement