You won't get your results because your query is wrong. Is there a property Cation? Shouldn't it be Caption?

On Fri, Jan 29, 2010 at 11:20 AM, Simon Mbuthia <simon.mbuthia@gmail.com> wrote:
If the error had been to do with my having used a wrong class/object, then I wouldn't be getting a permission denied error. Running it on another PC would give results because I wrote this script last year and it was working, until I reinstalled Windows on my PC. So I am sure the code is OK.

In case VBS is a problem, here is the same code in JScript:

ListCOM( "." );


function ListCOM( computer )
{
    var wmistr = "winmgmts:{impersonationLevel=impersonate}!\\\\";
    wmistr += computer + "\\root\\cimv2";

    var objWMIService = GetObject( wmistr );

    var query = "SELECT * FROM Win32_ClassicCOMClassSetting where Cation like 'Datac%'"; 
    var ClassCollection = objWMIService.ExecQuery( query );

    var ecom = new Enumerator( ClassCollection );
    for( ; !ecom.atEnd(); ecom.moveNext() )
    {
        var icom = ecom.item();
        print( "Name        : " + icom.Caption );
        print( "Path        : " + icom.InprocServer32 + "\n" );
    }
}


function print( msg )
{
     WScript.Echo( msg );
}

This time, I don't get an error message, but I don't get results either.

On 29 January 2010 10:27, aki <aki275@googlemail.com> wrote:


On Fri, Jan 29, 2010 at 10:12 AM, aki <aki275@googlemail.com> wrote:
On Fri, Jan 29, 2010 at 7:50 AM, Simon Mbuthia <simon.mbuthia@gmail.com> wrote:
@RAd Yes, it is
@aki, The problem is not with the syntax, but smething to do with permissions. The code is OK because scriptomatic-generated scripts [google scriptomatic] aren't generating any output. Besides, Win32_.... is a collection of objects from which I want to select the ones that begin with 'Datac'. Once I get a list of those objects, then I get attributes of each of those objects such as Name.. etc. Does that make sense?

 
@Simon, I checked sdk and still cannot find the object you are looking for. What class/object is ' datac ' under? WMI query has 494 classes.  :-)

Further to this, an example that I was working on last year : to enable auto DHCP ( execute WMI )
 
- Class = Win_32NetworkAdapterConfiguration  ( has 41 methods and each method has parameters you can assign )
- Method = "EnableDHCP"
- Instance = index of NIC cards/DUN/PPP, thus code the correct index number.
 
usual for-each loop.....
 
foreach(<variable> in <object>)
{
//statement
}
 
Result : When code script was run, it would enable DHCP.
 
Corrections welcome...
 
 
 




--
Be kind to your dentist - he has fillings too...

_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1fbjAwOUE&hl=en
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
Other lists
-------------
Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce
Science:  http://lists.my.co.ke/cgi-bin/mailman/listinfo/science
kazi:     http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general