show-taskbar.ps1 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # PowerShell script to show Windows taskbar
  2. # Use this script to restore the taskbar if needed
  3. # Run with: powershell -ExecutionPolicy Bypass -File show-taskbar.ps1
  4. try {
  5. Add-Type @"
  6. using System;
  7. using System.Runtime.InteropServices;
  8. public class Taskbar {
  9. [DllImport("user32.dll")]
  10. public static extern int FindWindow(string className, string windowName);
  11. [DllImport("user32.dll")]
  12. public static extern int ShowWindow(int hwnd, int command);
  13. public const int SW_SHOW = 5;
  14. public static void Show() {
  15. // Show main taskbar
  16. int hwnd = FindWindow("Shell_TrayWnd", null);
  17. if (hwnd != 0) {
  18. ShowWindow(hwnd, SW_SHOW);
  19. }
  20. // Show secondary taskbar (if exists, e.g., on multi-monitor setup)
  21. int secondaryHwnd = FindWindow("Shell_SecondaryTrayWnd", null);
  22. if (secondaryHwnd != 0) {
  23. ShowWindow(secondaryHwnd, SW_SHOW);
  24. }
  25. }
  26. }
  27. "@
  28. # Show taskbar
  29. [Taskbar]::Show()
  30. # Exit successfully
  31. exit 0
  32. } catch {
  33. # If error occurs, exit with error code
  34. exit 1
  35. }