locked
VBScript Icacls RRS feed

  • Question

  • Dear,

    I dont know what wrong with below script its not sccuessfully running


    OptionExplicit
    Dim Obj, intRunError, strHomeFolder
    Set Obj = wscript.createobject("wscript.shell") 

    strHomeFolder = "C:\Program Files\Temp\"

    'intRunError = Obj.run ("%COMSPEC% /c Echo Y| cacls " & strHomeFolder & " /c /g users:M ", 2, True)
    Obj.Run"icacls strHomeFolder /grant:r users:(OI)M"



    Support@Mytechnet.me

    Sunday, June 15, 2014 9:11 AM

Answers

  • Not a scripting problem - your syntax for icacls is wrong. Open a Command Prompt with cmd.exe, then play with icacls.exe until you get the correct syntax. Only then should you put it in your script.

    Type icacls /? > help.txt to get help for icacls.

    • Marked as answer by Bill_Stewart Monday, June 16, 2014 2:02 PM
    Sunday, June 15, 2014 10:21 AM

All replies

  • Not a scripting problem - your syntax for icacls is wrong. Open a Command Prompt with cmd.exe, then play with icacls.exe until you get the correct syntax. Only then should you put it in your script.

    Type icacls /? > help.txt to get help for icacls.

    • Marked as answer by Bill_Stewart Monday, June 16, 2014 2:02 PM
    Sunday, June 15, 2014 10:21 AM
  • This is impossible:

    Obj.Run"icacls strHomeFolder /grant:r users:(OI)M"

    You cannot use variables in strings.

    You have been trying ti write simple scripts for months now. You make the same mistakes over and over again.  You need to take time and learn the basics.

    Spend the next month doing all of the exercises here: http://technet.microsoft.com/en-us/scriptcenter/dd772284

    Keep going over this material until you understand it.  If you have a question about one specific step or article post a question.

    You cannot learn Windows technology by constant guessing as you should see by now.


    ¯\_(ツ)_/¯

    Sunday, June 15, 2014 10:42 AM