Need Batch File to close a Window.. NOT the batch window
Complete novice here so please forgive if the answer is obvious.
I have a batch file that does the following.
Starts program 1 Waits 3 seconds (I have to click a button on program 1 after it opens) Then program 2 starts.
My problem is that program 1 just needs to run in the background.... No window needed after the first 3 seconds.
Normally, I start the batch file, program 1 starts. I click the button to start a service.
Three seconds the second program starts.
I then have to go back to program 1 and click the X in top right of window to close it. I'd like for the WINDOW on program one to close automatically after 3 seconds (but the program itself cannot be killed).
Suggestions?
@echo off
start C:\Folder\To\MySystemManager.exe
TIMEOUT 3
start "" "C:\Program Files (x86)\CustomProgram\CustomProgram.exe"
exit
AFAIK that's not possible with 'pure' batch - you'd need to use either a 3rd party tool or use powershell [or some other way to reference Win API].
If I understood you correctly and the window you want to close is a kind of a control panel which redefines Window close message than this should work (as run from cmd and assuming there is only one instance of the process):
powershell (ps MySystemManager).CloseMainWindow()
This command acts as if you'd clicked 'close' (X) button
I have tested it with xampp control panel (powershell (ps xampp-control).CloseMainWindow()
), your mileage may vary