By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,286 Members | 2,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,286 IT Pros & Developers. It's quick & easy.

VB Script to Find a Random File's process

P: 31
Hey all,

I have a folder with a file in it. That file is open via some process. Using a .vbs script, I can find that file, using:

Expand|Select|Wrap|Line Numbers
  1. set myclose = GetObject(filepathname)
  2. myclose.close
to close said file. But this leaves the process running that file open in the task manager. I can do
Expand|Select|Wrap|Line Numbers
  1. myapp = myclose.Application 
to get the application running that file. I can use
Expand|Select|Wrap|Line Numbers
  1. .ExecQuery _
  2. ("Select * from Win32_Process WHERE Name = 'process.exe'")
to kill a process.

But how do I find the process running a dynamic file?

I've tried myclose.Process, .Title...can't seem to find what a given object's process is.

I'm TRYING to avoid populating the script with case statements translating process based on file extension.

The file in this folder could be any type, and I won't know it ahead of time. ={
May 11 '16 #1
Share this Question
Share on Google+
2 Replies

P: 31
As a follow up, I can go to Windows Task Manager, view the file's task n Applications tab, Right Click-->Go To Process, and it takes me to the Process where I can see Image Name, Description. Process Description LOOKS like object's .Application.

Maybe I can udpate my .ExecQuery with a [WHERE Description = '" & my app &"'"]?
May 11 '16 #2

P: 31
Cancel that. Process Description <> necessarily = an object's .Application.

There's GOT to be a way to automate this.
May 11 '16 #3

Post your reply

Sign in to post your reply or Sign up for a free account.