Solved

Passing a variable where select * wants a literal, VB6

Posted on 2004-08-11
3
243 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

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

Suggested Solutions

Title # Comments Views Activity
bunnyEars challenge 6 99
array220 challenge 8 56
Controlled Assessment GCSE - desperate help needed 4 75
control image tags in a string ? 12 110
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

919 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