Hi Folks,

I am trying to write a VBScript to set Modify permission on a file for Users Group. However, I have not been able to figure out what's going wrong with the Script. Below is the Script I have. Any help will be appreciated. Thanks is advance.

On Error Resume Next

Dim sAllUsersAppData

Set objShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

sAllUsersAppData = objShell.ExpandEnvironmentStrings("%ProgramData%")

strFile = sAllUsersAppData & "\Folder1\Folder2\Folder3\File.ini"
strNTGroup = "Users"
If fso.FileExists(strFile)=true Then
objShell.Run "%COMSPEC% /c cacls " & strFile & " /T /E /G " & strNTGroup & ":C", 0, True
End If




Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

1
If objFSO.FileExists(strFile) Then
objShell.Run "%COMSPEC% /c cacls """ & strFile & """ /T /E /G " & strNTGroup & ":C", 0, True
End If
Answered 01/16/2015 by: jagadeish
Red Belt

Please log in to comment

Answers

0
Hello,

Maybe this will help you :

The CACLS command does not provide a /Y switch to automatically answer 'Y' to the Y/N prompt. However, you can pipe the 'Y' character into the CACLS command using ECHO, use the following syntax:
ECHO Y| CACLS filename /g username:permission


It seems "cacls.exe"  is not recommand for windows 7 . You should be try with "setacl.exe" or "xcals.vbs".

Regards
Answered 01/16/2015 by: egiberne
Second Degree Brown Belt

Please log in to comment
0
Did you have look in making a powershell script?
This stuff is build in, not great, but to improve that there is a Powershell NTFS module.
Perhaps more powerful then VBscript.
Just google and there are a lot examples.
Answered 01/16/2015 by: dedenker
Third Degree Black Belt

  • Hi,
    I actually wanted to have PowerShell to get this, however, i am fairly new for PowerShell Script.

    Any link would be great!
    • https://gallery.technet.microsoft.com/scriptcenter/1abd77a5-9c0b-4a2b-acef-90dbb2b84e85
      Is one I talked about.
      Then one of the example's you can use.
      And about Powershell, is it nothing special if you have some scripting experience.
      And lots of info pages if you start from zero.
      Take a look here: http://ss64.com/ps/
Please log in to comment
0
Firstly, please use the 'Code' style when posting code.

Secondly, there is a nice VBS class file authored internally within Microsoft which you'll find useful if you want to stick with VBS. It will obviously give you a lot more control over error-trapping and error reporting which is way too convoluted to do with command-line tools like CACLS, SetACL etc.
Answered 01/16/2015 by: VBScab
Red Belt

Please log in to comment
0
If objFSO.FileExists(strFile) Then
objShell.Run "%COMSPEC% /c cacls """ & strFile & """ /T /E /G " & strNTGroup & ":C", 0, True
End If
Answered 01/16/2015 by: jagadeish
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity