DosTips.com

A Forum all about DOS Batch
It is currently 02 Dec 2016 18:19

All times are UTC-06:00




Post new topic  Reply to topic  [ 17 posts ]  Go to page 1 2 Next
Author Message
PostPosted: 23 Feb 2012 15:09 
Offline

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


Top
   
PostPosted: 23 Feb 2012 15:11 
Offline
Expert

Joined: 04 Oct 2008 09:49
Posts: 357
Try
start /WAIT "%~1" C:\Folder\xyz.exe "%~1"

If you need more help try the comand

START /?


Top
   
PostPosted: 23 Feb 2012 16:00 
Offline
Expert

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


Top
   
PostPosted: 23 Feb 2012 16:35 
Offline

Joined: 12 Sep 2010 08:54
Posts: 11
Yes, it is the catch - it just continues waiting even though I terminate xyz.exe.
There may probably not be that simple a solution...


Top
   
PostPosted: 23 Feb 2012 22:46 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 6033
You can probably use the same batch file to start the process, and use it again to kill the process.

(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
)


Top
   
PostPosted: 24 Feb 2012 01:39 
Offline
Expert

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


Top
   
PostPosted: 24 Feb 2012 02:13 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 6033
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. ;)


Top
   
PostPosted: 24 Feb 2012 14:58 
Offline

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


Top
   
PostPosted: 24 Feb 2012 16:04 
Offline
Expert

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


Top
   
PostPosted: 24 Feb 2012 16:50 
Offline
Expert

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


Top
   
PostPosted: 26 Feb 2012 09:43 
Offline

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


Top
   
PostPosted: 26 Feb 2012 09:56 
Offline

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


Top
   
PostPosted: 26 Feb 2012 10:13 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 6033
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?


Top
   
PostPosted: 26 Feb 2012 15:20 
Offline
Expert

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


Top
   
PostPosted: 27 Feb 2012 00:18 
Offline
Expert

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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 17 posts ]  Go to page 1 2 Next

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot] and 8 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited