this is a very basic program I wanted to write a VB script which I’ll call from command line and pass in a few parameters, and the VB script should take the parameters and query some information from WMI, the code is like this:
1.strProperty = colNamedArguments.Item("Property") //this is to store the parameter
2.str..... some other parameters
3.Set objSWbemServices = GetObject("winmgmts:\\" & strComputer & strNamespace)
4.Set colSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass)
5.For Each objSWbemObject In colSWbemObjectSet
6. wscript.echo objSWbemObject.strProperty
1 and 2. is to store the parameter 3.is to connect to the WMI 4.is to query the data needed 5 and 6.is to run through the collected data and print them out. The problem I have is that when I run the script with the correct parameters it prints out nothing, but if I replace the strProperty in line 5 with actual parameter I passed with command it works, and to test if the parameter is passing properly I have add lines of codes to print it out soon as it gets the parameter that worked. I think the line 5 is using the “strProperty” as the property to match the data but not the string value of the strProperty.
If you really want what I gather from your description (access a property specified at runtime), this
output:
or:
should get you started: use the Properties_ ‘dictionary’ of the item.