Link to home
Start Free TrialLog in
Avatar of technicalman
technicalman

asked on

vbscript select * using a variable in a select statement


In the vbscript below, i'm trying to see if I can substitute a variable in the select statement below.  I haven't been able to make it work.  Does anyone know a way?

Thanks
Randy
-----------------------------------------------------------------------------------------------------
strComputer = "."

Dim myprogram
MYPROGRAM = "outlook.exe"  <<<<<<<THIS          


Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = MYPROGRAM") <<<<<<<THIS
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Set colProcesses = objWMIService.ExecQuery _
  ("Select * from Win32_Process Where Name = '" &  MYPROGRAM & "'")

should do it...
Shouldn't have typed "should do it..."
:^ )
yeah, too slow :-)  
Avatar of technicalman
technicalman

ASKER

You guys are Great!  Thanks!