
ownership of files and direcotry
You can use WMI to take ownership of a file. The following script,
to.vbs, takes ownership of the file specified on the command line:
'connect to WMI namespace on local machine
Set objServices =
GetObject("winmgmts:{impersonationLevel=impersonate}")
'get a reference to data file
strFile = Wscript.Arguments(0)
Set objFile = objServices.Get("CIM_DataFile.Name='" & strFile & "'")
If objFile.TakeOwnership = 0 Then
Wscript.Echo "File ownership successfully changed"
Else
Wscript.Echo "File ownership transfer operation"
End If
They syntax is:
to.vbs path
So
to.vbs c:\data\report.doc
would attempt to take ownership of the file c:\data\report.doc.
WMI is included with 2000 and XP.
Regards,
Stein Borge
Author of: Managing Enterprise Systems with the Windows Script Host
Over 800 pages of practicle solutions oriented material, providing
detailed coverage of WSH 5.6, WMI, ADSI, ADO, CDO, FSO, Shell and much
more.
www.EnterpriseWSH.com
www.EnterpriseWSH.com/wmi.htm
On Mon, 18 Mar 2002 20:38:34 +0100, "Torsten Keilholz"
Quote:
>Hi,
>i'm search way to set a new owner for a file or an Directory under
>Windows2000 or Windows/XP. i know that i'm must owner of the self group who
>the user that i take the ownership of a file or Directory.
>Has everydoy a tip for me.