Running CMD command in PowerShell

前端 未结 5 1141
逝去的感伤
逝去的感伤 2020-12-02 12:02

I am having a bunch of issues with getting a PowerShell command to run. All it is doing is running a command that would be run in a CMD prompt window.

Here is the co

5条回答
  •  眼角桃花
    2020-12-02 12:37

    To run or convert batch files externally from PowerShell (particularly if you wish to sign all your scheduled task scripts with a certificate) I simply create a PowerShell script, e.g. deletefolders.ps1.

    Input the following into the script:

    cmd.exe /c "rd /s /q C:\#TEMP\test1"
    
    cmd.exe /c "rd /s /q C:\#TEMP\test2"
    
    cmd.exe /c "rd /s /q C:\#TEMP\test3"
    

    *Each command needs to be put on a new line calling cmd.exe again.

    This script can now be signed and run from PowerShell outputting the commands to command prompt / cmd directly.

    It is a much safer way than running batch files!

提交回复
热议问题