66

I am trying to run the following batch command. The command has been extracted from the IDE so is confirmed working. Getting the error mentioned below.

I have tried a few variations with double quotes but they haven't worked. Even on powershell it has the same message.

C:\Program Files\IAR Systems\Embedded Workbench 7.0\430\bin\icc430.exe F:\CP001\source\Meter\Main.c -D Hardware_P20E -D Calibration_code -D _Optical -D _Configuration_TS0382 -o F:\CP001\Temp\C20EO\Obj\ --no_cse --no_unroll --no_inline --no_code_motion --no_tbaa --debug -D__MSP430F425 -e --double=32 --dlib_config C:\Program Files\IAR Systems\Embedded Workbench 7.0\430\lib\dlib\dl430fn.h -Ol --multiplier=16 --segment __data16=DATA16 --segment __data20=DATA20

Command Prompt

Update:

Trying the solution with quotes confuses the compiler in some way

enter image description here

gunr2171
  • 16,104
  • 25
  • 61
  • 88
Rohan Sharma
  • 1,416
  • 2
  • 14
  • 19

11 Answers11

57

If a directory has spaces in, put quotes around it. This includes the program you're calling, not just the arguments

"C:\Program Files\IAR Systems\Embedded Workbench 7.0\430\bin\icc430.exe" "F:\CP001\source\Meter\Main.c" -D Hardware_P20E -D Calibration_code -D _Optical -D _Configuration_TS0382 -o "F:\CP001\Temp\C20EO\Obj\" --no_cse --no_unroll --no_inline --no_code_motion --no_tbaa --debug -D__MSP430F425 -e --double=32 --dlib_config "C:\Program Files\IAR Systems\Embedded Workbench 7.0\430\lib\dlib\dl430fn.h" -Ol --multiplier=16 --segment __data16=DATA16 --segment __data20=DATA20
James Hunt
  • 2,448
  • 11
  • 23
26

You just need to keep Program Files in double quote & rest of the command don't need any quote.

C:\"Program Files"\IAR Systems\Embedded Workbench 7.0\430\bin\icc430.exe F:\CP00 .....
msc
  • 33,420
  • 29
  • 119
  • 214
DheerajS
  • 293
  • 3
  • 2
21

This seems to happen from time to time with programs that are very sensitive to command lines, but one option is to just use the DOS path instead of the Windows path. This means that C:\Program Files\ would resolve to C:\PROGRA~1\ and generally avoid any issues with spacing.

To get the short path you can create a quick Batch file that echos the short path:

@ECHO OFF
echo %~s1

Which is then called as follows:

C:\>shortPath.bat "C:\Program Files"
C:\PROGRA~1
rjzii
  • 14,236
  • 12
  • 79
  • 119
  • I tried setting my PATH variable to use `%ProgramFiles(x86)%` with no luck as I guess it resolved still to the path with spaces - but your solution worked, ended up using "PROGRA~2", thank you so much – joshcomley Nov 26 '16 at 14:09
  • @joshcomley, yes, for `Program Files(x86)` see https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html: `Progra~1 = 'Program Files'`, `Progra~2 = 'Program Files(x86)'`. – CoolMind Jul 27 '21 at 08:13
2

Try putting cd before the file path.

Example:

C:\Users\user>cd C:\Program Files\MongoDB\Server\4.4\bin

TheGoldenTree
  • 158
  • 4
  • 16
1

If a directory has spaces in, put quotes around it. This includes the program you're calling, not just the arguments

"C:\Program Files\IAR Systems\Embedded Workbench 7.0\430\bin\icc430.exe"

Also - SPACES in your "${workspaceFolder}" (dir to your project) can confuse the compiler!

At least mine was throwing various errors (like that above, but I had fixed the compiler path), I finally noticed it compiled on PC 1 (dir without spaces) and would NOT compile PC 2 (dir with spaces).

Actually don't know where to put quotes ("") to make this work because ${workspaceFolder} or ${fileDirname} are a predefined variable reference in VSC...

emcdee
  • 11
  • 1
  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/30557264) – Compo Dec 14 '21 at 16:49
0

I encountered a similar problem using windows command line for R script, Rscript.exe, which is very sensitive to spaces in the path. The solution was to create a virtual path to the binary folder using the windows subst command.

The following fails: "C:\Program Files\R\R-3.4.0\bin\Rscript.exe"

Doing following succeeds:

subst Z: "C:\Program Files\R\R-3.4.0"
Z:\bin\Rscript.exe

The reason the above-proposed solutions didn't work, evidently, has to do with the Rscript.exe executable's own internal path resolution from its working directory (which has a space in it) rather the windows command line being confused with the space. So using ~ or " to resolve the issue at the command line is moot. The executable must be called within a path lacking spaces.

Soren
  • 1,792
  • 1
  • 13
  • 16
0

Most of the times, the issue is with the paths you have mentioned for 'java home' and 'javac' tags in settings.xml which is present in your .m2 repository and the issue is not with your path variable or Java_Home variable. If you check and correct the same, you should be able to execute your commands successfully. - Jaihind

jaihind
  • 1,090
  • 1
  • 8
  • 9
0

Just go to the folder path and type cmd on it. Then press ENTER enter image description here

0

You can go to folder by doing on first line and next line call exe like below.

cd 'c:\program files\....'
.\abc.exe --install service 
nKognito
  • 6,297
  • 17
  • 77
  • 138
Ganesh
  • 1
-1

I believe James Hunt's answer will solve the problem.

@user3731784: In your new message, the compiler seems to be confused because of the "C:\Program Files\IAR systems\Embedded Workbench 7.0\430\lib\dlib\d1430fn.h" argument. Why are you giving this header file at the middle of other compiler switches? Please correct this and try again. Also, it probably is a good idea to give the source file name after all the compiler switches and not at the beginning.

HelloWorld101
  • 3,878
  • 2
  • 34
  • 47
  • The command has been picked up from the original IDE. All the switches in it have to be used. Can't ignore anything. Only problem is -O switch because it doesn't have a space after it. Rest works – Rohan Sharma Jan 30 '15 at 10:16
-2

Go to Start and search for cmd. Right click on it, properties then set the Target path in quotes. This worked fine for me.

n1kkou
  • 3,096
  • 2
  • 21
  • 32