Results 1 to 4 of 4

Thread: How to Change Permission in VBScript

  1. #1
    Join Date
    May 2008
    Posts
    255

    How to Change Permission in VBScript

    I have some files of which security permissions have set for "no access" to everyone and i wanted to remove those permission and to allow "read only" permission on each temp folder, and could we apply this to the number of computer, such as I have 20 to 25 computer in each workgroup, and am trying to give this permission with the help of VBscript.... please suggest your opinion.

  2. #2
    Join Date
    Mar 2008
    Posts
    232

    Re: How to Change Permission in VBScript

    The following Xcacls.vbs are the VBScript commands that provide some examples of Xcacls.vbs usage.

    xcacls.vbs c:\test\ /g domain\testuser1:f /f /t /e
    This command edits existing permissions. It grants Domain\TestUser1 full control on all files under C:\Test, it traverses subfolders under C:\Test, and then it changes any files that are found. This command does not touch directories.

    xcacls.vbs c:\test\ /g domain\testuser1:f /s /l "c:\xcacls.log"
    This command replaces existing permissions. It grants Domain\TestUser1 full control on all subfolders under C:\Test, and it logs to C:\Xcacls.log. This command does not touch files, and it does not traverse directories.
    xcacls.vbs c:\test\readme.txt /o "machinea\group1". This command changes the owner of Readme.txt to be the group MachineA\Group1.

  3. #3
    Join Date
    Oct 2008
    Posts
    167

    Re: How to Change Permission in VBScript

    It is not that hard for VBScript which grant permissions on folder/file NTFS formatted drive. You Just need to modify/tweak the script as per the requirements and follow various options available with CACLS.

    Code:
    This script will assign Modify/C-Change (write) Permission To Power User on "C:\MyFolder" using cacls on NTFS formatted drive
    
    Dim oShell, FoldPerm, Calcds, oFSO
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oShell = CreateObject("WScript.Shell")
    
    sSysDir = oFSO.GetSpecialFolder(1).Path
    If Right(sSysDir,1) <> "\" Then sSysDir = sSysDir & "\"
    
    Calcds = sSysDir & "cacls.exe" 
    
    'Chang The folder Name, User and Access rights in the following line of code  
    
    FoldPerm = """" & Calcds &"""" & """C:\MyFolder""" & " /E /T /C /G " & """Power Users""" & ":C" 
    
    oShell.Run FoldPerm, 1 ,True

  4. #4
    Join Date
    Dec 2008
    Posts
    161

    Re: How to Change Permission in VBScript

    xcacls.vbs \\servera\sharez\testpage.htm /p "domain\group2":14
    This command remotely connects to \\ServerA\ShareZ by using Windows Management Instrumentation (WMI). It then obtains the local path for that share, and under that path, it changes the permissions on Testpage.htm. It leaves the existing permissions of Domain\Group2 intact, but it adds permissions 1 (read data) and 4 (read extended attributes). The command drops other permissions on the file because the /e switch was not used.

    xcacls.vbs d:\default.htm /g "domain\group2":f /server servera /user servera\admin /pass password /e
    This command uses WMI to remotely connect as ServerA\Admin to ServerA and then grants full permissions on Default.htm to Domain\Group2. Existing permissions for Domain\Group2 are lost and other permissions on the file

Similar Threads

  1. Replies: 2
    Last Post: 30-07-2009, 05:14 PM
  2. how to pull NTFS security permission in vbscript
    By vivekmohan in forum Software Development
    Replies: 3
    Last Post: 25-07-2009, 01:28 PM
  3. How to change IE proxy using VBscript
    By Harshini in forum Software Development
    Replies: 2
    Last Post: 27-04-2009, 11:55 PM
  4. Microsoft VBScript runtime error: Permission denied: 'GetObject'
    By Swati_here_2008 in forum Software Development
    Replies: 3
    Last Post: 05-05-2008, 01:57 PM
  5. Replies: 3
    Last Post: 08-03-2006, 02:41 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,127,792.87754 seconds with 17 queries