Powershell Command Processing (Passing in Variables)

后端 未结 6 2211
没有蜡笔的小新
没有蜡笔的小新 2021-02-15 23:01

I\'m creating a Powershell script to deploy some code and part of the process is to call a command-line compression tool called RAR.EXE to back-up some folders.

I\'m at

6条回答
  •  爱一瞬间的悲伤
    2021-02-16 00:00

    One other way I found to do this was to create an array of arguments for the command line and use that with the apersand & call operator. Something like this:

    $exe = "cmd";
    [Array]$params = "/c", "echo", "foo";
    
    & $exe $params;
    

    It's worked well for me.

    I originally found this technique here: http://techstumbler.blogspot.com/2009/12/windows-commands-with-arguments-in.html

提交回复
热议问题