Linked Questions

12 votes
2 answers
48k views

What's the difference between *.bat and *.cmd file? [duplicate]

Possible Duplicate: Windows batch files: .bat vs .cmd? Hi, I am learning Windows Batch programming and come across this question: What's the difference between .bat and .cmd file? If they are ...
smwikipedia's user avatar
  • 63.2k
3 votes
1 answer
2k views

Why continue using extensions .bat instead of .cmd? [duplicate]

Possible Duplicate: Windows batch files: .bat vs .cmd? I know that the .cmd is the successor of the .bat (.cmd files use 32-bit execution while the .bat files use 16-bit execution) but most ...
Acaz Souza's user avatar
  • 8,481
232 votes
91 answers
228k views

Hidden features of Windows batch files

What are some of the lesser know, but important and useful features of Windows batch files? Guidelines: One feature per answer Give both a short description of the feature and an example, not just a ...
34 votes
16 answers
93k views

Batch files don't run - they're being opened with notepad [closed]

I use WinXP sp3, and I have created a .bat file that does something. When I double click on it, a Notepad is opened and I can edit the batch file - but it is not run ??!?! I expect that when I double ...
DuduArbel's user avatar
  • 1,150
39 votes
9 answers
156k views

Exiting out of a FOR loop in a batch file?

Why does this batch file never break out of the loop? For /L %%f In (1,1,1000000) Do @If Not Exist %%f Goto :EOF Shouldn't the Goto :EOF break out of the loop? Edit: I guess I should've asked more ...
user541686's user avatar
  • 208k
34 votes
3 answers
48k views

Using nodejs's spawn causes "unknown option -- " and "[Error: spawn ENOENT]" errors

I'm trying to get spawn to effect an rm -rf node_modules followed by npm install (on windows 7; nx commands courtesy of a transparently installed CygWin. All nx commands resolve on a commandline just ...
Mike 'Pomax' Kamermans's user avatar
24 votes
1 answer
11k views

Order in which command prompt executes files with the same name (a.bat vs a.cmd vs a.exe)

What is the order in which the Windows command prompt executes files with the same name, but different extensions? For example, I have a bunch of executable files: something.cmd, something.bat and ...
Dominik Grabiec's user avatar
24 votes
2 answers
9k views

Which cmd.exe internal commands clear the ERRORLEVEL to 0 upon success?

A frequent method to handling errors within Windows batch scripts is to use things like if errorlevel 1 ... or if %errorlevel% neq 0 .... Often times one wants the error handling code to preserve the ...
dbenham's user avatar
  • 129k
13 votes
3 answers
9k views

Batch goto loses errorlevel

Consider the following bat, test.bat (PC01 is off): mkdir \\PC01\\c$\Test || goto :eof If I run that bat from a command shell: > test.bat || echo 99 > if ERRORLEVEL 1 echo 55 The output is ...
Patrick's user avatar
  • 1,139
14 votes
5 answers
4k views

Difference between "|| exit /b" and "|| exit /b !errorlevel!"

We have a bunch of .bat build scripts which are invoked by a PowerShell based GitLab runner that were recently refactored from: program args if !errorlevel! neq 0 exit /b !errorlevel! to the more ...
Chris Oldwood's user avatar
7 votes
2 answers
22k views

Export/SET environment variables in windows through a shell script

There is a script.sh file set FABRIC_CFG_PATH=<some path> set CORE_PEER_LOCALMSPID=<some id> If I'm running this script in windows, the env variables are not getting set. Whereas if ...
SAURABH SINGH's user avatar
4 votes
1 answer
30k views

Putting multiple commands into one batch file

I feel like this has to be so simple and somehow I'm just missing something. I have 3 commands that I have to continuously execute back to back. How can I put those all into one batch file? Here are ...
Without Me It Just Aweso's user avatar
4 votes
2 answers
5k views

Line length limit in xp batch file?

When running long command in .bat file (say 300 characters length) for example: Some_exe "C:/Documents and Settings/Some user/Some folder1/Some folder2/Some folder3/Some folder4 ... -Some_exe_arg1="...
JavaSheriff's user avatar
  • 7,368
2 votes
2 answers
9k views

How to run Windows Commands through C++ Program?

For some back info to help you guys out, I'm making a small program that will take an .SQL file and restore it to the users localhost phpMyAdmin using mysql.exe. Importing the file through the MyAdmin ...
Brxxn's user avatar
  • 110
2 votes
2 answers
7k views

Git Bash and Composer - Running without an extension

I've installed Git for Windows, configured to use Git commands exclusively in Git Bash. So I have a file composer.cmd sitting beside composer.phar which looks like this: @echo off php C:\bin\...
Dissident Rage's user avatar

15 30 50 per page