Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Win32::OLE and WMI

by maa (Pilgrim)
on Feb 02, 2004 at 12:33 UTC ( [id://325836]=note: print w/replies, xml ) Need Help??


in reply to Win32::OLE and WMI

Hi, grmm2
I suspect you just need to be more explicit in what you ask WMI for.

Your VB is interpreted as a WQL Where clause. It's unlikely Win32::OLE will interpret it the same way.

If I were you I'd create my WMI handle and use the $wmi->ExecQuery("SELECT * FROM Win32_LogicalFileSecuritySetting WHERE path='d:\\programming'")

HTH - mark

Replies are listed 'Best First'.
Re: Re: Win32::OLE and WMI
by grmm2 (Acolyte) on Feb 02, 2004 at 15:21 UTC
    You mean like this...
    use Win32::OLE; use Data::Dumper; $wmi = Win32::OLE->GetObject('winmgmts:root/cimv2'); $query = 'SELECT * FROM Win32_LogicalFileSecuritySetting WHERE Path="d +:\\\\Programming"'; $resultset = $wmi->ExecQuery($query); foreach $obj (in $resultset) { $rc = $obj->GetSecurityDescriptor($sec); print "Path=[$obj->{Path}] rc=[$rc]\n"; print Data::Dumper->Dump([$sec], [qw(*sec)]); }
    No luck there either, I'm afraid :-( The output from the above code is...
    Path=[d:\Programming] rc=[0] $sec = undef;

      I tried this... but it just hangs!

      my $stuff =Win32::OLE->GetObject( "WinMgmts:!Win32_LogicalFileSecuritySetting.path='C:\\\\TEMP'" );
      I'll be interested to see what the final solution is!

      Note: The VBScript Example from MSDN hangs on my PC too. NT4 SP6a. Weird

        I've not seen that syntax before (ie. with a shriek after WinMgmts: and before Win32).

        I know its heresy, but my only option at the moment seems to be using the vbs code. It works fine. If I ever get the perl code to work I'll let you know.

        PS. Try this vbs and see if it hangs...

        a = ShowPermissions("computer","sharename") Function ShowPermissions(ComputerName,ExplicitPath) Set objSecurity = GetObject("winmgmts:{(Security,Restore)}\\" & Co +mputerName & _ "\root\cimv2:Win32_LogicalShareSecuritySetting='" & ExplicitPa +th & "'") If objSecurity.GetSecurityDescriptor(objSD) = 0 Then For Each objACE in objSD.DACL wscript.Echo objACE.Trustee.Domain, objACE.Trustee.Name PermissionBitMask = objACE.AccessMask Select Case PermissionBitMask Case 1179817 wscript.Echo "Read" Case 1245631 wscript.Echo "Modify" Case 2032127 wscript.Echo "Full" Case Else wscript.Echo "Other: " & PermissionBitMask End Select Next End If End Function

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://325836]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-25 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found