Writing a Powershell Script to Close Windows on startup

I have recently installed some new software (vhui64.exe) that opens two popup windows upon running it and I want to close these ASAP or ideally have the exe run without these gui elements.

When the program is open it does not display in the system tray but it is present in the task manager.

I have tried to make an automated script in powershell and batch (using taskkill in batch completely closes all processes but I want the program to continue running).

Using the Alt+F4 keys on both of these windows closes them correctly without stopping the process from running, and so my script tries to do this automatically but it doesn't seem to be working?

I am new to powershell and batch so if anyone has any ideas/better ways of doing this please let me know, thanks!

Popups Powershell Script


Solution 1:

You may use the free AutoHotkey.

The following example script will wait twice for a dialog with the title of "VirtualHere Client" to become active and will close it. After closing the two dialogs, the script will terminate.

#persistent
SetTitleMatchMode, 2
Loop, 2
{
  WinWaitActive, VirtualHere Client
  WinClose
}
ExitApp
Return

After installing AutoHotKey, put the above text in a .ahk file and double-click it to test. You may stop the script by right-click on the green H icon in the traybar and choosing Exit. To have it run on login, place it in the Startup group at
C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Useful AutoHotkey documentation:

  • List of Keys
  • Hotkeys