Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , ,

Sponsored Links



How to Change Permission in VBScript

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 09-06-2009
Quattro's Avatar
Member
 
Join Date: May 2008
Posts: 256
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.
Reply With Quote
  #2  
Old 09-06-2009
Shell's Avatar
Member
 
Join Date: Mar 2008
Posts: 233
Re: How to Change Permission in VBScript

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

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

Quote:
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.
Reply With Quote
  #3  
Old 09-06-2009
Member
 
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
Reply With Quote
  #4  
Old 09-06-2009
Member
 
Join Date: Dec 2008
Posts: 161
Re: How to Change Permission in VBScript

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

Quote:
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Change Permission in VBScript"
Thread Thread Starter Forum Replies Last Post
ADMT 3.1 vbscript : ADMT.Migration object creation permission deni Scan le Gentil Active Directory 1 02-12-2009 09:55 PM
need vbscript to pull explicit assigned permission on folder which are not inherited vivekmohan Software Development 2 30-07-2009 06:14 PM
how to pull NTFS security permission in vbscript vivekmohan Software Development 3 25-07-2009 02:28 PM
Microsoft VBScript runtime error: Permission denied: 'GetObject' Swati_here_2008 Software Development 3 05-05-2008 02:57 PM
VBScript runtime error: 800A0046 Permission denied: 'GetObject'" Jerrald Noland Active Directory 6 08-03-2006 02:41 AM


All times are GMT +5.5. The time now is 03:59 AM.