Command Prompt Error 'C:\Program' is not recognized as an internal or external command, operable program or batch file - batch-file

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
Update:
Trying the solution with quotes confuses the compiler in some way

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

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 .....

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

Try putting cd before the file path.
Example:
C:\Users\user>cd C:\Program Files\MongoDB\Server\4.4\bin

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...

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.

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

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

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

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.

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

Related

7-zip command line - Incorrect wildcard type marker

I'm using 7-zip 15.14 64-bit on Windows 10. I have a batch file that compiles a game I'm working on, only problem is I get an error about an "Incorrect wildcard type marker". Here is the line of code taken right from the batch file.
"%ProgramFiles%\7-Zip\7z.exe" a "%expt%\Game_Win.exe" "%expt%\Win\*" -x!*.m4a -sfx -mx9 -y
Note that I do have symbolic links in the directory I'm trying to compress.
It sounds like you have enabledelayedexpansion turned on.
With this mode, ! symbols have special meaning, and to make matters more interesting, there are two parse passes on each line, meaning you'll need to double escape them to have the symbol pass through to the target application:
echo "%ProgramFiles%\7-Zip\7z.exe" a "%expt%\Game_Win.exe" "%expt%\Win\*" -x^^!*.m4a -sfx -mx9 -y

Unable to start .bat script under Windows 7

This is strange: in general, .bat scripts work fine on this machine. So the PATH variable is fine.
However, I have one script that creates the error message
--> 'C:\Windows\system32\cmd.exe\' is not recognized as an internal ....
Here is the one-line script:
--> #echo %1 | "C:\Program Files\putty\PSFTP.exe" -pw xxx User#Host
This script is working fine on two other Windows 7 machines, just not on mine.
Any ideas what to check?
Is it possible you are using a 64bit version of Windows?. The path may need to be set to point to "C:\Program Files (x86)\Putty"
Actually, the problem had nothing to do with the specific command. Even a
dir | dir
from the command line threw the same error.
I did find the solution here:
https://superuser.com/questions/557387/pipe-not-working-in-cmd-exe-on-windows-7
Problem was the environment variable ComSpec; somehow it had a bad character in the field. I removed that darn back-slash and all is fine.
Thanks for looking at my problem.

How to mention C:\Program Files in batchfile

I need to invoke an exe file in C:\Program Files directory from a batch file.How can we mention the directory name "Program Files" in batch file.I am getting error like C:\Program not found.
I believe that % or ~ needs to be added in between but couldn't get it.Kindly assist.
Surround the script call with "", generally it's good practices to do so with filepath.
"C:\Program Files"
Although for this particular name you probably should use environment variable like this :
"%ProgramFiles%\batch.cmd"
or for 32 bits program on 64 bit windows :
"%ProgramFiles(x86)%\batch.cmd"
On my pc I need to do the following:
#echo off
start C:\"Program Files (x86)\VirtualDJ\virtualdj_pro.exe"
start C:\toolbetech\TBETECH\"Your Toolbar.exe"
exit
Now that bash is out for windows 10, if you want to access program files from bash, you can do it like so: cd /mnt/c/Program\ Files.
I use in my batch files - c:\progra~2\ instead of C:\Program Files (x86)\ and it works.
I had a similar issue as you, although I was trying to use start to open Chrome and using the file path. I used only start chrome.exe and it opened just fine. You may want to try to do the same with exe file. Using the file path may be unnecessary.
Here are some examples (using the file name you gave in a comment on another answer):
Instead of C:\Program^ Files\temp.exe you can try temp.exe.
Instead of start C:\Program^ Files\temp.exe you can try start
temp.exe
use this as somethink
"C:/Program Files (x86)/Nox/bin/nox_adb" install -r app.apk
where
"path_to_executable" commands_argument
Interestingly with variables ,this worked for me ...
SET "VESTADIR=\\%TARGET%\C$\"Program Files (x86)"\Cassidian\VESTA"
While createting the bat file, you can easly avoid the space. If you want to mentioned "program files "folder in batch file.
Do following steps:
1. Type c: then press enter
2. cd program files
3. cd "choose your own folder name"
then continue as you wish.
This way you can create batch file and you can mention program files folder.

Delete a file named "NUL" on Windows

