0

I am looking for a solution to close a window and leave the .exe running.

The .bat file:

@echo off

TITLE Bejelentkezes ujrainditasa

TASKKILL /F /im eszig-eid.exe
TASKKILL /F /im eszig-cmu.exe

start /d "C:\Program Files (x86)\ESZEMELYI\eSzemelyi_Kliens" eszig-cmu.exe

So, the eszig-cmu.exe must stay running, but when the code executes it opens the window of the program, and I don't need it. I want to close only the window of the application, like how I mentioned and leave the .exe (the active program) running! I also apply the solution in PowerShell! I only curious about the solution!

  • 1
    Is `eszig.exe` a console application? What about `start "" /B /D "C:\Program Files (x86)\ESZEMELYI\eSzemelyi_Kliens" eszig-cmu.exe`? – aschipfl Sep 14 '21 at 11:13
  • No i tried, but is stays open. – Barnabás Schmidt Sep 14 '21 at 13:14
  • If you want only close window - send `WM_Close` message to this window. But there can be any procedure to care for data saving: Close confirmation dialog. If it fits your needs use Powershell to call Win322API functions: [Example 1](https://stackoverflow.com/questions/25780138/), [Example 2](https://social.technet.microsoft.com/Forums/windowsserver/en-US/ac9cbb23-24c9-46dc-a9b4-f2f77d9cd0a1/how-to-script-clicking-on-quotxquot-to-close-window) – Daemon-5 Sep 15 '21 at 04:44
  • So, just to make sure, i need a command, an example, written in the .bat file to ensure that i use the right code. Sadly i cannot reveal the solution on the links mentioned above. – Barnabás Schmidt Sep 15 '21 at 06:25
  • You cannot use WinAPI-call directly from batch-file execution. But you can write **Powershell**-script to use WinAPI. Then call Powershell-script from batch file. There is also another famous automation utility **AutoIt**. – Daemon-5 Sep 15 '21 at 12:57
  • Bejelentkezes ujrainditasa = Restart login. I assume you want to repetitively attempt a login while the window is hidden? is that the use case? – ilinkcs Sep 15 '21 at 18:17
  • Not exactly, but very close to it. It is basically should be described as "repeat login", from your opinion, but the main case is close 2 program, open them again, but leave only one of them visible via window. – Barnabás Schmidt Sep 16 '21 at 09:48
  • probably do not want to use cmd then, its not a good wrapper for logins and passwords, suggest you switch to PowerShell. – ilinkcs Sep 16 '21 at 13:33

1 Answers1

0
powershell -command "Start-Process 'C:\Path\To\App.exe' -WindowStyle Hidden"
A7ec
  • 136
  • 6