1

I'm running a script in PowerShell using Task-Scheduler on system start which runs a command. I want to control what happens when I click the minimize or close buttons on this PowerShell window. I would like the process to get hidden (minimized to system tray) instead of

  • minimizing in the task-bar on clicking the minimize button or
  • terminating the process and closing on clicking the Cross (X) button

Using the below resources, I was able to add a system tray icon in the taskbar with few menu items to show and hide the window when necessary.

Note that I was able to disable the Cross (X) button by using the below code from this link:

[Win32.NativeMethods]::EnableMenuItem($hMenu, $SC_CLOSE, $MF_DISABLED) | Out-Null

But I don't want to disable it, Instead I want it to minimize to system tray

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.