Re: Obtain the process id for a given filename
From: Chris \( Val \) (chrisval_at_bigpond.com.au)
Date: 03/24/04
- Next message: Thomas Damgaard: "Re: delete every file or folder in another folder"
- Previous message: Tom Lavedas: "Obtain the process id for a given filename"
- In reply to: Tom Lavedas: "Obtain the process id for a given filename"
- Next in thread: David Wang [Msft]: "Re: Obtain the process id for a given filename"
- Reply: David Wang [Msft]: "Re: Obtain the process id for a given filename"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 25 Mar 2004 01:08:46 +1100
Hi Tom - thanks for the help.
I have seen examples of this previously, but it's not
really what I was looking to do. Perhaps I can explain
what I'm after with some sample code:
Private Function GetPID( ByVal filename As String ) As Long
'
Dim Result As Long
Result = 'Do whatever it takes to get the PID associated
'with the program that has the file locked...
GetPID = Result
'
End Function
Once I get the PID, then I guess the easy part is running
an query on the Win32_Process class, to obtain the Name
property, etc...
It's a VB type function, but I hope it explains better
what I want to do.
Thanks.
Chris Val
"Tom Lavedas" <tlavedas@hotmail.remove.com> wrote in message
news:1291a01c411a7$65aeed70$a401280a@phx.gbl...
| Her's an example of one way that finds all instances of
| running processes that match a supplied name ...
|
| sComputer = "."
| sAppName = "Excel.exe" ' for example
|
| set oWMIService = GetObject("winmgmts:" _
| & "{impersonationLevel=impersonate}!\\" _
| & sComputer & "\root\cimv2")
|
| Set cThreadList = oWMIService.ExecQuery _
| ("Select * from Win32_Process where Name = '" _
| & sAppName & "'",, 48)
|
| For Each oThread in cThreadList
| s = s & oThread.ProcessID & ", "
| Next
| wsh.echo "Process ID(s):", _
| Replace(s & "None Found", ", None Found", "")
|
| Tom Lavedas
| ===========
|
| >-----Original Message-----
| >Hi all - I'm finding it really difficult to find a way
| >to do this (if at all possible ). Does anyone know of
| >a way to obtain the process id of a filename ?
| >
| >Any help appreciated.
| >
| >Cheers.
| >Chris Val
| >.
| >
- Next message: Thomas Damgaard: "Re: delete every file or folder in another folder"
- Previous message: Tom Lavedas: "Obtain the process id for a given filename"
- In reply to: Tom Lavedas: "Obtain the process id for a given filename"
- Next in thread: David Wang [Msft]: "Re: Obtain the process id for a given filename"
- Reply: David Wang [Msft]: "Re: Obtain the process id for a given filename"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|