Run Multiple commands in a single line in windows command prompt - windows

When I execute the following commands separately i can get the information of the mnc file
C:>set path=%path%;C:\Program Files\MINC\bin
C:>mincinfo image.mnc
But I want to run it in a single line. So i tried this as
C:>set path=%path%;"C:\Program Files\MINC\bin" && mincinfo image.mnc
But it gives the following error,
'mincinfo' is not recognized as an internal or external command,
operable program or batch file.
Is there something wrong in my commands? Please help to solve it.

You can of course specify the full path of the program to execute, without needing to add it to the PATH variable.
C:>"C:\Program Files\MINC\bin\mincinfo" image.mnc

if you concatenate your commands with &&, the whole line will be parsed at one time.
The result is, the path is yet the old path for the second command.

Related

Adding lua.exe to my system path

I've been having difficulty setting up lua as a system path. I'm attempting to run lua programs via the command prompt. I've followed multiple stackoverflow answers for similar questions:
Running a lua program from a text file
to no avail. Regarding the link's four steps: I'm able to complete step one no problem, would like to complete step three and step two onward have thoroughly confused me.
I've edited my PATH variable to include what I believe the correct path for lua is: C:\Program Files\Lua\5.3.4_64\lua53.exe. I feel like this is where I'm botching it.
This is the general output when I try to run lua from a cmd prompt within the folder holding lua.exe or outside of it.
C:\Program Files\Lua\5.3.4_32>lua main.lua
'lua' is not recognized as an internal or external command,
operable program or batch file.
If anyone can help or needs more information to help please let me know and thank you in advance.
You need to add the folder of lua53.exe to the PATH variable. That is, add C:\Program Files\Lua\5.3.4_64, not C:\Program Files\Lua\5.3.4_64\lua53.exe. Then when you type lua53 in the command prompt, the command processor will search in that folder for lua53.exe and run it.
If you want to run Lua in the command line with the name lua, you will have to rename lua53.exe to lua.exe, or create a batch file named lua.bat with the content lua53 %* and save it in the same folder as lua53.exe. (%* is a variable that copies the arguments that you typed after the name of the batch file. That is, if you type lua -e "print 'Hello, world!'" in the command line, it will execute the command lua53 -e "print 'Hello, world!'".)

Ninja batch file as command

I want to use a batch file as a rule command in ninja like this
rule test
command = some-batch-file
but it results in
CreateProcess failed: The system cannot find the file specified.
It works when I prefix the command with cmd /c, but then I face the problem of the command-line length cap at 8191 or so characters. I found it hard finding information on why this doesn't work. My guess is that windows can really only execute .exe files with CreateProcess().
Can I make it work when it is passed directly to CreateProcess() or do I have to use cmd /c?

Current directory and parent directory seem broken

I have Windows 8.1 and I have a strange problem.
When I launch a Command Terminal, it seems that current directory and parent directory don't work when I try to use it to launch executable.
For example, considering the following folders :
C:/dirA/dirB/program.exe
C:/dirA/dirB/dirC
I put dirA/dirB in the PATH variable.
So, when I launch program.exe in Command Terminal, it works.
But, if I go in C:/ and launch the following command :
./dirA/dirB/program.exe
I got the following error :
'.' is not recognized as an internal or external command, operable
program or batch file.
Error is the same if I go on C:/dirA/dirB/dirC folder and launch the following command :
../program.exe
Error is :
'..' is not recognized as an internal or external command, operable
program or batch file.
So, I don't understand what is the problem and how to solve it. Someone have an idea and can help me ?
Thanks for your help.
Sylvain
If you want to use forward slashes (/) with paths in Windows Command Prompt you need to quote the whole path.
"./dirA/dirB/program.exe"
If you use backslashes (\) then you don't have to quote paths (unless your path contains spaces).

Error when i run a shortcut using it's path in cmd

I have a problem whenever I try to run some paths,
for example :
C:\Users\Dell\Desktop\Menu\program.lnk
I had this error:
not recognized as an internal or external command operable program or batch file.
As you can see this not a problem of space in the path, how can I solve this?
Having Tested This in the command prompt myself I found that on my windows 7 machine the command prompt doesn't like me appending the '.lnk' file extension on the end yet it seems to work to when I remove it. Other than I am not too sure. Could be a problem with the shortcut or the executable but I doubt it.
i just had to add cmd /C as prefix of the command

Where does windows cls.exe reside?

As we know windows CMD can clear the scren by cls.exe command. But I cannot find the command location.
Usually, I can use which to find the location of the command program file.
But for cls.exe, it does not work, and displays as:
which: no cls in c:\Windows\System32...
Could you guys help me how cmd works? I searched on the internet, only finding clues on how to use it. Not how itself works!
There is no cls.exe. 'cls' is an CMD.EXE internal built-in.
It's built-in command to cmd.exe and not a stand-alone program.
i.e. cls.exe does not exist:
C:\>"cls.exe"
'"cls.exe"' is not recognized as an internal or external command,
operable program or batch file.
C:\>"cls.com"
'"cls.com"' is not recognized as an internal or external command,
operable program or batch file.
C:\>"find.exe"
FIND: Parameter format not correct
The last one, find.exe, is just there to show what happens when it exists.

Resources