Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

20 Experts available now in Live!

Get 1:1 Help Now