Re: Changing file permissions using vbscript

From: Roger Abell (mvpNOSpam_at_asu.edu)
Date: 05/16/05


Date: Sun, 15 May 2005 19:11:31 -0700

You, or rather the context your script will run in, may only
take ownership of a file if you have the permission to take
ownership, such as by having Full Control.
The file will be defined with the permissions that are effective
for new files in the location where it is created. Usually the
defining account will already be the owner.
If the file is defined with permissions that allow the context
of the script to do so, then shelling out to exec of cacls is one
most frequently used way to set permissions. There are others,
such as by use of WMI objects, AdsSecurity.dll, and third
party controls.

-- 
Roger Abell
Microsoft MVP (Windows  Security)
MCSE (W2k3,W2k,Nt4)  MCDBA
"SunRace" <SunRace@discussions.microsoft.com> wrote in message
news:CC9AA7DD-B2D8-468D-9275-AA941902B864@microsoft.com...
> Hello,
>
> I am creating a txt file using following script when the user logs in. Now
> what I want to do is take ownership of that file and deny access to all
users
> expect one group - this group will have read access to the file. I want
> domain administrators to have full rights to the file.
>
> ----------------
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objNet = CreateObject("WScript.NetWork")
>
> If NOT objFSO.FileExists("\\advad02\Profiles\Notepads\owner\" +
> objNet.UserName + ".txt") Then
>
> strPath = "\\advad02\Profiles\Notepads\owner\"
> strFileName = objNet.UserName + ".txt"
> strFullName = objFSO.BuildPath(strPath, strFileName)
> Set objFile = objFSO.CreateTextFile(strFullName)
> objFile.Close
>
> End if
>
> ----------------
>


Relevant Pages

  • Re: Changing file permissions using vbscript
    ... > ownership, such as by having Full Control. ... > The file will be defined with the permissions that are effective ... >> I am creating a txt file using following script when the user logs in. ...
    (microsoft.public.security)
  • SUMMARY: partition /
    ... >>Do you know any script or tool to give this information? ... >This will print the size, timestamp, ownership and permissions for ...
    (SunManagers)
  • Re: Can this be fixed by a VBS and how
    ... I got a bit of an issue here that I think using the right script will fix ... The issue is resetting security permissions on a large amount of files in ... anyone unless the logged on user takes ownership of them. ...
    (microsoft.public.windows.server.scripting)
  • Re: Apache problems on FC3?
    ... going to ask if perhaps something in the script was changing the ... what is the ownership of the files in /var/myfolder? ... the permissions on that file, and the directory that owns it? ... Registered Linux User 383030 ...
    (Fedora)
  • RE: user logon script context....
    ... It is not possible to run logon scripts under a different context. ... will require using a password in a script. ... doesn't have permissions itself but runs AT a certain level of access) ...
    (Focus-Microsoft)