Hi currently I am able to get the process name with the following codes. The process name I wanted to get is EXCEL.EXE but now I want to get the document name eg. data.xlsx.
Is it possible to get the document name from the process ID?
I am currently using VB.net
Dim w As Object
Dim processQ As String
Dim processes As Object
Dim process As Object
w = GetObject("winmgmts:{impersonationLevel=impersonate}\\" & pc & "\root\cimv2")
processQ = "SELECT * FROM win32_process WHERE name = 'EXCEL.EXE'"
processes = w.execquery(processQ)
For Each process In processes
MsgBox(process.processid & process.name)
Next
The code works fine for me to get the process's id and name, but what I want now is the document name instead.
The reason that I'm using win32_process is because later on I want it to be able to retrieve it from remote pc as well.
Any replies will be much appreciated :)
After some digging, I found a code that can display Microsoft Excel.
dim activeprocess as Process = Process.GetProcessById(process.processid)
MsgBox(FileVersionInfo.GetVersionInfo(activeprocess.MainModule.FileName).FileDescription)
but it's still not I wanted