currently I am in the batch-hell. I want to call my powershell script via a batch file. This works properly as long as there are no empty spaces in the path. For example this is working
set DATAPATH="%~1"
set XMLFILE="%~2"
set PSFILE="C:\dev\workflow\handler.ps1"
echo %PSFILE%
echo powershell -command %PSFILE% -datapath """%DATAPATH%""" -xmlFile """%XMLFILE%"""
powershell -command %PSFILE% -datapath """%DATAPATH%""" -xmlFile """%XMLFILE%"""
IF %ERRORLEVEL% == 0 (echo true) else (echo false)
When I change it to use a path which contains a space in the file path it is not working.
set DATAPATH="%~1"
set XMLFILE="%~2"
set PSFILE="C:\dev\work flow\handler.ps1"
echo %PSFILE%
echo powershell -command %PSFILE% -datapath """%DATAPATH%""" -xmlFile """%XMLFILE%"""
powershell -command %PSFILE% -datapath """%DATAPATH%""" -xmlFile """%XMLFILE%"""
IF %ERRORLEVEL% == 0 (echo true) else (echo false)
The error message "C:\dev\work" was not not found as a name of a cmdlet indicates for me that the space is the root of the problem. Any idea I tried it also to define the variable PSFILE like this
set PSFILE="""C:\dev\work flow\handler.ps1"""
Maybe someone knows a solution and shows me how to handle spaces in a batch file path.
