[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-02-18
2
Medium Priority
?
484 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

810 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