Alan said:
Thanks Roger - that solved the problem. Is there a non-
safe mode solution for XP Home to save me booting to safe
mode?
Hi
Try this:
Create a file called GetOwner.vbs containing the script below and
create a shortcut to it in the SendTo folder (or just put the file
itself in the SendTo folder, but then you will see the .vbs extension,
at least if you have set Explorer to show file extensions).
This way, you can select one or several files in Explorer, right click
on them and use the SendTo selection GetOwner. If you want to get the
result into the clipboard, just press Ctrl+C on the dialog box.
To open the SendTo folder, run this from the Start\Run menu (include
the quotes!):
"%USERPROFILE%\SendTo"
GetOwner.vbs:
'--------------------8<----------------------
Set oArgs = WScript.Arguments
If oArgs.Count = 0 Then
MsgBox "Error: You need to supply one or more file name(s) " _
& "as input parameter(s)!", vbSystemModal, "GetOwner"
Wscript.Quit
End If
sStr = "<file>: <owner>" & vbCrLf
For i = 0 To oArgs.Count - 1
sStr = sStr & oArgs(i) & ": " _
& GetOwner(oArgs(i)) & vbCrLf
Next
WScript.Echo sStr
If InStr(1, WScript.FullName, "cscript.exe", vbTextCompare) > 0 Then
MsgBox "Finished", vbSystemModal, "GetOwner"
End If
Function GetOwner(sFile)
sComputer = "."
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
On Error Resume Next
Set oCollection = oWMI.ExecQuery _
("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & sFile _
& "'} WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")
For Each oSID in oCollection
GetOwner = oSID.AccountName
Next
If VarType(GetOwner) = 0 Then
GetOwner = "error"
End If
End Function
'--------------------8<----------------------
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx