I need to run the following batch file:
cd ..
msbuild reve_host.vcxproj
In order for msbuild to work, it needs to be run through a specific shell. Its path is stored in $executorPath in my Powershell script, which looks like this:
$executorPath = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2019'
Write-Host "STAGE: CLEAN."
Here are several ways of executing that I have tried, that have not worked:
Invoke-Command '$executorPath "BUILD.bat"'Invoke-Command '$executorPath ".\BUILD.bat"'Invoke-Command -ScriptBlock {& $executorPath 'BUILD.bat'}Invoke-Command -ScriptBlock {& $executorPath '.\BUILD.bat'}$($executorPath 'BUILD.bat')$($executorPath '.\BUILD.bat')
With 1 and 2, I get:
Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.
With 3 and 4, I get:
The term 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2019' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
None of these work. How do I run this?
*.batis not an executable -CMD.exeis. And bat should be provided as the second argument after/cif you want to run it. Otherwise you would need to useInvoke-Expression;-). (Join-Path -Path $executorPath -ChildPath BUILD.bat)or (another approach)& "$(Join-Path -Path $executorPath -ChildPath BUILD.bat)"or something alike."C:\randomPath\withSubfolder" "fileName.bat"is not the same like"C:\randomPath\withSubfolder\fileName.bat". Only second one is a valid full path. ;-)