Re: Changing file permissions using vbscript
From: Roger Abell (mvpNOSpam_at_asu.edu)
Date: 05/16/05
- Next message: Joy: "Ad Aware SE"
- Previous message: Jack: "RE: Firewall"
- In reply to: SunRace: "Changing file permissions using vbscript"
- Next in thread: SunRace: "Re: Changing file permissions using vbscript"
- Reply: SunRace: "Re: Changing file permissions using vbscript"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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
>
> ----------------
>
- Next message: Joy: "Ad Aware SE"
- Previous message: Jack: "RE: Firewall"
- In reply to: SunRace: "Changing file permissions using vbscript"
- Next in thread: SunRace: "Re: Changing file permissions using vbscript"
- Reply: SunRace: "Re: Changing file permissions using vbscript"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|