How to automatically close an active window with a batch file?

Soldato
Joined
26 Apr 2013
Posts
5,025
Location
Plymouth
The Windows 10 anniversary update broke the startup of an application used in my sound driver suite. It no longer starts with windows, however, it'll start fine if you do it manually. ASUS are aware of the issue but, as of yet, have been unable to fix it. As such, I have had success starting it with a batch file at startup. My batch file is as follows:

START "SonicStudio" "C:\Program Files\ASUSTeKcomputer.Inc\SS2\UserInterface\SS2UILauncher.exe" /open_module SonicStudio.exe

My issue is, this then creates an active window on my desktop of Sonic Suite. I've tried /MIN but that didn't work. This is one of those taskbar apps that only returns to the taskbar when you click close. Is there a way I can automate the closing of the active window without exiting the application?
 
Tried "WM_CLOSE"? It's the command that's sent when pressing the X on a window. Check out this KB (I realise it's ancient :p) - https://support.microsoft.com/en-gb/kb/178893

If that isn't giving you any joy, a semi-long way round would be to make either a VB script or an AutoHotKey macro to send key presses, and then call it in your batch file. Sending ALT+F4 should close the window, but not kill the process. This will really only be doing the same thing as WM_CLOSE, but it might be a way of getting it to work if you're having issues.
 
It appears that WM_CLOSE terminates the application, where as using ALT+F4 only closes the window but leaves it running. Either way, I've got food for thought and a few ideas to pursue. Thanks for your help.
 
That's where the problem lies. The application doesn't start from a shortcut in the startup folder. That was one of the first things I tried. I also tried running a batch that points to the shortcut with the run option set to minimised as well as trying one with commands.

I know it sounds like a bizarre issue, but it's a recurring one on the ASUS forums in the threads regarding the audio drivers. The only luck I've had getting it to start with windows is the above batch file. If I have to quickly click the X each time I start windows, so be it, but I'd like to automate it so I can be lazy. :D
 
can you run it as a service instead eg

.. some services I have open a window, but also have a countdown in it and then autoclose of the window, continuing to run, if you do not want to modify settings or update them.
 
You could create a batch file then get the taskscheduler to run it on login of user ?
eg stick the following into a batch file and create a new task to launch it on login of user

START /D"C:\Program Files\ASUSTeKcomputer.Inc\SS2\UserInterface\" /B /MIN SS2UILauncher.exe /open_module SonicStudio.exe
 
Last edited:
I think you guys are reading this wrong, his problem isn't a command prompt window left open.

My issue is, this then creates an active window on my desktop of Sonic Suite.

So, the application he's automatically starting opens a window that he'd rather not be open, but he still wants it to run in the background and the icon to appear in the system tray so he can't just kill the process.
 
You could us Autohotkey for this.

The idea would be to replace the batch file with an autohotkey script, you can even make them an exe.

Use run or runwait to start to the software you want. Use AU3_Spy to find the name of the window that pop's up and use winwait to wait for that window to appear before the script carries on.

Then use Send !{f4} to close it.

Batch files are great, but sometimes there's an easier option.

something like:

Run SonicStudio.exe
WinWait "window ID/name you want to close"
Send !{F4}

turn into an exe with the software, enter into startup folder.
 
Last edited:
Does it even need to run on startup?

Never had a sound driver suite that was needed for sound to work.
 
My issue is, this then creates an active window on my desktop of Sonic Suite. I've tried /MIN but that didn't work. This is one of those taskbar apps that only returns to the taskbar when you click close. Is there a way I can automate the closing of the active window without exiting the application?

If he posted a screen capture of what click close means - I assume this is not referring to ALt-F4 , but rather a seperate close button the app's gui presents , which does not kill it. ?
 
Back
Top Bottom