Solved

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

Posted on 2011-02-18
2
464 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now