Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Running PowerShell script from a Batch File in a nested folder

$
0
0

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)


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>