View unanswered posts | View active topics It is currently 01 Nov 2014 04:17



Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Wait until application finished 
Author Message

Joined: 12 Sep 2010 08:54
Posts: 11
Post 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.


23 Feb 2012 15:09
Profile
Expert

Joined: 04 Oct 2008 09:49
Posts: 357
Post Re: Wait until application finished
Try
start /WAIT "%~1" C:\Folder\xyz.exe "%~1"

If you need more help try the comand

START /?


23 Feb 2012 15:11
Profile

Joined: 23 Dec 2011 13:59
Posts: 1952
Post 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?


23 Feb 2012 16:00
Profile

Joined: 12 Sep 2010 08:54
Posts: 11
Post 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...


23 Feb 2012 16:35
Profile

Joined: 10 Feb 2012 02:20
Posts: 4331
Post 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):

Code:
@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
)


23 Feb 2012 22:46
Profile
Expert

Joined: 13 Jan 2012 21:24
Posts: 441
Post Re: Wait until application finished
batchelor wrote:
Yes, it is the catch - it just continues waiting even though I terminate xyz.exe.
How do you define "terminate" then?

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


24 Feb 2012 01:39
Profile

Joined: 10 Feb 2012 02:20
Posts: 4331
Post 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.

Quote:
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. ;)


24 Feb 2012 02:13
Profile

Joined: 12 Sep 2010 08:54
Posts: 11
Post 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.


24 Feb 2012 14:58
Profile
Expert

Joined: 04 Oct 2008 09:49
Posts: 357
Post Re: Wait until application finished
According to Google, xyz.exe is either a virus or a Trojan.
Why are you running a known malware ? :P

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 :-
Quote:
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 :-
Quote:
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


24 Feb 2012 16:04
Profile

Joined: 10 Feb 2012 02:20
Posts: 4331
Post 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.


24 Feb 2012 16:50
Profile

Joined: 12 Sep 2010 08:54
Posts: 11
Post 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.


26 Feb 2012 09:43
Profile

Joined: 12 Sep 2010 08:54
Posts: 11
Post 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...


26 Feb 2012 09:56
Profile

Joined: 10 Feb 2012 02:20
Posts: 4331
Post 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.

Quote:
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?


26 Feb 2012 10:13
Profile
Expert

Joined: 04 Oct 2008 09:49
Posts: 357
Post 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


26 Feb 2012 15:20
Profile
Expert

Joined: 13 Jan 2012 21:24
Posts: 441
Post 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


27 Feb 2012 00:18
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.