I cannot get the following batch code to work if variable !batDir!
contains spaces, e.g. W:\scripts windows\
:
if /I "!i!" GTR "1" (
Powershell "!batDir!ript.ps1 !test! '!testWithSpaces!' "
goto :scriptEnd
)
W:\scripts : The term 'W:\scripts' is not recognized as the name of a cmdlet, function, script file, or operable
program.
CodePudding user response:
You need to use quotes with &.
Powershell "& '!batDir!ript.ps1' !test! '!testWithSpaces!' "
https://newbedev.com/how-to-run-a-powershell-script-with-white-spaces-in-path-from-command-line