none
vb script to read txt file and excute icacls RRS feed

  • Question

  • Hi

    I have a big list of usernames with exclusive folder permissions that i need to reset.

    Can someone help create a vs script to read each line in the txt file and run:

    icacls "\\Server1\User$\USERNAME\Documents" /Reset /t /c /l /q

    Monday, January 13, 2014 12:37 AM

Answers

  • oshell.run (icacls "\\server01\users$\"+ strusername /Reset /t /c /l /q")

    Hi,

    That's a good start, but the above line that uses the Run method does not have valid syntax. You would need to write it this way:


    oshell.Run "icacls ""\\server01\users$\" & strusername & """ /Reset /t /c /l /q"

    VBScript uses "" inside a string to represent a single ", and you use the & character to concatenate strings.

    Bill

    • Proposed as answer by Mike Laughlin Monday, January 13, 2014 7:19 PM
    • Marked as answer by pigd0g Monday, January 13, 2014 7:47 PM
    Monday, January 13, 2014 7:12 PM
    Moderator

All replies

  • Hi,

    What does your script look like so far?

    Bill

    Monday, January 13, 2014 1:15 AM
    Moderator
  • Set objFSO  = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("C:\userlist.txt")
    Set oShell  = WScript.CreateObject("WSCript.shell")

    Do Until objFile.AtEndOfStream
    strusername = objFile.ReadLine
    oshell.run (icacls "\\server01\users$\"+ strusername /Reset /t /c /l /q")
    Loop
    Monday, January 13, 2014 1:52 AM
  • oshell.run (icacls "\\server01\users$\"+ strusername /Reset /t /c /l /q")

    Hi,

    That's a good start, but the above line that uses the Run method does not have valid syntax. You would need to write it this way:


    oshell.Run "icacls ""\\server01\users$\" & strusername & """ /Reset /t /c /l /q"

    VBScript uses "" inside a string to represent a single ", and you use the & character to concatenate strings.

    Bill

    • Proposed as answer by Mike Laughlin Monday, January 13, 2014 7:19 PM
    • Marked as answer by pigd0g Monday, January 13, 2014 7:47 PM
    Monday, January 13, 2014 7:12 PM
    Moderator
  • oshell.run (icacls "\\server01\users$\"+ strusername /Reset /t /c /l /q")

    Hi,

    That's a good start, but the above line that uses the Run method does not have valid syntax. You would need to write it this way:


    oshell.Run "icacls ""\\server01\users$\" & strusername & """ /Reset /t /c /l /q"

    VBScript uses "" inside a string to represent a single ", and you use the & character to concatenate strings.

    Bill


    Thanks so much! All working well :D
    Monday, January 13, 2014 7:47 PM