ownership of files and direcotry 
Author Message
 ownership of files and direcotry

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.



Sat, 04 Sep 2004 03:38:34 GMT  
 ownership of files and direcotry

Asked and answered in microsoft.public.inetsdk.programming.scripting.VBScript...

<TIP type=friendly topic=Multiposting is Not a Good Thing>

If you need to post a question to more than one newsgroup, please crosspost(send
to more than one group at once) instead of multiposting (remailing the same
message to multiple groups).  This ties threads together, making it easier for
both responders and you to see whether your question was answered and what the
answers were.

</TIP>

--
torgeir



Sat, 04 Sep 2004 08:41:53 GMT  
 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.



Sat, 04 Sep 2004 10:55:27 GMT  
 ownership of files and direcotry

Quote:

> 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:

Can you use WMI on a file, to not take, but give ownership to another user?

--
torgeir



Sat, 04 Sep 2004 11:32:03 GMT  
 ownership of files and direcotry

Quote:


> > 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:

> Can you use WMI on a file, to not take, but give ownership to another user?

> --
> torgeir

Windows does not support this feature (otherwise I could deny them dirty
pictures being mine;), therefore I doubt it is implemented through WMI.

Branimir



Sat, 04 Sep 2004 12:54:39 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. ownership of files and direcotry

2. Filling a combo box with a list of files in a direcotry at run time

3. ACC97 OS level File Ownership

4. Taking file ownership (NT4 + NTFS)

5. Determining file ownership

6. Visual basic and NT file ownership

7. How to Read File Ownership on NTFS

8. Taking file ownership (NT4 + NTFS)

9. Take ownership of a file

10. file ownership from Novell volumes

11. disk quotas and files ownership

12. File Ownership

 

 
Powered by phpBB® Forum Software