I ran a program on Windows 7 that was compiled under Cygwin and passed "NUL" as an output file name. Instead of suppressing output it actually created a file named "NUL" in the current directory. (Apparently it expects "/dev/null", even on Windows.) Now I'm stuck with this "NUL" file that I cannot delete!
I've already tried:
Windows Explorer - error: "Invalid MS-DOS function" (yes, that is seriously what it says!)
Command prompt using "del NUL" - error: "The filename, directory name, or volume
label syntax is incorrect."
Deleting the entire directory - same deal as just deleting the file
remove() in a C program - also fails
How can I get rid of these NUL files (I have several by now), short of installing the full Cygwin environment and compiling a C program under Cygwin to do it?
Open a command prompt and use these commands to first rename and then delete the NUL file:
C:\> rename \\.\C:\..\NUL. deletefile.txt
C:\> del deletefile.txt
Using the \\.\ prefix tells the high-level file I/O functions to pass the filename unparsed to the device driver - this way you can access otherwise invalid names.
Read this article about valid file / path names in Windows and the various reserved names.
If you have Git for Windows Installed (v2.18) do the following
Open the directory containing the files you want to remove
Left Click and select Git Bash Here
Type rm nul.json at the command prompt and hit ENTER, the file now should be removed.
NOTE: These screenshots show the removal of file nul.topo.json which is another file that I could not removed with a simple delete.
If you have git on windows, just right click on the folder containing the nul file -> go to gitbash here -> and type "rm nul" or "rm nul.json" depending upon the file type.
I had a similar issue. It was probably caused by Cygwin as well (since I use this regularly), but I've since forgotten exactly how the file was created.
I also had trouble deleting it. I followed the advice of some other posts and tried booting into safe mode to delete the file, though this did nothing. The tip from +xxbbcc didn't work for me either.
However, I was able to delete the file using the Cygwin terminal! Cygwin createth and Cygwin destroyeth.
To remove a nul file situated here:
C:\unix\cygwin\dev\nul
I simply use (tested only on Windows 10) :
Del \?\C:\unix\cygwin\dev\NUL
I solved this in a slightly different way.
I thought I would add this here because it is high in the google results and I had a similar issue for a folder named NUL.
I tried rmdir\\?\C:\My\Path\NUL and rmdir\\.\C:\My\Path\NUL without any success and also tried several commands using bash from my SourceTree installation. No joy.
In the end I used DIR /X /A from cmd to list the short names in the parent directory. This showed me NUL~1 for my NUL folder and identified the crux of the problem.
This was then used in the standard command rmdir /s NUL~1 and finally resolved the issue.
I was having this same issue.
If you have WSL2 installed just go to that directory and run:
rm -f nul
In my case the file was lowercase. You should be good.
Try writing a short C program that calls the Windows API to delete that file.
http://msdn.microsoft.com/en-us/library/aa363915%28v=vs.85%29.aspx
If that doesn't work, try opening a handle to the file with CreateFile() with FILE_FLAG_DELETE_ON_CLOSE, and then close the handle.

Why multiple arguments with spaces are not interpreted correctly in a batch script?

I'm running an exe with multiple arguments that may or may not contain spaces. I encloses them with quotes but they are somehow not passed to the exe correctly.
Here's the command i'm using:
makeblastdb -in "D:\d b\sequence.fasta" -input_type fasta -dbtype prot -title xd -out "D:\d b\xd"
which I think cmd should pass 10 arguments to the exe but somehow it isn't passing correctly.
this is the result i get
BLAST options error: File "D:\d" does not exist.
which is basically saying that the second argument is being chopped for some reason?
Any help will be appreciated, thanks!
Based on your comments to your question, the BLAST utility does not properly handle quoted paths with spaces, and your volume does not support short file names.
Obviously you can move your working directory to a path that does not contain spaces.
An alternative is to use SUBST to temporarily create a virtual drive that points to your problematic path.
subst K: "d:\d b"
makeblastdb -in "K:\sequence.fasta" -input_type fasta -dbtype prot -title xd -out "K:\xd"
subst /d K:
Type subst /? for help with the command.
Update based on fact that you are running the command from within python
In your comment to this answer, you state you will attempt to get the command to work from within python. That could be the entire source of your problem.
You should try to run the command in your question directly from a Windows command prompt (cmd.exe console).
If the command does not work from the command prompt, then the problem is indeed with the BLAST utility, and SUBST is a good solution.
If the command does work from the command prompt, then the problem is with how you are shelling out the command from python, and the SUBST command should not be required.
I'm not a python user, but I see that many people have similar problems when using python on Windows. Perhaps this will help: How do I execute a program from python? os.system fails due to spaces in path
makeblastdb has an odd escaping convention. Try this:
-in \""D:\d b\sequence.fasta"\"
Unfortunately this doesn't work for -out, so dbenham's answer is probably best.
Alternative is you can try using directory shortname for "D:\d b" which you can find by running dir /X command on your D drive. For instance if I run dir /X on my C drive here is what I get:
01/21/2013 09:47 AM <DIR> PROGRA~1 Program Files
So you want to use C:\Program Files you can alternatively use C:\PROGRA~1.

Resources