Cannot get Execute-Process with ICACLS and parameters correct! Escape characters

//Cannot get Execute-Process with ICACLS and parameters correct! Escape characters
Cannot get Execute-Process with ICACLS and parameters correct! Escape characters 2016-11-22T17:09:24+00:00

The Toolkit Forums General Cannot get Execute-Process with ICACLS and parameters correct! Escape characters

  • Author
    Posts
  • Baatch
    Participant
    Post count: 8

    Hi,

    I’m pulling my hair out with this one. I’m trying to run this command that works in the commandline:

    ICACLS “C:\Program Files (x86)\Software AB” /INHERITANCE:e /GRANT:r “Domain\Domain Users”:(F) /T /C

    But when I put it into the PS appdeployment toolkit script and run with with Execute-Process is does not work:

    Execute-Process -Path “$envSystem32Directory\icacls.exe” -Parameters “”C:\Program Files (x86)\Software AB” /INHERITANCE:e /GRANT:r “Domain\Domain Users:(F)” /T /C”

    I can’t wrap my head around all the spaces and the need for escape characters in the parameters section. I’m at a loss on how it works. Please help.

    • This topic was modified 1 year, 6 months ago by  Baatch.
  • Francois
    Participant
    Post count: 105

    Hi,

    I don’t know well ICACLS but why not using SECEDIT?

    Thanks,

  • Dan
    Participant
    Post count: 10

    If you have quotes inside of other quotes. You have to use an escape character. Which in powershell is this. ‘
    So, try this.

    Execute-Process -Path “$envSystem32Directory\icacls.exe’” -Parameters ‘“’”C:\Program Files (x86)\Software AB’” /INHERITANCE:e /GRANT:r “Domain\Domain Users:(F)’” /T /C”

    • Baatch
      Participant
      Post count: 8

      Hi Dan,

      Thank for helping with the commenting. I think the forum is formatting the escape character wrong.
      Is it possible for you to post it somewhere else and link it?

  • Dan
    Participant
    Post count: 10

    Not really. I have been meaning to set up a website. I guess I need to work on that. Let me try and explain.

    If you have ” inside other quotes. Like this. ” stuff ” more stuff ” stuff ”

    then the quotes inside need an escape character or they don’t come out right.
    So, you need this key in front of the quotes on the inside. ‘

    ” stuff ‘” more stuff ‘” stuff ”

    I hope that helps man.
    Email me at dandanesia@gmail.com if that doesn’t help and I will tweak it and email it back to you.

  • Dan
    Participant
    Post count: 10

    I made a mistake with my posts here. I am sorry. You need back ticks in front of the inside quotes.

    The key in the upper left of the keyboard.
    So, you need this.

    Execute-Process -Path “$envSystem32Directory\icacls.exe” -Parameters “”C:\Program Files (x86)\Software AB” /INHERITANCE:e /GRANT:r “Domain\Domain Users:(F)” /T /C”

    Basically a back tick in front of any inside quote.

You must be logged in to reply to this topic.