Reputation: 309
I have this code (not just this, but thats the part with the problem)
Dim objWMI : Set objWMI = GetObject("winmgmts:\\.\root")
Dim objSecuritySettings : Set objSecuritySettings = objWMI.Get("__SystemSecurity=@")
Dim objSD : objSecuritySettings.GetSecurityDescriptor(objSD)
Why am I not getting the objSD ?
If I run the script it returns an error when I try to use objSD.DACL
or something like that:
Object not found!
So whats my mistake ?
Something else what´s strange is, if I run it like this:
Dim objSD : objSecuritySettings.GetSecurityDescriptor objSD
It works on Win7 .... but not on server 2003 or 2012.
EDIT:
I tested it on WinServer 2008 and it works perfectly ( like on Win7) .... so why not on 03 and 12 ?
Upvotes: 0
Views: 208
Reputation: 30153
I can't document the behaviour competently here (google for msdn "Scripting Security Descriptors - Microsoft"
, download the first DOC
found):
option explicit
Dim iSD, intRet
Dim objWMI : Set objWMI = GetObject("winmgmts:\\.\root")
Dim objSecuritySettings : Set objSecuritySettings = objWMI.Get("__SystemSecurity=@")
Dim objSD : objSecuritySettings.GetSecurityDescriptor(objSD)
Dim objSDa : intRet = objSecuritySettings.GetSecurityDescriptor(objSDa)
Dim objSDx : objSecuritySettings.GetSecurityDescriptor objSDx
Wscript.Echo "objSecuritySettings" _
, VarType(objSecuritySettings), TypeName(objSecuritySettings) _
, vbNewLine, "objSD ", VarType(objSD) , TypeName(objSD) _
, vbNewLine, "objSDa", VarType(objSDa), TypeName(objSDa), intRet _
, vbNewLine, "objSDx", VarType(objSDx), TypeName(objSDx)
Output
==>cscript D:\VB_scripts\SO\31512037.vbs
objSecuritySettings 9 SWbemObjectEx
objSD 0 Empty
objSDa 9 SWbemObjectEx 0
objSDx 9 SWbemObjectEx
==>
Upvotes: 0