Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

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

Posted on 2011-02-18
2
Medium Priority
?
481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

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…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

647 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