When cvs is typed in cmd.exe in windows 7 nothing is output. The path of the cvs is already in the PATH :C:\Program Files (x86)\CVSNT\; When typing "C:\Program Files (x86)\CVSNT\cvs" there are outputs there. But when other .exe e.g. calc is typed the corresponding program can be executed. Any idea?
This might sound like a strange suggestion, but try cvs.exe instead of just cvs. Without specifying an extension, your operating system will search for the first file that matches the name, cvs. If it happens to find cvs.bat in one of your paths, then it will execute the .bat file instead of the.exe.
If you have cvs.bat , cvs.com, and cvs.exe within the same directory. The order of precedence would be the following:
cvs.com
cvs.bat
cvs.exe
I have a strong suspicion that there's a blank cvs.bat file hidden somewhere in one of folders defined in your path variable, and that you are actually running this batch file when you type cvs.
HI the answer is Run the exe with full path like "C:\Program Files (x86)\CVSNT\cvs.exe" followed by CVS arguments like -q Checkout.....
Related
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!'".)
H:\>"H:\Program Files\R\R-3.4.0beta\bin\R.exe"
'H:\Program' is not recognized as an internal or external command,
operable program or batch file.
H:\>"H:\Progra~1\R\R-3.4.0beta\bin\R.exe"
The system cannot find the path specified.
H:\>H:\Progra~1\R\R-3.4.0beta\bin\R.exe
The system cannot find the path specified.
I tried using "..." and Progra~1 and both are not working on Windows 10.
What I'm doing wrong?
Short answer: Use & 'C:\path with spaces\app.exe'
Explanation: Just type your path into powershell and use TAB for auto completion when you choose any directory containing spaces. Powershell will automatically insert single quotes 'bla bla' and it will also put an & in front which is needed to treat the string as something that should be executed. Continue completing your path like usual.
The way to do this - and I can't believe I'm just now figuring this out - is to use Windows short names generated for files with non-8dot3 names. To get the path or program name in question, type dir /x <path to program>. It will spit out something like PROGRA~1 for Program Files folder. Of course you have to do that directory by directory, and if you have multiple files/folders with spaces in the name, it's cumbersome. If you want the full path formatted with short names, you can do:
for %I in (*) do echo %~sI
For example, if the file I want to access is C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\License Terms\License_msodbcsql_ENU.txt, I could type:
for %I in ("C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\License Terms\License_msodbcsql_ENU.txt") do echo %~sI
And what I get back is the much easier C:\PROGRA~1\MICROS~2\CLIENT~1\ODBC\170\LICENS~1\LICENS~1.TXT.
Annoying that you can't query the whole directory path without using a loop, but it is what it is. Good for aliases.
There may be an easier way with powershell, but I'm pretty sure there isn't from the cmd prompt.
you must be doing something wrong as the double quotes encapsulates the path to the executable including spaces.
To ensure you are doing it correctly, start typing the path to the command and use TAB after F:\Program until you see the correct path, in your case it will automatically do this
"F:\Program Files"
Use your arrow key to go back behind the end quotation and continue the path and use tab until you have reached.
"H:\Program Files\R\R-3.4.0beta\bin\R.exe"
You can also try and issue it with Start
start "H:\Program Files\R\R-3.4.0beta\bin\R.exe"
If Your cmd windows is open on the actual System drive where "Program Files" are located, you can run this instead of adding the drive letter as well:
".\Program Files\R\R-3.4.0beta\bin\R.exe"
Or add it to your environment variables with the path, then it should execute with just:
R.exe
Where are the commands located for Command Prompt? I know this is possible in Linux, but what about windows?
I want to rename certain commands so I can make my own using the original name.
Im doing this on a 32bit Windows XP if that helps.
More specifically, where can I find the tree command?
https://superuser.com/questions/312926/windows-equivalent-of-which-command-in-linux
in windows 7 there's the where command.
You can overwrite the standard commands, but this will break a lot of stuff.
You would also have to modify your path environment variable
in windows 7 tree is located in C:\Windows\System32\tree.com
This might be a useful site for you
http://ss64.com/nt/
Use a bat file of the same name to override an inbuilt external command. Some commands are internal so you have to specify .bat. Also if calling the overridden program specify the extension.
There are two types of commands in Windows command prompt. The internal commands are built-in inside the command processor program, that is called cmd.exe. You may inspect such commands if you open cmd.exe file with an Hex editor, or even directly with Notepad (although doing that requires a lot of patience!); to know the location of cmd.exe file, type: set comspec. Examples of internal commands are DIR, COPY, TYPE, MD, etc. (the simplest ones) and all Batch-file commands, like GOTO, IF, FOR, REM, etc. There is no way to change the name of an internal command, unless you modify the cmd.exe file (for example, using the same Hex editor) that, although possible, is NEVER recommended!!!
The external commands reside in disk files with .com or .exe extension that are grouped in certain subdirectories, usually in C:\Windows\System or C:\Windows\System32; these subdirectories must appear in %PATH% variable in order to execute the external commands directly in the command prompt. You may locate the folder where an executable file resides using the following command, that review folders included in PATH variable only (you can not use wild-cards in this case):
for %a in (tree.com tree.exe) do #echo/%~$PATH:a
You may directly change the name of any command-name.exe file; however, this practice is not recommended. A simpler option is create a Batch file with the same name of a standard command (and .bat extension) and place it in a folder that will be included in PATH variable before the standard commands folder (or in the current directory). For example, create a file named tree.bat and place it in C:\Users\MyName\MyCommands; then, modify PATH variable this way: path=C:\Users\MyName\MyCommands;C:\Windows;C:\Windows\System32. If you need to use the standard tree command inside your tree.bat file, just include the proper extension: tree.com.
I have an application named DriveMaster which I want to run from command line with different arguments. The application is residing in:
"C:\Program Files (x86)\ULINK DM2012 PRO NET\v970\DriveMaster.exe\"
Now in Windows - Run, if I open command prompt and want to give a command like:
DriveMaster /s:Scriptname.srt
This should be able to launch DriveMaster with that particular script.
How can I do this? What should I need to add in the Environment variables so that I can run the application from command prompt?
In Windows 7:
In the menu Start click Computer
In the context menu, select System Properties
Select Advanced System Settings -> tab Advanced
Select Environment Variables Menu System Variables to find the PATH variable and click it.
In the editing window, change the PATH, adding value: ; C:\Program Files (x86)\ULINK DM2012 PRO NET\v970
Open Run and type: DriveMaster /s:Scriptname.srt
That's all.
When you're in the command prompt the working directory is given in the prompt:
C:\Users>
Here, I'm in the folder C:\Users. If I want to run a program or a script in the folder I'm currently in, I can use its name alone (e.g. DriveMaster). If the program is outside my working directory, I can't call it like that because there could be many DriveMasters in different folders throughout my computer. I can either change my directory to be the one that has this program, or I can specify where in the filesystem it's located.
Changing the directory and running:
C:\Users> cd "C:\Program Files (x86)\ULINK DM2012 PRO NET\v970\"
C:\Program Files (x86)\ULINK DM2012 PRO NET\v970> DriveMaster
Specifying the full path:
"C:\Program Files (x86)\ULINK DM2012 PRO NET\v970\DriveMaster"
(I need to use quotes here because the folder names have spaces and my command prompt may not know if it's part of the folder name or the beginning of another command or argument.)
On the same line I call the program, I can choose a number of arguments (also called options, switches, flags) to change the way to program behaves. If my program accepts another file and wants it in the form /s: and-then-the-filename, that file also needs to be in my working directory. If it lives somewhere else, I can use the full specification, like I've done above.
Environment variables are a little more complicated of a topic, but there is one we might be interested in here. The Path environment variable is a list of folders that the command prompt will look in when you try to use names of files that aren't in your working directory. If I know I'm going to be using this program frequently and like where it is, I can add its folder to my Path so that I can access it with just DriveMaster in the future:
set PATH=%PATH%;C:\Program Files (x86)\ULINK DM2012 PRO NET\v970
(If I mistype that command, though, I could break other things in a way that would be hard to fix.)
In a file name drivemaster.bat whch would be located at some point in the path,
#echo off
setlocal
"C:\Program Files (x86)\ULINK DM2012 PRO NET\v970\DriveMaster.exe" /s:Scriptname.srt
where Scriptname.srt would need to be quoted and supplied with a full pathname if it's not in the current directory.
Oh you want to type DriveMaster /s:Scriptname.srt
Then use
"C:\Program Files (x86)\ULINK DM2012 PRO NET\v970\DriveMaster.exe" %1
in that script in place of the original "c:..." line.
edit : removed stray terminal backslash from ...exe
I run a batch file as an external tool (by adding it in Tools->External tools) in VS2010 (I've checked the "Use Output Window" option). This batch file performs compilation as in VS command prompt. The project that I'm working on has makefiles for various folders, so I use the mk command to build.
In the batch file, I set up the VS environment and then run the following commands:
cd $directoryWhichContainsFileToBuild
mk
cd main //This directory contains the executable that is to be built
mk
I see the output of the first mk in the Output window but after that it just hangs. I also tried to use an echo after the first mk but even that doesn't get printed in the output window (the ones before it can be seen).
Somewhere I read that there is an issue with VS 2010 output window where it hangs after showing some output, although I couldn't really be sure that that is what's the issue here.
Do I need to enable some other VS setting? Has anybody else encountered this issue?
Thanks.
Update: I unchecked the "Use Output Window" and "Close on exit" option, and I see an extra statement: "Press any key to continue". On doing that however, their is no further processing of the batch file.
Update2: Got it to work by prefixing mk with "call".
Thanks all who tried.
It is always good in batch files to specify executables with full path and file extension instead of just the file name. This avoids often lots of problems.
Here was just mk used instead of mk.bat. Therefore on every compile the command line processor cmd.exe searches for mk.* and then checks if any of the found files have an extension listed in environment variable PATHEXT. The order of file extensions separated by a semicolon in PATHEXT defines the order of execution in case of a directory contains multiple mk.* files.
If a command being specified in a batch file not being an internal command of cmd.exe without path, command line processor searches first for a file with given name in current working directory. This is often one more cause of error. What is the current working directory on execution of the batch file?
Next if no file to execute can be found in current working directory, the command line processor searches in all folders being listed in environment variable PATH separated by semicolons.
So specifying in batch files edited only rarely an external application or another batch file with full path, file name and file extension, in double quotes if necessary because of 1 or more spaces in path or file name, helps command line processor to more quickly execute that application or batch file and avoids problems because of executable not found (unknown command).
Sure, when typing commands in a command prompt window, nobody wants to enter the executables with full path, name and extension. But for batch files it is always good to be not lazy and type files to be executed with full path and extension.
TripeHound has given already the explanation why the observed behavior occurred here.
If a batch file is executed from another batch file without using command call, the command line processor continues batch execution in the other batch file and does never come back. In a C/C++ program this is like using goto with the difference that parameters can be passed to the batch file containing the further commands to be executed next.
But running from within a batch file another batch file with call results in continuation of execution below the line calling the other batch file once the other batch file reaches end, except command exit is used in the called batch file without parameter /B.
So the solution here is using:
cd /D "Directory\Which\Contains\File\To\Build"
call "Path\Containing\Batch\File\To\Build\mk.bat"
rem With mk.bat not changing current working directory change working
rem directory to the directory containing the executable to be built.
cd main
call "Path\Containing\Batch\File\To\Build\mk.bat"
BTW: exit exits command processor, exit /B exits just current batch file. I'll give you three guesses why the parameter is B and not a different letter. Yes, B is the first letter of batch.
Writing as a separate answer instead of an update in the question itself as many readers see the header and skim to the answer: got it to work by prefixing mk with "call". (#TripleHound has also posted the conceptual reason for it in the comment above.)