I need to call .bat file from Powershell script

后端 未结 3 786
广开言路
广开言路 2020-12-12 07:20

We are migrating perl script to powershell script. In Perl the code is as shown below

$rc=\'D:\\\\EmailConnector\\\\run.bat> $EmailConnector_log;\';
         


        
3条回答
  •  星月不相逢
    2020-12-12 07:54

    Or, since there are no spaces in the path, you can just execute the batch file directly from PowerShell:

    D:\EmailConnector\run.bat > $EmailConnector_log
    

    This is one of the advantages of PowerShell being both a "shell" and a "scripting language". Execution of batch, cmd, vbs, exe files is straightforward - usually. Parameter passing can be an issue but these days that is easily solved with the stop parsing operator: --%.

提交回复
热议问题