Use VBA to kill a specific Access process (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,314
You are not showing the window title? :(
I have just run it again on my PC and now have

(2) Use VBA to kill a specific Access process | Access World Forums - Vi

So if I was searching for this thread in my browser pages, I could delete this instance of it.?
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
Nothing attached.? :(

Use as Doc advises
Code:
tasklist /v > c:\temp\tasklist.txt ' assuming you have a c:\temp
to see what windows you have. Obviously have some access DBs open before you do that. Then you can see what the windows are called.?

Look at the options for either tasklist or taskkill with the /? parameter
I issue the commands from a command window?
The file is attached in post #11 of this thread
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
You are not showing the window title? :(
I have just run it again on my PC and now have

(2) Use VBA to kill a specific Access process | Access World Forums - Vi

So if I was searching for this thread in my browser pages, I could delete this instance of it.?
Please look at post #11 for the attached file. Is it this what you mean by Windows title?

In post #14 you mention
"
I'd be just deleting the process using the window title, less hassle?

In fact before this thread, I di not have a clue as how to do it, now I do. :)
"
Can you share what you did.

In your post #21, I never said the Windows title was showing and I do not understand what you mean by
"I have just run it again on my PC and now have"

Also, if I use VBA to kill, this means that I need to run yet another Access session.
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,314
I found out what the window titles were? You can do that by looking at the access window title bar, or with any process using tasklist.
So if you had 3 access sessions going with names like
Sales
Production
Admin
and you were actually in admin and wanted to kill Sales, the use tasklist to kill Sales.
However if you are in Admin, then you could just as easy used @arnelgp 's code ?

I ran the tasklist again withe the relevant parameters, then opened the output and searched for access, and the first access word I found was this thread in the browser?

Post 11 is a pic from task manager, is it not?, not what we are talking about at all?
We are talking about commands task list and taskkill.
The output from tasklist is more informative if you use the correct options?
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
I found out what the window titles were? You can do that by looking at the access window title bar, or with any process using tasklist.
So if you had 3 access sessions going with names like
Sales
Production
Admin
and you were actually in admin and wanted to kill Sales, the use tasklist to kill Sales.
However if you are in Admin, then you could just as easy used @arnelgp 's code ?

I ran the tasklist again withe the relevant parameters, then opened the output and searched for access, and the first access word I found was this thread in the browser?

Post 11 is a pic from task manager, is it not?, not what we are talking about at all?
We are talking about commands task list and taskkill.
The output from tasklist is more informative if you use the correct options?
Gasman, many thanks for your message above. I am trying to understand what you are saying.
"I found out what the window titles were?" Is this a question? You seem to use the "?" even when it is not a question.
"You can do that by looking at the access window title bar, or with any process using tasklist" Can you please indicate what you mean by the first statement or the second statement?
"and you were actually in admin and wanted to kill Sales, the use tasklist to kill Sales." Can you please indicate what you mean.
"I ran the tasklist again withe the relevant parameters, then opened the output and searched for access, and the first access word I found was this thread in the browser?" Can you please indicate what you did?
"Post 11 is a pic from task manager, is it not?, not what we are talking about at all?" Yes it is from Task Manager and was asking whether that is the Title you are referring to.
"The output from tasklist is more informative if you use the correct options?" Can you please indicate which options?

The problem is that there is no clear indication of what you mean by Windows Title and how to obtain it.
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,314
At the top of each window is normally a title bar?
In that it shows some text that indicates what the window is about?
I am on my phone in the hospital grounds atm, but when I ran it at home, the text that was in my browser title bar was displayed with tasklist.
As doc advised, use tasklist /? to see all the options. One is verbose, which means it gives you more information.

Open a few of your dbs, and report back what you see in the title bar of each window.
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
At the top of each window is normally a title bar?
In that it shows some text that indicates what the window is about?
I am on my phone in the hospital grounds atm, but when I ran it at home, the text that was in my browser title bar was displayed with tasklist.
As doc advised, use tasklist /? to see all the options. One is verbose, which means it gives you more information.

Open a few of your dbs, and report back what you see in the title bar of each window.
In dbs 1 and 2 which I mention above I see what appears as the first picture of this attachment.

In db 3 which I mention above I see what appears as the second picture of this attachment. Is this what you refer to as Windows title? Remember the “24” which appears in the attachment of post #11.

It would help if you indicate in an attachment, what you mean by Windows Title.
 

Attachments

  • Databases.pdf
    76.7 KB · Views: 116

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,314
Yes, they are window titles, or appear to be. Most people give the application a name :(

That is what I meant by Sales, Production and Admin
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
To amplify this, I frequently used a shell command to find some information by dumping output to a file and then reading it, because such files are frequently fixed-format output (essentially, constant columns) so extracting data from them is just a MID$ function call. Thus, you just run the command, read the file one line at a time until you find what you want, then do your thing to the task in question, delete that output file, and you are done. Tedious, but easily managed with VBA if you figure out the right command for SHELL to operate.

Note the section in this reference that discusses asynchronous commands, because that will apply to my suggestion. There is a link in the paragraph on async operation that might help you figure out how to wait for the shell command to finish.

Many thanks for your input. It has been very practical and useful.

To this point I have been unable to identify a specific Access session.

I have opened 3 Access sessions, the first 2 of the same Access program and the third session of another Access program. The output is indicated in post #20. There is no way to identify which is which. Can you assist?
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
Yes, they are window titles, or appear to be. Most people give the application a name :(

That is what I meant by Sales, Production and Admin
The titles do not appear in the Tasklist. Is there any other way to obtain the titles?
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,314
Show what you have for those DBs in options.
Here is mine form my Commissions DB

Do not put all into a PDF, paste them direct to thread. I do not want to have to download files all the time, just to see a picture. :(

If you do not have a window title, then I do not see how you can tell what is what?

1644836391315.png

1644836446889.png
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
You refer in a general manner to "Window Title", whereas what you mean is "Application Title".

In my case the Application Title changes based on the client using it and the form that the client is in.

In any case, how would you close your Access session with Application Title "Commissions & Fees"?

Per your request I include below the screenshots from my applications

1644844300719.png


1644844310470.png
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:47
Joined
Feb 28, 2001
Messages
27,192
Many thanks for your input. It has been very practical and useful.

To this point I have been unable to identify a specific Access session.

I have opened 3 Access sessions, the first 2 of the same Access program and the third session of another Access program. The output is indicated in post #20. There is no way to identify which is which. Can you assist?

Look into using the OPENFILES command (also a SHELL situation) - but note that you might have to do a registry operation to do so. This would list the files open by a specific task, and that might be what you need. That is, the opened file tells you the right task.
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,314
You refer in a general manner to "Window Title", whereas what you mean is "Application Title".

In my case the Application Title changes based on the client using it and the form that the client is in.

In any case, how would you close your Access session with Application Title "Commissions & Fees"?

Per your request I include below the screenshots from my applications

View attachment 98242

View attachment 98243
Well that explains where the 24 came from in task manager? However if you open two copies of it, as you seemed to do, how are you meant to know which is which.
No I mean window title that just happens to be access application title as well.:(
The last title I posted was from a vivaldi browser.
Open a few excel wookbooks and see what the window title is for those.
We appear to be nit picking here, so I will bow out and let more experienced members help.
At least I have learnt something out of this thread.:)
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
Well that explains where the 24 came from in task manager? However if you open two copies of it, as you seemed to do, how are you meant to know which is which.
No I mean window title that just happens to be access application title as well.:(
The last title I posted was from a vivaldi browser.
Open a few excel wookbooks and see what the window title is for those.
We appear to be nit picking here, so I will bow out and let more experienced members help.
At least I have learnt something out of this thread.:)
Many thanks for your help, but you did not comment on how you would close your Access session with Application Title "Commissions & Fees"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:47
Joined
Oct 29, 2018
Messages
21,474
Gasman many thanks.

I ran on the same pc, 3 Access sessions (using the A13 runtime) and the result of the command you suggested is indicated in the attachment.

The first 2 instances of ACCESS.EXE belong to the same software and the third instance to a different software.

I cannot see any information that would identify either the first 2 sessions or the 3rd session. All 3 appear the same and I would like to be able to identify either the first 2 or the 3rd sessions and kill a problematic session.
What was the tasklist argument you used? Did you use WINDOWTITLE?

Edit: Oops, sorry. I didn't realize there were more posts after the one I responded to. Cheers!
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
What was the tasklist argument you used? Did you use WINDOWTITLE?

Edit: Oops, sorry. I didn't realize there were more posts after the one I responded to. Cheers!
Something like the following would list the Window Titles

TASKLIST /v /fo list |find /i "window title" |find /v "N/A"
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,314
Many thanks for your help, but you did not comment on how you would close your Access session with Application Title "Commissions & Fees"
I would use the window title with TaskKill
I could even use Commis* as long as no other window title satisfied that criteria
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
Something like the following would list the Window Titles

TASKLIST /v /fo list |find /i "window title" |find /v "N/A"
And this would save it to

TASKLIST /v /fo list |find /i "window title" |find /v "N/A" > c:\junk\tasklist.txt

In my software package, every client has a client number which appears as the title. I can make sure that only this number appears as the Application/Window Title and I just need to figure out how to kill this.
 

JohnPapa

Registered User.
Local time
Today, 20:47
Joined
Aug 15, 2010
Messages
954
And this would save it to

TASKLIST /v /fo list |find /i "window title" |find /v "N/A" > c:\junk\tasklist.txt

In my software package, every client has a client number which appears as the title. I can make sure that only this number appears as the Application/Window Title and I just need to figure out how to kill this.
The following lists the PID as well

tasklist /v /fi "PID gt 0" /fo csv

So I can output to a file, read the file and kill the PID

Thanks to all of you for your assistance.
 

Users who are viewing this thread

Top Bottom