Solved

Passing a variable where select * wants a literal, VB6

Posted on 2004-08-11
3
242 Views
Last Modified: 2012-05-05
Code:

For Each Process In GetObject("winmgmts:").ExecQuery("select * from Win32_Process where
Name='cmd.exe'")
        Process.Terminate
Next

I need to pass a variable to the Name= instead of a literal (here I put cmd.exe).  This should be easy but can't think of the answer. tried this no help:

Name='" & myVar)

0
Comment
Question by:bluedragon99
  • 2
3 Comments
 
LVL 1

Author Comment

by:bluedragon99
ID: 11774876
Need to pass process.name
0
 
LVL 7

Accepted Solution

by:
Tanglin05 earned 500 total points
ID: 11774890
Did you try:

Name='"& myVar &"'")
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 11774938
Perfect!  Thanks for the quick solution.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
This is an explanation of a simple data model to help parse a JSON feed
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 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

18 Experts available now in Live!

Get 1:1 Help Now