Issue with batch when %APPDATA% generates a path with a space in it

80 views Asked by At

I have a batch script which moves, and unzips and activates an excel add in. This script works fine when run on a computer with a user with no spaces in the name however fails when a user with a space attempts to run it.

Here is what I have:

Echo Copying PyXLL files...
xcopy \\server\s\SCIA\Operations\Temp\Peter\pyxll\deployment\PyxllAddIn.zip %APPDATA%\PyXLL\ /y

Echo Unzipping files...
powershell -command "Expand-Archive %APPDATA%\PyXLL\PyxllAddIn.zip %APPDATA%\PyXLL"

Echo Installing add-in...
%APPDATA%\PyXLL\python-3913\python.exe -m pyxll activate --non-interactive "%APPDATA%\PyXLL\pyxll.xll

Echo Done!
pause
1

There are 1 answers

2
Keith Langmead On

I'll put my answer to the Powershell bit here, as the comments won't let me show a backtick properly. So the Powershell line would be :

powershell -command "Expand-Archive `"%APPDATA%\PyXLL\PyxllAddIn.zip`" `"%APPDATA%\PyXLL`""