Wait until application finished
Moderator: DosItHelp
Wait until application finished
I wish to run a program that doesn't unload its exe from the services (in Task Manager), for which purpose I added a taskkill command:
@echo off
start "%~1" C:\Folder\xyz.exe "%~1"
TASKKILL /F /IM "xyz.exe"
exit
Logically, it doesn't work because it immediately turns itself off this way.
What can I write before "TASKKILL" so that the batch file waits with that command until I turn xyz.exe off?
I want it to stop before "TASKKILL" and continue only after I terminate xyz.exe.
@echo off
start "%~1" C:\Folder\xyz.exe "%~1"
TASKKILL /F /IM "xyz.exe"
exit
Logically, it doesn't work because it immediately turns itself off this way.
What can I write before "TASKKILL" so that the batch file waits with that command until I turn xyz.exe off?
I want it to stop before "TASKKILL" and continue only after I terminate xyz.exe.
Re: Wait until application finished
Try
start /WAIT "%~1" C:\Folder\xyz.exe "%~1"
If you need more help try the comand
START /?
start /WAIT "%~1" C:\Folder\xyz.exe "%~1"
If you need more help try the comand
START /?
Re: Wait until application finished
You may be caught in a catch22. Some programs do not play nice with the /wait switch either. But either way how would we know the program is finished if it is not closing itself?
Re: Wait until application finished
Yes, it is the catch - it just continues waiting even though I terminate xyz.exe.
There may probably not be that simple a solution...
There may probably not be that simple a solution...
Re: Wait until application finished
You can probably use the same batch file to start the process, and use it again to kill the process.
(Untested):
(Untested):
Code: Select all
@echo off
If not exist "%temp%\flag.txt" (
type nul >"%temp%\flag.txt"
start "%~1" "C:\Folder\xyz.exe" "%~1"
) else (
TASKKILL /F /IM "xyz.exe"
del "%temp%\flag.txt" 2>nul
)
Re: Wait until application finished
How do you define "terminate" then?batchelor wrote:Yes, it is the catch - it just continues waiting even though I terminate xyz.exe.
Some apps have a "minimize to systray instead of closing" configuration setting, which might be what you are seeing (and, in that case, all that's needed is turn the config setting off, no taskkill required). But you gave no context or details on the actual scenario.
Liviu
Re: Wait until application finished
Liviu wrote:Some apps have a "minimize to systray instead of closing" configuration setting, which might be what you are seeing
Good thinking.
But you gave no context or details on the actual scenario.
That's the perennial question that we-who-like-to-give-support have to face: wtf is the OP *really* trying to do.
![Wink ;)](./images/smilies/icon_wink.gif)
Re: Wait until application finished
Thanks guys.
Terminate: Click the x button on the upper right. In WinXP the exe disappears from the processes listed in Task Manager, in Win 7 it doesn't. So when I start it again, it next time doesn't request the password as it should, but just reactivates the exe in the process.
@foxidrive: thanks, it did work, except that it also never terminates the exe... but it still remains in the Task Manager.
Terminate: Click the x button on the upper right. In WinXP the exe disappears from the processes listed in Task Manager, in Win 7 it doesn't. So when I start it again, it next time doesn't request the password as it should, but just reactivates the exe in the process.
@foxidrive: thanks, it did work, except that it also never terminates the exe... but it still remains in the Task Manager.
Re: Wait until application finished
According to Google, xyz.exe is either a virus or a Trojan.
Why are you running a known malware ?
More seriously, different executables have different characteristics when closing.
If you have a SPECIFIC program for which you need SPECIFIC advice, we need to know what that SPECIFIC program is.
Incidentally, I think your terminology is inappropriate/misleading in your first sentence :-
I assume that what you really meant was :-
Task Manager will show under the processes TAB various running executables.
A large number are launched by "Automatic Services" before the user ever gets to log on,
Another large number are those present when you, the User, has "Run a Program".
A much smaller number are "Manual Services" which are possibly triggered by system events, or by your running a program that chooses to use a system "Service".
Clicking the top right corner of a Application Window will normally close the Application.
If a System "Automatic Service" or "Manual Service" is responsible for that Window we have a different ball game and different rules.
My only experience in this region was H.P. Printer software that was determined to use the Internet for some "Print to Web" feature.
I finished up by location the EXE responsible for the process and changing the extension to TXT.
Alan
Why are you running a known malware ?
![Razz :P](./images/smilies/icon_razz.gif)
More seriously, different executables have different characteristics when closing.
If you have a SPECIFIC program for which you need SPECIFIC advice, we need to know what that SPECIFIC program is.
Incidentally, I think your terminology is inappropriate/misleading in your first sentence :-
I wish to run a program that doesn't unload its exe from the services (in Task Manager),
I assume that what you really meant was :-
I wish to run a program that doesn't unload its exe from the processes (in Task Manager)
Task Manager will show under the processes TAB various running executables.
A large number are launched by "Automatic Services" before the user ever gets to log on,
Another large number are those present when you, the User, has "Run a Program".
A much smaller number are "Manual Services" which are possibly triggered by system events, or by your running a program that chooses to use a system "Service".
Clicking the top right corner of a Application Window will normally close the Application.
If a System "Automatic Service" or "Manual Service" is responsible for that Window we have a different ball game and different rules.
My only experience in this region was H.P. Printer software that was determined to use the Internet for some "Print to Web" feature.
I finished up by location the EXE responsible for the process and changing the extension to TXT.
Alan
Re: Wait until application finished
batchelor wrote:@foxidrive: thanks, it did work, except that it also never terminates the exe... but it still remains in the Task Manager.
Put a pause statment after the DEL command and read the console window which should tell you why it didn't terminate.
Re: Wait until application finished
@alan_b: Well, my friend, I just call it xyz.exe, but it has another name, of course… in this case Passcrypt.exe, a password safe. As I wrote above, I DO want it to terminate the exe from the processes, when I close the program. It does in XP, but not in Win7.
Re: Wait until application finished
Passcrypt.exe doesn't show up in the list of processes, even if it still appears in the Task Manager.
Adding PAUSE doesn't show why it doesn't terminate the exe process, but I have the option to click the batch window once more to additionally terminate the process once program is closed. So I have to click twice...
Adding PAUSE doesn't show why it doesn't terminate the exe process, but I have the option to click the batch window once more to additionally terminate the process once program is closed. So I have to click twice...
Re: Wait until application finished
batchelor wrote:Passcrypt.exe doesn't show up in the list of processes, even if it still appears in the Task Manager.
It could be listed as another exe, perhaps.
Adding PAUSE doesn't show why it doesn't terminate the exe process, but I have the option to click the batch window once more to additionally terminate the process once program is closed. So I have to click twice...
I don't understand - you click once to launch it. And you click once to kill the process.
That's what I said it was meant to do.
What *is* displayed on the screen when pause is after the del command?
Re: Wait until application finished
Are you sure Passcrypt.exe is good and safe ?
The nice thing about knowing a specific name is that Google may tell us useful information to resolve problems.
In this particular case I gained no such problem resolution,
but an awful lot of results, many suggesting it was harmless and others suggesting a Trojan.
I am not saying it is bad - just asking if you are confident
Alan
The nice thing about knowing a specific name is that Google may tell us useful information to resolve problems.
In this particular case I gained no such problem resolution,
but an awful lot of results, many suggesting it was harmless and others suggesting a Trojan.
I am not saying it is bad - just asking if you are confident
Alan
Re: Wait until application finished
batchelor wrote:@alan_b: Well, my friend, I just call it xyz.exe, but it has another name, of course… in this case Passcrypt.exe, a password safe. As I wrote above, I DO want it to terminate the exe from the processes, when I close the program. It does in XP, but not in Win7.
Don't have any first hand experience with passcrypt, but I notice that it has a "system tray" tab among its advertised Options settings http://www.seamistsoftware.com/screenpopup.aspx?image=options_preferences.gif. What's under that tab, and are the settings the same between your xp/win7 machines?
Just saying, but taskkill'ing a program in charge of maintaining some database file with critical info may easily backfire someday.
Liviu