Click here to Skip to main content
15,896,288 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: vb Pin
Dave Kreskowiak27-Sep-14 6:47
mveDave Kreskowiak27-Sep-14 6:47 
QuestionRecommendations on VB.Net to C# code conversion tool Pin
Vipul Mehta26-Sep-14 10:28
Vipul Mehta26-Sep-14 10:28 
AnswerRe: Recommendations on VB.Net to C# code conversion tool Pin
Tim Carmichael26-Sep-14 11:24
Tim Carmichael26-Sep-14 11:24 
GeneralRe: Recommendations on VB.Net to C# code conversion tool Pin
Vipul Mehta27-Sep-14 3:21
Vipul Mehta27-Sep-14 3:21 
QuestionFormatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Member 1111259726-Sep-14 7:29
Member 1111259726-Sep-14 7:29 
AnswerRe: Formatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Chris Quinn28-Sep-14 21:15
Chris Quinn28-Sep-14 21:15 
GeneralRe: Formatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Member 1111259729-Sep-14 7:10
Member 1111259729-Sep-14 7:10 
Questionicacls vbscript - disabling inheritance and removing permissions a security group Pin
Chris Cooper26-Sep-14 3:17
Chris Cooper26-Sep-14 3:17 
Hi all,

I have been working on a script to do what the subject line says but I'm really not getting anywhere. I feel as though I'm almost there, but I just can't figure out the last part.

My script is as follows:

VB
Option Explicit

'Declare Variables
Dim strProjectsFolder, strProjectNumber, strCostingsPath, strProjectsLTDGroup

'Set Variables
strProjectsFolder = "\\ac1fpcov01.za.if.atcsg.net\Business\Delegation IT\Projects\"
strProjectNumber = InputBox("Please enter the new Project Number", "Project Number")
strCostingsPath = strProjectsFolder & strProjectNumber & "\02. Costing"
strProjectsLTDGroup = "AC1-LS-Finance SSC"

SetPermissions

Function SetPermissions()
    Dim intRunError, objShell, objFSO

    Set objShell = CreateObject("Wscript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    If objFSO.FolderExists(strCostingsPath) Then
        WScript.Echo "You're changing the permissions on " & strCostingsPath
'Remove inheritance from subfolders and files
        intRunError = objShell.Run ("%COMSPEC% /c Echo Y| ICACLS.EXE " & strCostingsPath & " /inheritance:d /remove:g AC1-LS-Finance SSC:(OI)(CI) ", 2, True)
        If intRunError <> 0 Then
            Wscript.Echo "Error removing inheritance from " & strCostingsPath
        End If
'Remove all permissions granted to the group
        'intRunError = objShell.Run ("ICACLS.EXE " & strCostingsPath & " /T /remove:g strProjectsLTDGroup ", 2 True)
        'If intRunError <> 0 Then
            'Wscript.Echo "Error removing permissions for" & strProjectsLTDGroup " from " & strCostingsPath
        'End If
        Else
            WScript.Echo "Error: Project Folder " & strProjectNumber & " does not exist."
    End If
End Function

WScript.Quit


I've REMd some lines to simplify while I debug, so I'm currently focusing on the removal of inheritance. I figured if I got that bit right I could move onto the removal of permissions, either in a second IF statement or in the same command line.

But basically, what the script is doing is:
1. Ask the user for the Project number (e.g. P33333)
2. Set variables for the file / folder location based on the project folder on the server
3. Check that the project folder exists, and show a message with the subfolder on which the permissions are being changed.
4. Run the ICACLS command with the /inheritanceBig Grin | :-D /T switch to disable inheritance on the project subfolder and all subfolders and files.
5. I've included inRunError to capture any errors, and added another IF statement to show which part of the script is showing the error (only the inheritance section is active at the moment).
6. Finally, an Error trap in case the project folder was entered incorrectly.

Run the script, and all I get is the inRunError that the inheritance command isn't working.

I've taken the exact same command and entered it into a bat file and it works perfectly fine. But in a script it fails every time. I've tried taking all the variables out and working with a skeleton script and still nothing.

So it leads me to believe that I'm either trying to do something with the command that isn't possible, or vbscript just doesn't like me.

Any help would be greatly appreciated.

Thanks

Chris

PS. I should also add, clearly the folder is on a network location. My user account does already have full control permissions over the folder.

It is also an AD security group that I am changing the permissions of in the second part of the script, again it works as-is in a bat file, but not in the script.
AnswerRe: icacls vbscript - disabling inheritance and removing permissions a security group Pin
Eddy Vluggen26-Sep-14 6:03
professionalEddy Vluggen26-Sep-14 6:03 
QuestionPloting xy grapgh on VB Pin
Member 1051522523-Sep-14 20:31
professionalMember 1051522523-Sep-14 20:31 
QuestionMore than 1 barcode reader in one pc Pin
Member 380289623-Sep-14 19:19
Member 380289623-Sep-14 19:19 
AnswerRe: More than 1 barcode reader in one pc Pin
Bernhard Hiller23-Sep-14 22:01
Bernhard Hiller23-Sep-14 22:01 
AnswerRe: More than 1 barcode reader in one pc Pin
Tino Fourie24-Sep-14 6:40
Tino Fourie24-Sep-14 6:40 
AnswerRe: More than 1 barcode reader in one pc Pin
ZurdoDev24-Sep-14 10:07
professionalZurdoDev24-Sep-14 10:07 
QuestionTextBox Validation Pin
Benniiit23-Sep-14 7:09
Benniiit23-Sep-14 7:09 
AnswerRe: TextBox Validation Pin
JR21223-Sep-14 21:18
JR21223-Sep-14 21:18 
QuestionRemove double spaces in a textbox on keypress Pin
Benniiit20-Sep-14 3:10
Benniiit20-Sep-14 3:10 
AnswerRe: Remove double spaces in a textbox on keypress Pin
Bernhard Hiller21-Sep-14 21:43
Bernhard Hiller21-Sep-14 21:43 
AnswerRe: Remove double spaces in a textbox on keypress Pin
Mycroft Holmes21-Sep-14 22:28
professionalMycroft Holmes21-Sep-14 22:28 
QuestionMultiline text box manipulating Pin
Member 1109601819-Sep-14 17:58
Member 1109601819-Sep-14 17:58 
SuggestionRe: Multiline text box manipulating Pin
Richard MacCutchan19-Sep-14 21:22
mveRichard MacCutchan19-Sep-14 21:22 
GeneralRe: Multiline text box manipulating Pin
Member 1109601819-Sep-14 22:17
Member 1109601819-Sep-14 22:17 
QuestionDirectx 11 and vb6.0 or .net Pin
Otekpo Emmanuel19-Sep-14 12:17
Otekpo Emmanuel19-Sep-14 12:17 
SuggestionRe: Directx 11 and vb6.0 or .net Pin
Richard MacCutchan19-Sep-14 21:24
mveRichard MacCutchan19-Sep-14 21:24 
AnswerRe: Directx 11 and vb6.0 or .net Pin
Dave Kreskowiak20-Sep-14 12:22
mveDave Kreskowiak20-Sep-14 12:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.