Via VS 2017 calling Setup.cmd which contains:
@echo off
chcp 65001
powershell -ExecutionPolicy Unrestricted .\setup.ps1 "%*"
The file is called, and this error appear:
Active code page: 65001
.\setup.ps1 : The term '.\setup.ps1' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ .\setup.ps1 -SkipDbInstall:0 -SkipPandoSupportInstall:0 -SkipSearchServiceInstal ...
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.\setup.ps1:String) [], Command NotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
setup.ps1 exist in the same level like setup.cmd.
What can be the problem?
Most likely your working directory is not what you think it is. You can verify that by adding a line echo %CD% to the batch file.
To change the working directory to the folder in which the scripts reside add a line cd /d "%~dp0". You also need to remove the quotes from %*, otherwise all arguments to your batch script will be passed as a single string argument to the PowerShell script. And I'd recommend using the parameter -File with powershell.exe, so that you'll get a proper exit code from the PowerShell script (if it returns one).
@echo off
cd /d "%~dp0"
chcp 65001 >nul
powershell.exe -ExecutionPolicy Unrestricted -File .\setup.ps1 %*
If the PowerShell script doesn't care about the working directory you could also run it with the full path instead of changing the directory:
powershell.exe -ExecutionPolicy Unrestricted -File "%~dp0setup.ps1" %*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With