How to pass command-line arguments to a PowerShell ps1 file

前端 未结 7 883
Happy的楠姐
Happy的楠姐 2020-12-12 23:21

For years, I have used the cmd/DOS/Windows shell and passed command-line arguments to batch files. For example, I have a file, zuzu.bat and in it,

相关标签:
7条回答
  • 2020-12-13 00:05

    OK, so first this is breaking a basic security feature in PowerShell. With that understanding, here is how you can do it:

    1. Open an Windows Explorer window
    2. Menu Tools -> Folder Options -> tab File Types
    3. Find the PS1 file type and click the advanced button
    4. Click the New button
    5. For Action put: Open
    6. For the Application put: "C:\WINNT\system32\WindowsPowerShell\v1.0\powershell.exe" "-file" "%1" %*

    You may want to put a -NoProfile argument in there too depending on what your profile does.

    0 讨论(0)
提交回复
热议问题