locked
Running PowerShell script from a Batch File in a nested folder RRS feed

  • Question

  • Hey all, I'd like to use a batch file that will call up a Powershell Script in a folder of the same directory.

    Example: %driveletter%\tools\scripts

    Where the batch file is in the Tools folder, and the powershell scripts are in the Scripts folder.  The files/scripts will be run from a USB drive, so hard-coding a drive letter is out of the question.

    Currently my batch file uses the following command to run the script:

    PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"

    I'd like to modify this line so I can run the scripts in the nested folder, and also specify which ones I want to run (ex: script1.ps1, script2.ps1, etc)

    • Moved by Bill_Stewart Friday, March 15, 2019 7:04 PM This is not "scripts on demand"
    Monday, February 4, 2019 9:32 PM

All replies