Solved

Need to get the full path of a file in visual basic 6

Posted on 2011-02-18
2
466 Views
Last Modified: 2012-05-11
I use a vb script in Visual Basic that calls win32_process and returns a list of processes. I use the executablePath property to get the process path. However, some processes do not return with a path. It seems that Windows knows where they are at since they are located within the "path" variable. For example, presentationfontcache.exe is located in
C:\WINDOWS\Microsoft.NET\Framework\v3.0\WPF and the Windows folder is in the path variable.
So the question is, if I only know the process name such as presentationfontcache.exe how do I quickly get it's full path? The reason I need the full path is because I need my program to output all processes and their full paths to make sure they are not viruses.
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process")


msgbox colProcess.count
For Each objProcess in colProcess
	msgbox objProcess.name & vbcrlf & objProcess.ExecutablePath
Next

Open in new window

0
Comment
Question by:advcom
2 Comments
 
LVL 7

Accepted Solution

by:
kemi67 earned 500 total points
ID: 34924454
You have to add even the (Debug) impersonation level. That is:
 
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Debug)}!\\" & "." & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process")


msgbox colProcess.count
For Each objProcess in colProcess
	msgbox objProcess.name & vbcrlf & objProcess.ExecutablePath
Next

Open in new window

0
 

Author Closing Comment

by:advcom
ID: 34924526
worked perfectly, thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question