QuestionId stringlengths 3 8 | QuestionTitle stringlengths 15 149 | QuestionScore int64 1 27.2k | QuestionCreatedUtc stringdate 2008-08-01 18:33:08 2025-06-16 04:59:48 | QuestionBodyHtml stringlengths 40 28.2k | QuestionViewCount int64 78 16.5M | QuestionOwnerUserId float64 4 25.2M ⌀ | QuestionLastActivityUtc stringdate 2008-09-08 19:26:01 2026-01-24 22:40:25 | AcceptedAnswerId int64 266 79.7M | AnswerScore int64 2 30.1k | AnswerCreatedUtc stringdate 2008-08-01 23:40:28 2025-06-16 05:23:39 | AnswerOwnerUserId float64 1 29.5M ⌀ | AnswerLastActivityUtc stringdate 2008-08-01 23:40:28 2026-01-23 17:46:09 | QuestionLink stringlengths 31 36 | AnswerLink stringlengths 31 36 | AnswerBodyHtml stringlengths 35 33k | AnswerBodyPreview stringlengths 35 400 | AllTagIdsCsv stringlengths 2 37 | AllTagNamesCsv stringlengths 2 106 | MergedQuestion stringlengths 74 28.4k | quality_filter stringclasses 10
values | unique_id int64 0 29k | tag_major_lang stringclasses 10
values | MergedQuestion_md stringlengths 60 28.1k | AnswerBodyHtml_md stringlengths 14 29.2k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9258822 | Change message of pause command in batch script | 54 | 2012-02-13 10:21:19 | <p>I'm writing a Windows batch script. By default, the <code>pause</code> command will pause the script and display the text <em>"Press any key to continue..."</em>.</p>
<p>How do I modify this text to display my own text to the user?</p>
| 120,287 | 1,191,147 | 2025-11-05 23:44:21 | 9,258,873 | 130 | 2012-02-13 10:25:30 | 799,586 | 2022-04-24 01:06:37 | https://stackoverflow.com/q/9258822 | https://stackoverflow.com/a/9258873 | <p>You could hide the text from the <code>pause</code> command by using this:</p>
<p><code>pause >nul</code></p>
<p>Then you could echo your own message to tell the user it has paused:</p>
<p><code>echo The batch file has paused</code></p>
<p>So the full script might look like this:</p>
<pre><code>@echo off
echo Hel... | <p>You could hide the text from the <code>pause</code> command by using this:</p> <p><code>pause >nul</code></p> <p>Then you could echo your own message to tell the user it has paused:</p> <p><code>echo The batch file has paused</code></p> <p>So the full script might look like this:</p> <pre><code>@echo off echo Hel... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Change message of pause command in batch script</h1>
<p>I'm writing a Windows batch script. By default, the <code>pause</code> command will pause the script and display the text <em>"Press any key to continue..."</em>.</p>
<p>How do I modify this text to display my own text to the user?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,983 | cmd | # Change message of pause command in batch script
I'm writing a Windows batch script. By default, the `pause` command will pause the script and display the text *"Press any key to continue..."*.
How do I modify this text to display my own text to the user? | You could hide the text from the `pause` command by using this:
`pause >nul`
Then you could echo your own message to tell the user it has paused:
`echo The batch file has paused`
So the full script might look like this:
```
@echo off
echo Hello World!
echo The batch file has paused
pause >nul
``` |
9278614 | If greater than batch files | 52 | 2012-02-14 14:28:37 | <p>I wrote a simple batch file to run Frequently Used websites based on a number selection. Here's the code I have. I am trying to set it so if someone inputs a number 6 or greater it will go to <code>:N</code> but whenever I type 6 the batch file exits. I have tried <code>if %input% > 6 goto :N</code> but it just t... | 179,798 | 1,209,291 | 2018-05-23 06:34:19 | 9,278,668 | 130 | 2012-02-14 14:32:51 | 859,154 | 2018-05-23 06:34:19 | https://stackoverflow.com/q/9278614 | https://stackoverflow.com/a/9278668 | <p>try this:</p>
<pre><code>if 3 gtr 2 @echo "biggger"
</code></pre>
<p>This outputs:</p>
<pre><code>"biggger"
</code></pre>
<p><img src="https://i.sstatic.net/5D4vJ.jpg" alt="enter image description here" /></p>
<p>The other operators are:</p>
<blockquote>
<p>EQU - equal<br />
NEQ - not equal<br />... | <p>try this:</p> <pre><code>if 3 gtr 2 @echo "biggger" </code></pre> <p>This outputs:</p> <pre><code>"biggger" </code></pre> <p><img src="https://i.sstatic.net/5D4vJ.jpg" alt="enter image description here" /></p> <p>The other operators are:</p> <blockquote> <p>EQU - equal<br /> NEQ - not equal<br />... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>If greater than batch files</h1>
<p>I wrote a simple batch file to run Frequently Used websites based on a number selection. Here's the code I have. I am trying to set it so if someone inputs a number 6 or greater it will go to <code>:N</code> but whenever I type 6 the batch file exits. I have tried <code>if %input... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,984 | cmd | # If greater than batch files
I wrote a simple batch file to run Frequently Used websites based on a number selection. Here's the code I have. I am trying to set it so if someone inputs a number 6 or greater it will go to `:N` but whenever I type 6 the batch file exits. I have tried `if %input% > 6 goto :N` but it jus... | try this:
```
if 3 gtr 2 @echo "biggger"
```
This outputs:
```
"biggger"
```

The other operators are:
> EQU - equal
> NEQ - not equal
> LSS - less than
> LEQ - less than or equal
> GTR - greater than
> GEQ - greater than or equal
### Refe... |
418916 | Delete certain lines in a txt file via a batch file | 93 | 2009-01-07 01:59:41 | <p>I have a generated txt file. This file has certain lines that are superfluous, and need to be removed. Each line that requires removal has one of two string in the line; "ERROR" or "REFERENCE". These tokens may appear anywhere in the line. I would like to delete these lines, while retaining all other lines.</p>
... | 251,755 | 51,826 | 2021-09-24 01:31:55 | 418,949 | 129 | 2009-01-07 02:12:37 | 14,860 | 2009-01-07 02:12:37 | https://stackoverflow.com/q/418916 | https://stackoverflow.com/a/418949 | <p>Use the following:</p>
<pre><code>type file.txt | findstr /v ERROR | findstr /v REFERENCE
</code></pre>
<p>This has the advantage of using standard tools in the Windows OS, rather than having to find and install sed/awk/perl and such.</p>
<p>See the following transcript for it in operation:</p>
<pre>
C:\>type fi... | <p>Use the following:</p> <pre><code>type file.txt | findstr /v ERROR | findstr /v REFERENCE </code></pre> <p>This has the advantage of using standard tools in the Windows OS, rather than having to find and install sed/awk/perl and such.</p> <p>See the following transcript for it in operation:</p> <pre> C:\>type fi... | 139, 7002 | batch-file, string | <h1>Delete certain lines in a txt file via a batch file</h1>
<p>I have a generated txt file. This file has certain lines that are superfluous, and need to be removed. Each line that requires removal has one of two string in the line; "ERROR" or "REFERENCE". These tokens may appear anywhere in the line. I would like... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,985 | cmd | # Delete certain lines in a txt file via a batch file
I have a generated txt file. This file has certain lines that are superfluous, and need to be removed. Each line that requires removal has one of two string in the line; "ERROR" or "REFERENCE". These tokens may appear anywhere in the line. I would like to delete th... | Use the following:
```
type file.txt | findstr /v ERROR | findstr /v REFERENCE
```
This has the advantage of using standard tools in the Windows OS, rather than having to find and install sed/awk/perl and such.
See the following transcript for it in operation:
```
C:\>type file.txt
Good Line of data
bad line of C:\... |
22481298 | How to change directory to run .bat files from different drive? | 64 | 2014-03-18 13:45:51 | <p>I have some .bat files that I run from the local directory (e.g. C:\Users\pozna001). However, when I try and change the directory to a data drive using <code>cd F:\nrcs_project</code> to run the .bat files from a different location, I see that the command prompt does not recognize the <code>cd</code> command. How ... | 117,277 | 1,446,289 | 2020-11-09 04:43:42 | 22,481,364 | 129 | 2014-03-18 13:48:30 | 921,690 | 2019-08-20 07:18:21 | https://stackoverflow.com/q/22481298 | https://stackoverflow.com/a/22481364 | <pre><code>CD /D F:\nrcs_project
</code></pre>
<p>Use the <code>/D</code> switch to change current drive in addition to changing current directory for a drive.</p>
| <pre><code>CD /D F:\nrcs_project </code></pre> <p>Use the <code>/D</code> switch to change current drive in addition to changing current directory for a drive.</p> | 64, 7002 | batch-file, windows | <h1>How to change directory to run .bat files from different drive?</h1>
<p>I have some .bat files that I run from the local directory (e.g. C:\Users\pozna001). However, when I try and change the directory to a data drive using <code>cd F:\nrcs_project</code> to run the .bat files from a different location, I see that... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,986 | cmd | # How to change directory to run .bat files from different drive?
I have some .bat files that I run from the local directory (e.g. C:\Users\pozna001). However, when I try and change the directory to a data drive using `cd F:\nrcs_project` to run the .bat files from a different location, I see that the command prompt d... | ```
CD /D F:\nrcs_project
```
Use the `/D` switch to change current drive in addition to changing current directory for a drive. |
8662024 | How do I capture the output of a script if it is being ran by the task scheduler? | 162 | 2011-12-28 22:29:11 | <p>Using Windows Server 2008, how do I go about capturing the output of a script that is being ran with the windows task scheduler?</p>
<p>I'm testing a rather long custom printing batch-script, and for debugging purposes, I would like to see all of the output from it every night.</p>
| 167,997 | 781,339 | 2022-02-06 07:48:05 | 18,603,068 | 128 | 2013-09-03 23:29:34 | 2,744,787 | 2013-09-03 23:50:18 | https://stackoverflow.com/q/8662024 | https://stackoverflow.com/a/18603068 | <p>Try this as the command string in Task Scheduler:</p>
<pre><code>cmd /c yourscript.cmd > logall.txt
</code></pre>
| <p>Try this as the command string in Task Scheduler:</p> <pre><code>cmd /c yourscript.cmd > logall.txt </code></pre> | 7002, 9299 | batch-file, scheduled-tasks | <h1>How do I capture the output of a script if it is being ran by the task scheduler?</h1>
<p>Using Windows Server 2008, how do I go about capturing the output of a script that is being ran with the windows task scheduler?</p>
<p>I'm testing a rather long custom printing batch-script, and for debugging purposes, I wou... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,987 | cmd | # How do I capture the output of a script if it is being ran by the task scheduler?
Using Windows Server 2008, how do I go about capturing the output of a script that is being ran with the windows task scheduler?
I'm testing a rather long custom printing batch-script, and for debugging purposes, I would like to see a... | Try this as the command string in Task Scheduler:
```
cmd /c yourscript.cmd > logall.txt
``` |
8823643 | Echo off but messages are displayed | 84 | 2012-01-11 17:18:01 | <p>I turned off echo in bat file.</p>
<pre><code>@echo off
</code></pre>
<p>then I do something like this</p>
<pre><code>...
echo %INSTALL_PATH%
if exist %INSTALL_PATH%(
echo 222
...
)
</code></pre>
<p>and I get:</p>
<blockquote>
<p>The system cannot find the path specified.</p>
</blockquote>
<p>message between... | 360,254 | 1,059,446 | 2023-10-10 20:31:22 | 8,827,469 | 128 | 2012-01-11 22:13:49 | 740,923 | 2012-01-11 22:13:49 | https://stackoverflow.com/q/8823643 | https://stackoverflow.com/a/8827469 | <p>As <a href="https://stackoverflow.com/a/8823746/740923">Mike Nakis</a> said, <code>echo off</code> only prevents the printing of commands, not results. To hide the result of a command add <code>>nul</code> to the end of the line, and to hide errors add <code>2>nul</code>. For example:</p>
<pre><code>Del /Q ... | <p>As <a href="https://stackoverflow.com/a/8823746/740923">Mike Nakis</a> said, <code>echo off</code> only prevents the printing of commands, not results. To hide the result of a command add <code>>nul</code> to the end of the line, and to hide errors add <code>2>nul</code>. For example:</p> <pre><code>Del /Q ... | 2631, 7002, 13824 | batch-file, cmd, echo | <h1>Echo off but messages are displayed</h1>
<p>I turned off echo in bat file.</p>
<pre><code>@echo off
</code></pre>
<p>then I do something like this</p>
<pre><code>...
echo %INSTALL_PATH%
if exist %INSTALL_PATH%(
echo 222
...
)
</code></pre>
<p>and I get:</p>
<blockquote>
<p>The system cannot find the path spe... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,988 | cmd | # Echo off but messages are displayed
I turned off echo in bat file.
```
@echo off
```
then I do something like this
```
...
echo %INSTALL_PATH%
if exist %INSTALL_PATH%(
echo 222
...
)
```
and I get:
> The system cannot find the path specified.
message between those two echos.
What can be the reason of this mes... | As [Mike Nakis](https://stackoverflow.com/a/8823746/740923) said, `echo off` only prevents the printing of commands, not results. To hide the result of a command add `>nul` to the end of the line, and to hide errors add `2>nul`. For example:
```
Del /Q *.tmp >nul 2>nul
```
Like [Krister Andersson](https://stackoverfl... |
14686330 | How do I make a Windows batch script completely silent? | 76 | 2013-02-04 12:01:00 | <p>There has been variants of this question asked for generations, but despite writing some quite complicated Windows scripts, I can't seem to find out how to make them actually silent.</p>
<p>The following is an excerpt from one of my current scripts:</p>
<pre><code>@ECHO OFF
SET scriptDirectory=%~dp0
COPY %scriptDi... | 198,484 | 1,297,496 | 2021-04-05 18:15:31 | 14,686,887 | 127 | 2013-02-04 12:32:36 | 297,408 | 2013-02-04 12:39:22 | https://stackoverflow.com/q/14686330 | https://stackoverflow.com/a/14686887 | <p>To suppress output, use redirection to <code>NUL</code>.</p>
<p>There are two kinds of output that console commands use:</p>
<ul>
<li><p>standard output, or <code>stdout</code>,</p></li>
<li><p>standard error, or <code>stderr</code>.</p></li>
</ul>
<p>Of the two, <code>stdout</code> is used more often, both by in... | <p>To suppress output, use redirection to <code>NUL</code>.</p> <p>There are two kinds of output that console commands use:</p> <ul> <li><p>standard output, or <code>stdout</code>,</p></li> <li><p>standard error, or <code>stderr</code>.</p></li> </ul> <p>Of the two, <code>stdout</code> is used more often, both by in... | 64, 2631, 7002, 13824 | batch-file, cmd, echo, windows | <h1>How do I make a Windows batch script completely silent?</h1>
<p>There has been variants of this question asked for generations, but despite writing some quite complicated Windows scripts, I can't seem to find out how to make them actually silent.</p>
<p>The following is an excerpt from one of my current scripts:</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,989 | cmd | # How do I make a Windows batch script completely silent?
There has been variants of this question asked for generations, but despite writing some quite complicated Windows scripts, I can't seem to find out how to make them actually silent.
The following is an excerpt from one of my current scripts:
```
@ECHO OFF
SE... | To suppress output, use redirection to `NUL`.
There are two kinds of output that console commands use:
- standard output, or `stdout`,
- standard error, or `stderr`.
Of the two, `stdout` is used more often, both by internal commands, like `copy`, and by console utilities, or *external* commands, like `find` and othe... |
731332 | Check for null variable in Windows batch | 69 | 2009-04-08 18:48:33 | <p>I'm working on a Windows batch file that will bcp three text files into SQL Server. If something goes wrong in production, I want to be able to override the file names. So I'm thinking of doing something like this.</p>
<pre><code>bcp.exe MyDB..MyTable1 in %1 -SMyServer -T -c -m0
bcp.exe MyDB..MyTable2 in %2 -SMySer... | 191,128 | 44,586 | 2023-07-21 12:17:35 | 731,354 | 127 | 2009-04-08 18:54:04 | 51,691 | 2023-07-21 12:17:35 | https://stackoverflow.com/q/731332 | https://stackoverflow.com/a/731354 | <p>To test for the existence of a command line parameter, use empty brackets:</p>
<pre><code>IF [%1]==[] echo Value Missing
</code></pre>
<p>or</p>
<pre><code>IF [%1] EQU [] echo Value Missing
</code></pre>
<p>The <a href="https://ss64.com/nt/if.html" rel="nofollow noreferrer">SS64 page on IF</a> will help you here, un... | <p>To test for the existence of a command line parameter, use empty brackets:</p> <pre><code>IF [%1]==[] echo Value Missing </code></pre> <p>or</p> <pre><code>IF [%1] EQU [] echo Value Missing </code></pre> <p>The <a href="https://ss64.com/nt/if.html" rel="nofollow noreferrer">SS64 page on IF</a> will help you here, un... | 64, 7002 | batch-file, windows | <h1>Check for null variable in Windows batch</h1>
<p>I'm working on a Windows batch file that will bcp three text files into SQL Server. If something goes wrong in production, I want to be able to override the file names. So I'm thinking of doing something like this.</p>
<pre><code>bcp.exe MyDB..MyTable1 in %1 -SMySer... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,990 | cmd | # Check for null variable in Windows batch
I'm working on a Windows batch file that will bcp three text files into SQL Server. If something goes wrong in production, I want to be able to override the file names. So I'm thinking of doing something like this.
```
bcp.exe MyDB..MyTable1 in %1 -SMyServer -T -c -m0
bcp.ex... | To test for the existence of a command line parameter, use empty brackets:
```
IF [%1]==[] echo Value Missing
```
or
```
IF [%1] EQU [] echo Value Missing
```
The [SS64 page on IF](https://ss64.com/nt/if.html) will help you here, under "Test if a variable is empty".
You can't set a positional parameter, so what yo... |
14954271 | string comparison in batch file | 107 | 2013-02-19 09:39:39 | <p>How do we compare strings which got space and special chars in batch file?</p>
<p>I am trying:</p>
<pre><code>if %DevEnvDir% == "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\"(
echo VS2010
)
</code></pre>
<p>But it gives an error "Files was unexpected at this time."</p>
<p>I tried:</p>
<pre><... | 419,310 | 1,228,479 | 2022-08-18 05:55:07 | 14,955,571 | 126 | 2013-02-19 10:49:08 | 2,078,245 | 2022-06-30 13:15:10 | https://stackoverflow.com/q/14954271 | https://stackoverflow.com/a/14955571 | <p>Just put quotes around the Environment variable (as you have already done):</p>
<pre><code>if "%DevEnvDir%" == "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\"
</code></pre>
<p>The strings you are comparing are fine, the problem is the way you put the opening bracket without a s... | <p>Just put quotes around the Environment variable (as you have already done):</p> <pre><code>if "%DevEnvDir%" == "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\" </code></pre> <p>The strings you are comparing are fine, the problem is the way you put the opening bracket without a s... | 64, 7002 | batch-file, windows | <h1>string comparison in batch file</h1>
<p>How do we compare strings which got space and special chars in batch file?</p>
<p>I am trying:</p>
<pre><code>if %DevEnvDir% == "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\"(
echo VS2010
)
</code></pre>
<p>But it gives an error "Files was unexpected at... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,991 | cmd | # string comparison in batch file
How do we compare strings which got space and special chars in batch file?
I am trying:
```
if %DevEnvDir% == "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\"(
echo VS2010
)
```
But it gives an error "Files was unexpected at this time."
I tried:
```
if "%DevEnvD... | Just put quotes around the Environment variable (as you have already done):
```
if "%DevEnvDir%" == "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\"
```
The strings you are comparing are fine, the problem is the way you put the opening bracket without a space. That is confusing it.
Works for me...
... |
9362692 | How to create ls in windows command prompt? | 130 | 2012-02-20 14:25:17 | <p>I want to use ls in windows command prompt and make it run the dir command.</p>
<p>How can I do that?</p>
| 183,927 | 187,730 | 2025-05-25 15:38:31 | 9,362,783 | 124 | 2012-02-20 14:32:38 | 1,033,896 | 2012-02-20 14:32:38 | https://stackoverflow.com/q/9362692 | https://stackoverflow.com/a/9362783 | <p>You could:</p>
<ul>
<li>create a batch file called <code>ls.bat</code> and have it contain the <code>dir</code> command only</li>
<li>add the directory where the <code>ls.bat</code> file exists to your <code>PATH</code> environment variable</li>
</ul>
<p>You could then execute <code>ls</code> from a command prompt... | <p>You could:</p> <ul> <li>create a batch file called <code>ls.bat</code> and have it contain the <code>dir</code> command only</li> <li>add the directory where the <code>ls.bat</code> file exists to your <code>PATH</code> environment variable</li> </ul> <p>You could then execute <code>ls</code> from a command prompt... | 64, 2216, 2631, 3589, 14208 | cmd, dir, ls, windows, windows-xp | <h1>How to create ls in windows command prompt?</h1>
<p>I want to use ls in windows command prompt and make it run the dir command.</p>
<p>How can I do that?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,992 | cmd | # How to create ls in windows command prompt?
I want to use ls in windows command prompt and make it run the dir command.
How can I do that? | You could:
- create a batch file called `ls.bat` and have it contain the `dir` command only
- add the directory where the `ls.bat` file exists to your `PATH` environment variable
You could then execute `ls` from a command prompt. |
22815542 | rails4 unknown encoding name - CP720 | 39 | 2014-04-02 15:02:32 | <p>I got now this error When I want to run any gem commands such as</p>
<pre><code> gem install rubygems-update
</code></pre>
<p>the error</p>
<pre><code>while executing gem ... (ArgumentError)
unknown encoding name - CP720
</code></pre>
<p>so when I goggled it I found some one suggest to use this commands to Chan... | 19,848 | 2,487,778 | 2015-03-22 20:33:18 | 22,861,206 | 124 | 2014-04-04 11:11:53 | 232,082 | 2014-08-20 12:26:52 | https://stackoverflow.com/q/22815542 | https://stackoverflow.com/a/22861206 | <p>This command fixed it for me (without the second command);</p>
<pre><code>chcp 1252
</code></pre>
<p>This changes the code page of the current terminal.</p>
<p><strong>UPDATE; why this happens?</strong></p>
<p>From <a href="https://github.com/oneclick/rubyinstaller/issues/193#issuecomment-26605470" rel="noreferr... | <p>This command fixed it for me (without the second command);</p> <pre><code>chcp 1252 </code></pre> <p>This changes the code page of the current terminal.</p> <p><strong>UPDATE; why this happens?</strong></p> <p>From <a href="https://github.com/oneclick/rubyinstaller/issues/193#issuecomment-26605470" rel="noreferr... | 12, 1231, 2631, 4984 | cmd, command-line, ruby, ruby-on-rails | <h1>rails4 unknown encoding name - CP720</h1>
<p>I got now this error When I want to run any gem commands such as</p>
<pre><code> gem install rubygems-update
</code></pre>
<p>the error</p>
<pre><code>while executing gem ... (ArgumentError)
unknown encoding name - CP720
</code></pre>
<p>so when I goggled it I found... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,994 | cmd | # rails4 unknown encoding name - CP720
I got now this error When I want to run any gem commands such as
```
gem install rubygems-update
```
the error
```
while executing gem ... (ArgumentError)
unknown encoding name - CP720
```
so when I goggled it I found some one suggest to use this commands to Change encoding ... | This command fixed it for me (without the second command);
```
chcp 1252
```
This changes the code page of the current terminal.
**UPDATE; why this happens?**
From [some other resources](https://github.com/oneclick/rubyinstaller/issues/193#issuecomment-26605470), this is caused by your current terminal as it is usi... |
673523 | How do I measure execution time of a command on the Windows command line? | 677 | 2009-03-23 14:13:43 | <p>Is there a built-in way to measure execution time of a command on the Windows command line?</p>
| 608,160 | 79,078 | 2024-10-14 04:06:03 | 752,307 | 123 | 2009-04-15 15:44:29 | null | 2021-07-06 17:25:58 | https://stackoverflow.com/q/673523 | https://stackoverflow.com/a/752307 | <p>If you are using Windows 2003 (note that windows server 2008 and later are not supported) you can use The Windows Server 2003 Resource Kit, which contains timeit.exe that displays detailed execution stats. Here is an example, timing the command "timeit -?":</p>
<pre><code>C:\>timeit timeit -?
Invalid s... | <p>If you are using Windows 2003 (note that windows server 2008 and later are not supported) you can use The Windows Server 2003 Resource Kit, which contains timeit.exe that displays detailed execution stats. Here is an example, timing the command "timeit -?":</p> <pre><code>C:\>timeit timeit -? Invalid s... | 64, 603, 2631, 7002, 23964 | batch-file, cmd, time, windows, windows-server-2003 | <h1>How do I measure execution time of a command on the Windows command line?</h1>
<p>Is there a built-in way to measure execution time of a command on the Windows command line?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,995 | cmd | # How do I measure execution time of a command on the Windows command line?
Is there a built-in way to measure execution time of a command on the Windows command line? | If you are using Windows 2003 (note that windows server 2008 and later are not supported) you can use The Windows Server 2003 Resource Kit, which contains timeit.exe that displays detailed execution stats. Here is an example, timing the command "timeit -?":
```
C:\>timeit timeit -?
Invalid switch -?
Usage: TIMEIT [-f ... |
11865085 | Out of a git console: how do I execute a batch file and then return to git console? | 95 | 2012-08-08 13:01:37 | <p>I have a small utility script called <code>clear.bat</code> that does some housekeeping work on my sources.</p>
<p>It is a <code>.bat</code> file so that I could easily double-click it in Windows Explorer.</p>
<p>Sometimes, I find it more handy to execute it from my Git bash (msysgit, if this matters).</p>
<p>To ... | 104,909 | 520,162 | 2023-09-19 03:36:54 | 11,878,147 | 123 | 2012-08-09 06:50:09 | 520,162 | 2012-08-09 06:50:09 | https://stackoverflow.com/q/11865085 | https://stackoverflow.com/a/11878147 | <p>After playing around a bit more, I found the solution myself:</p>
<pre><code>cmd "/C clean.bat"
</code></pre>
<p>does the trick. But I got no clue, why...</p>
| <p>After playing around a bit more, I found the solution myself:</p> <pre><code>cmd "/C clean.bat" </code></pre> <p>does the trick. But I got no clue, why...</p> | 64, 119, 2631, 7002 | batch-file, cmd, git, windows | <h1>Out of a git console: how do I execute a batch file and then return to git console?</h1>
<p>I have a small utility script called <code>clear.bat</code> that does some housekeeping work on my sources.</p>
<p>It is a <code>.bat</code> file so that I could easily double-click it in Windows Explorer.</p>
<p>Sometimes... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,997 | cmd | # Out of a git console: how do I execute a batch file and then return to git console?
I have a small utility script called `clear.bat` that does some housekeeping work on my sources.
It is a `.bat` file so that I could easily double-click it in Windows Explorer.
Sometimes, I find it more handy to execute it from my ... | After playing around a bit more, I found the solution myself:
```
cmd "/C clean.bat"
```
does the trick. But I got no clue, why... |
21606419 | Set windows environment variables with a batch file | 91 | 2014-02-06 15:03:14 | <p>I was looking for a way to set the environment path variable with a .cmd file.<br>
When the path variable was getting too long, I got some errors.<br>
Just add the needed variables to 'Set Path variable' below<br>
Check the current value of your path variable and add to the script<br>
<strong>Run the script as admin... | 347,940 | 527,965 | 2025-09-28 13:44:41 | 21,606,502 | 123 | 2014-02-06 15:06:24 | 527,965 | 2025-09-28 13:44:41 | https://stackoverflow.com/q/21606419 | https://stackoverflow.com/a/21606502 | <p>This batch file must be <strong>run as administrator</strong> to update <strong>system</strong> environment variable <code>Path</code> and set/update <strong>system</strong> environment variable <code>JAVA_HOME</code>.</p>
<pre><code>@ECHO OFF
:: %ALLUSERSPROFILE% = C:\ProgramData
:: %ProgramFiles% = C:\Program Fil... | <p>This batch file must be <strong>run as administrator</strong> to update <strong>system</strong> environment variable <code>Path</code> and set/update <strong>system</strong> environment variable <code>JAVA_HOME</code>.</p> <pre><code>@ECHO OFF :: %ALLUSERSPROFILE% = C:\ProgramData :: %ProgramFiles% = C:\Program Fil... | 64, 421, 2631, 6268, 7002 | batch-file, cmd, environment, path, windows | <h1>Set windows environment variables with a batch file</h1>
<p>I was looking for a way to set the environment path variable with a .cmd file.<br>
When the path variable was getting too long, I got some errors.<br>
Just add the needed variables to 'Set Path variable' below<br>
Check the current value of your path varia... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,998 | cmd | # Set windows environment variables with a batch file
I was looking for a way to set the environment path variable with a .cmd file.
When the path variable was getting too long, I got some errors.
Just add the needed variables to 'Set Path variable' below
Check the current value of your path variable and add to ... | This batch file must be **run as administrator** to update **system** environment variable `Path` and set/update **system** environment variable `JAVA_HOME`.
```
@ECHO OFF
:: %ALLUSERSPROFILE% = C:\ProgramData
:: %ProgramFiles% = C:\Program Files
:: %USERPROFILE% = C:\Users\Ruben
:: %SystemDrive% = C:
:: %SystemRoot%... |
25760596 | How to terminate OpenSSL s_client after connection | 67 | 2014-09-10 08:23:24 | <p>(Reviewers: I also know this is straying into SuperUser territory, but if the previous question snuck through ... :) )</p>
<p>This is very similar to <a href="https://stackoverflow.com/questions/10394378/how-to-terminate-an-openssl-handshake-from-a-batch-file">this question</a>, but in an Windows (7/8/Server 2008/2... | 57,405 | 266,553 | 2023-10-26 08:31:08 | 34,749,879 | 123 | 2016-01-12 17:15:47 | 4,564,560 | 2023-05-13 17:58:38 | https://stackoverflow.com/q/25760596 | https://stackoverflow.com/a/34749879 | <p>You can achieve the desired effect by using a pipe to pass in the character "Q". This makes for a great one-liner for a script:</p>
<pre class="lang-bash prettyprint-override"><code>echo "Q" | openssl s_client -connect host:port
</code></pre>
<p>If you are using a sufficiently new version of BAS... | <p>You can achieve the desired effect by using a pipe to pass in the character "Q". This makes for a great one-liner for a script:</p> <pre class="lang-bash prettyprint-override"><code>echo "Q" | openssl s_client -connect host:port </code></pre> <p>If you are using a sufficiently new version of BAS... | 64, 1999, 7002 | batch-file, openssl, windows | <h1>How to terminate OpenSSL s_client after connection</h1>
<p>(Reviewers: I also know this is straying into SuperUser territory, but if the previous question snuck through ... :) )</p>
<p>This is very similar to <a href="https://stackoverflow.com/questions/10394378/how-to-terminate-an-openssl-handshake-from-a-batch-f... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,999 | cmd | # How to terminate OpenSSL s_client after connection
(Reviewers: I also know this is straying into SuperUser territory, but if the previous question snuck through ... :) )
This is very similar to [this question](https://stackoverflow.com/questions/10394378/how-to-terminate-an-openssl-handshake-from-a-batch-file), but... | You can achieve the desired effect by using a pipe to pass in the character "Q". This makes for a great one-liner for a script:
```
echo "Q" | openssl s_client -connect host:port
```
If you are using a sufficiently new version of BASH, you can also use the triple less-than redirect instead of piping (some times a pip... |
4458231 | Appending output of a Batch file To log file | 54 | 2010-12-16 07:01:34 | <p>I have a batch file which calls a java program.</p>
<p>The output is redirected to a log file in the same directory.
However the log file is replaced everytime the batch file is run...</p>
<p>I would like to keep the old outputs in the log file and always append the new output to the log file.</p>
| 150,721 | 544,394 | 2020-03-12 03:52:40 | 4,458,242 | 122 | 2010-12-16 07:04:04 | 22,656 | 2017-08-23 23:29:12 | https://stackoverflow.com/q/4458231 | https://stackoverflow.com/a/4458242 | <p>Instead of using ">" to redirect like this:</p>
<pre><code>java Foo > log
</code></pre>
<p>use ">>" to append normal "stdout" output to a new or existing file:</p>
<pre><code>java Foo >> log
</code></pre>
<p>However, if you also want to capture "stderr" errors (such as why the Java program couldn't be s... | <p>Instead of using ">" to redirect like this:</p> <pre><code>java Foo > log </code></pre> <p>use ">>" to append normal "stdout" output to a new or existing file:</p> <pre><code>java Foo >> log </code></pre> <p>However, if you also want to capture "stderr" errors (such as why the Java program couldn't be s... | 7002 | batch-file | <h1>Appending output of a Batch file To log file</h1>
<p>I have a batch file which calls a java program.</p>
<p>The output is redirected to a log file in the same directory.
However the log file is replaced everytime the batch file is run...</p>
<p>I would like to keep the old outputs in the log file and always appen... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,000 | cmd | # Appending output of a Batch file To log file
I have a batch file which calls a java program.
The output is redirected to a log file in the same directory.
However the log file is replaced everytime the batch file is run...
I would like to keep the old outputs in the log file and always append the new output to the... | Instead of using ">" to redirect like this:
```
java Foo > log
```
use ">>" to append normal "stdout" output to a new or existing file:
```
java Foo >> log
```
However, if you also want to capture "stderr" errors (such as why the Java program couldn't be started), you should also use the "2>&1" tag which redirects ... |
14502612 | Delete a directory and its files using command line but don't throw error if it doesn't exist | 139 | 2013-01-24 13:34:00 | <p>I need a Windows command to delete a directory and all its containing files but I do not want to see any errors if the directory does not exist.</p>
| 144,647 | 729,082 | 2025-06-08 11:18:19 | 14,502,670 | 121 | 2013-01-24 13:36:46 | 511,529 | 2021-04-30 20:17:36 | https://stackoverflow.com/q/14502612 | https://stackoverflow.com/a/14502670 | <p>Redirect the output of the <code>del</code> command to nul. Note the <code>2</code>, to indicate error output should be redirected. See also <a href="https://stackoverflow.com/questions/4507312/how-to-redirect-stderr-to-null-in-cmd-exe">this question</a>, and especially the tech doc <a href="https://learn.microsoft.... | <p>Redirect the output of the <code>del</code> command to nul. Note the <code>2</code>, to indicate error output should be redirected. See also <a href="https://stackoverflow.com/questions/4507312/how-to-redirect-stderr-to-null-in-cmd-exe">this question</a>, and especially the tech doc <a href="https://learn.microsoft.... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Delete a directory and its files using command line but don't throw error if it doesn't exist</h1>
<p>I need a Windows command to delete a directory and all its containing files but I do not want to see any errors if the directory does not exist.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,001 | cmd | # Delete a directory and its files using command line but don't throw error if it doesn't exist
I need a Windows command to delete a directory and all its containing files but I do not want to see any errors if the directory does not exist. | Redirect the output of the `del` command to nul. Note the `2`, to indicate error output should be redirected. See also [this question](https://stackoverflow.com/questions/4507312/how-to-redirect-stderr-to-null-in-cmd-exe), and especially the tech doc [Using command redirection operators](https://learn.microsoft.com/en-... |
1064557 | Creating a file name as a timestamp in a batch job | 103 | 2009-06-30 16:03:02 | <p>We have a batch job that runs every day and copies a file to a pickup folder. I want to also take a copy of that file and drop it into an archive folder with the filename</p>
<pre><code> yyyy-MM-dd.log
</code></pre>
<p>What's the easiest way to do this in a Windows batch job?</p>
<p>I'm basically looking for an e... | 362,019 | 30,155 | 2025-07-24 04:26:34 | 1,064,648 | 120 | 2009-06-30 16:19:50 | 131,129 | 2014-05-27 15:45:35 | https://stackoverflow.com/q/1064557 | https://stackoverflow.com/a/1064648 | <pre><code>CP source.log %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%.log
</code></pre>
<p>But it's locale dependent. I'm not sure if <code>%DATE%</code> is localized, or depends on the format specified for the short date in Windows.</p>
<p>Here is a locale-independent way to extract the current date from <a href="https://sta... | <pre><code>CP source.log %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%.log </code></pre> <p>But it's locale dependent. I'm not sure if <code>%DATE%</code> is localized, or depends on the format specified for the short date in Windows.</p> <p>Here is a locale-independent way to extract the current date from <a href="https://sta... | 64, 2177, 2631, 7002 | batch-file, cmd, timestamp, windows | <h1>Creating a file name as a timestamp in a batch job</h1>
<p>We have a batch job that runs every day and copies a file to a pickup folder. I want to also take a copy of that file and drop it into an archive folder with the filename</p>
<pre><code> yyyy-MM-dd.log
</code></pre>
<p>What's the easiest way to do this in... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,003 | cmd | # Creating a file name as a timestamp in a batch job
We have a batch job that runs every day and copies a file to a pickup folder. I want to also take a copy of that file and drop it into an archive folder with the filename
```
yyyy-MM-dd.log
```
What's the easiest way to do this in a Windows batch job?
I'm basica... | ```
CP source.log %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%.log
```
But it's locale dependent. I'm not sure if `%DATE%` is localized, or depends on the format specified for the short date in Windows.
Here is a locale-independent way to extract the current date from [this answer](https://stackoverflow.com/questions/203090/#2... |
8438511 | IF... OR IF... in a windows batch file | 134 | 2011-12-08 22:19:36 | <p>Is there a way to write an IF OR IF conditional statement in a windows batch-file? </p>
<p>For example:</p>
<pre><code>IF [%var%] == [1] OR IF [%var%] == [2] ECHO TRUE
</code></pre>
| 462,335 | 781,339 | 2023-04-14 12:55:47 | 8,439,069 | 119 | 2011-12-08 23:13:30 | 1,012,053 | 2020-07-08 02:27:36 | https://stackoverflow.com/q/8438511 | https://stackoverflow.com/a/8439069 | <p>The zmbq solution is good, but cannot be used in all situations, such as inside a block of code like a FOR DO(...) loop.</p>
<p>An alternative is to use an indicator variable. Initialize it to be undefined, and then define it only if any one of the OR conditions is true. Then use IF DEFINED as a final test - no need... | <p>The zmbq solution is good, but cannot be used in all situations, such as inside a block of code like a FOR DO(...) loop.</p> <p>An alternative is to use an indicator variable. Initialize it to be undefined, and then define it only if any one of the OR conditions is true. Then use IF DEFINED as a final test - no need... | 64, 2631, 2773, 7002, 39271 | batch-file, cmd, conditional-statements, if-statement, windows | <h1>IF... OR IF... in a windows batch file</h1>
<p>Is there a way to write an IF OR IF conditional statement in a windows batch-file? </p>
<p>For example:</p>
<pre><code>IF [%var%] == [1] OR IF [%var%] == [2] ECHO TRUE
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,004 | cmd | # IF... OR IF... in a windows batch file
Is there a way to write an IF OR IF conditional statement in a windows batch-file?
For example:
```
IF [%var%] == [1] OR IF [%var%] == [2] ECHO TRUE
``` | The zmbq solution is good, but cannot be used in all situations, such as inside a block of code like a FOR DO(...) loop.
An alternative is to use an indicator variable. Initialize it to be undefined, and then define it only if any one of the OR conditions is true. Then use IF DEFINED as a final test - no need to use d... |
225735 | Batch Renaming of Files in a Directory | 107 | 2008-10-22 13:33:23 | <p>Is there an easy way to rename a group of files already contained in a directory, using Python?</p>
<p><strong>Example:</strong> I have a directory full of *.doc files and I want to rename them in a consistent way.</p>
<blockquote>
<p>X.doc -> "new(X).doc"</p>
<p>Y.doc -> "new(Y).doc"</p>
</blockquote>
| 191,361 | 11,760 | 2021-08-30 19:19:59 | 227,125 | 119 | 2008-10-22 18:59:57 | 18,745 | 2008-10-22 18:59:57 | https://stackoverflow.com/q/225735 | https://stackoverflow.com/a/227125 | <p>Such renaming is quite easy, for example with <a href="http://docs.python.org/lib/module-os.html" rel="noreferrer">os</a> and <a href="http://docs.python.org/lib/module-glob.html" rel="noreferrer">glob</a> modules:</p>
<pre><code>import glob, os
def rename(dir, pattern, titlePattern):
for pathAndFilename in gl... | <p>Such renaming is quite easy, for example with <a href="http://docs.python.org/lib/module-os.html" rel="noreferrer">os</a> and <a href="http://docs.python.org/lib/module-glob.html" rel="noreferrer">glob</a> modules:</p> <pre><code>import glob, os def rename(dir, pattern, titlePattern): for pathAndFilename in gl... | 16, 724, 4510, 13475 | batch-rename, file-io, python, rename | <h1>Batch Renaming of Files in a Directory</h1>
<p>Is there an easy way to rename a group of files already contained in a directory, using Python?</p>
<p><strong>Example:</strong> I have a directory full of *.doc files and I want to rename them in a consistent way.</p>
<blockquote>
<p>X.doc -> "new(X).doc"</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,005 | cmd | # Batch Renaming of Files in a Directory
Is there an easy way to rename a group of files already contained in a directory, using Python?
**Example:** I have a directory full of *.doc files and I want to rename them in a consistent way.
> X.doc -> "new(X).doc"
>
> Y.doc -> "new(Y).doc" | Such renaming is quite easy, for example with [os](http://docs.python.org/lib/module-os.html) and [glob](http://docs.python.org/lib/module-glob.html) modules:
```
import glob, os
def rename(dir, pattern, titlePattern):
for pathAndFilename in glob.iglob(os.path.join(dir, pattern)):
title, ext = os.path.spl... |
2772456 | String replacement in batch file | 134 | 2010-05-05 10:43:23 | <p>We can replace strings in a batch file using the following command</p>
<pre><code>set str="jump over the chair"
set str=%str:chair=table%
</code></pre>
<p>These lines work fine and change the string "jump over the chair" to "jump over the table". Now I want to replace the word "chair" in the string with some varia... | 301,331 | 238,626 | 2022-07-06 12:44:05 | 2,773,504 | 118 | 2010-05-05 13:17:22 | 73,070 | 2010-05-05 13:17:22 | https://stackoverflow.com/q/2772456 | https://stackoverflow.com/a/2773504 | <p>You can use the following little trick:</p>
<pre><code>set word=table
set str="jump over the chair"
call set str=%%str:chair=%word%%%
echo %str%
</code></pre>
<p>The <code>call</code> there causes another layer of variable expansion, making it necessary to quote the original <code>%</code> signs but it all works o... | <p>You can use the following little trick:</p> <pre><code>set word=table set str="jump over the chair" call set str=%%str:chair=%word%%% echo %str% </code></pre> <p>The <code>call</code> there causes another layer of variable expansion, making it necessary to quote the original <code>%</code> signs but it all works o... | 1231, 7002 | batch-file, command-line | <h1>String replacement in batch file</h1>
<p>We can replace strings in a batch file using the following command</p>
<pre><code>set str="jump over the chair"
set str=%str:chair=table%
</code></pre>
<p>These lines work fine and change the string "jump over the chair" to "jump over the table". Now I want to replace the ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,006 | cmd | # String replacement in batch file
We can replace strings in a batch file using the following command
```
set str="jump over the chair"
set str=%str:chair=table%
```
These lines work fine and change the string "jump over the chair" to "jump over the table". Now I want to replace the word "chair" in the string with s... | You can use the following little trick:
```
set word=table
set str="jump over the chair"
call set str=%%str:chair=%word%%%
echo %str%
```
The `call` there causes another layer of variable expansion, making it necessary to quote the original `%` signs but it all works out in the end. |
6789491 | batch script to set a variable with the current path location | 64 | 2011-07-22 11:44:03 | <p>How can I set a variable with the current location? For instance, if I get in <code>c:\test</code> and want to set the variable to <code>test</code> and if I get inside <code>c:\test\test2</code> the variable will be set to <code>test2</code>.</p>
<p>I'm thinking about using a <code>for</code> to get inside a lot of... | 119,127 | 853,970 | 2021-01-05 09:51:12 | 6,789,530 | 118 | 2011-07-22 11:46:59 | 463,115 | 2011-07-22 11:46:59 | https://stackoverflow.com/q/6789491 | https://stackoverflow.com/a/6789530 | <p>The current directory is in the "shadow" variable cd.<br>
You could try</p>
<pre><code>set "var=%cd%"
</code></pre>
| <p>The current directory is in the "shadow" variable cd.<br> You could try</p> <pre><code>set "var=%cd%" </code></pre> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>batch script to set a variable with the current path location</h1>
<p>How can I set a variable with the current location? For instance, if I get in <code>c:\test</code> and want to set the variable to <code>test</code> and if I get inside <code>c:\test\test2</code> the variable will be set to <code>test2</code>.</p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,007 | cmd | # batch script to set a variable with the current path location
How can I set a variable with the current location? For instance, if I get in `c:\test` and want to set the variable to `test` and if I get inside `c:\test\test2` the variable will be set to `test2`.
I'm thinking about using a `for` to get inside a lot o... | The current directory is in the "shadow" variable cd.
You could try
```
set "var=%cd%"
``` |
1458636 | how to do "press enter to exit" in batch | 102 | 2009-09-22 07:36:25 | <p>I am using rake to build my project and I have a build.bat file similar to this:</p>
<pre><code>@echo off
cls
rake
</code></pre>
<p>When I double click on build.bat the dos window pops up and shows all the progress but closes itself when the task is finished. Is there way to do a Console.ReadLine so that user can ... | 313,297 | 52,752 | 2021-07-30 18:01:55 | 1,458,695 | 115 | 2009-09-22 07:57:02 | 125,562 | 2009-09-22 07:57:02 | https://stackoverflow.com/q/1458636 | https://stackoverflow.com/a/1458695 | <p>Default interpreters from Microsoft are done in a way, that causes them exit when they reach EOF. If rake is another batch file, command interpreter switches to it and exits when rake interpretation is finished. To prevent this write:</p>
<pre><code>@echo off
cls
call rake
pause
</code></pre>
<p>IMHO, call operato... | <p>Default interpreters from Microsoft are done in a way, that causes them exit when they reach EOF. If rake is another batch file, command interpreter switches to it and exits when rake interpretation is finished. To prevent this write:</p> <pre><code>@echo off cls call rake pause </code></pre> <p>IMHO, call operato... | 650, 7002 | batch-file, rake | <h1>how to do "press enter to exit" in batch</h1>
<p>I am using rake to build my project and I have a build.bat file similar to this:</p>
<pre><code>@echo off
cls
rake
</code></pre>
<p>When I double click on build.bat the dos window pops up and shows all the progress but closes itself when the task is finished. Is th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,008 | cmd | # how to do "press enter to exit" in batch
I am using rake to build my project and I have a build.bat file similar to this:
```
@echo off
cls
rake
```
When I double click on build.bat the dos window pops up and shows all the progress but closes itself when the task is finished. Is there way to do a Console.ReadLine ... | Default interpreters from Microsoft are done in a way, that causes them exit when they reach EOF. If rake is another batch file, command interpreter switches to it and exits when rake interpretation is finished. To prevent this write:
```
@echo off
cls
call rake
pause
```
IMHO, call operator will lauch another instan... |
3923596 | Git Windows Command Prompt gets stuck during Git commands with (END) | 65 | 2010-10-13 12:28:56 | <p>I've got Git for Windows setup (msysgit) and it was working fine for the last few days and today I've encountered an odd error. </p>
<p>When issuing a Git command in the Windows Command Prompt or in the Git Bash that comes bundled with msysgit, I get a strange '(END)' line appear and then I cannot issue any other c... | 29,587 | 156,406 | 2015-05-20 16:31:23 | 3,923,614 | 115 | 2010-10-13 12:31:29 | 46,594 | 2012-04-19 12:41:19 | https://stackoverflow.com/q/3923596 | https://stackoverflow.com/a/3923614 | <p>Git want to show more than one screen of information to you, to do so it call the standard unix pager program <code>less</code>. Just type <kbd>q</kbd> to return to the prompt when you no longer want to navigate in the output.</p>
<ul>
<li><kbd>j</kbd> move one line down</li>
<li><kbd>k</kbd> move one line up</li>
... | <p>Git want to show more than one screen of information to you, to do so it call the standard unix pager program <code>less</code>. Just type <kbd>q</kbd> to return to the prompt when you no longer want to navigate in the output.</p> <ul> <li><kbd>j</kbd> move one line down</li> <li><kbd>k</kbd> move one line up</li> ... | 64, 119, 1231, 2631, 21628 | cmd, command-line, git, msysgit, windows | <h1>Git Windows Command Prompt gets stuck during Git commands with (END)</h1>
<p>I've got Git for Windows setup (msysgit) and it was working fine for the last few days and today I've encountered an odd error. </p>
<p>When issuing a Git command in the Windows Command Prompt or in the Git Bash that comes bundled with ms... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,009 | cmd | # Git Windows Command Prompt gets stuck during Git commands with (END)
I've got Git for Windows setup (msysgit) and it was working fine for the last few days and today I've encountered an odd error.
When issuing a Git command in the Windows Command Prompt or in the Git Bash that comes bundled with msysgit, I get a st... | Git want to show more than one screen of information to you, to do so it call the standard unix pager program `less`. Just type `q` to return to the prompt when you no longer want to navigate in the output.
- `j` move one line down
- `k` move one line up
- `<space>` move one page down
- `b` move one page up
- `h` show... |
34786669 | Extract all video frames as images with FFMPEG | 63 | 2016-01-14 10:05:43 | <p>I am trying to convert a MP4 video file into a series of jpg images (out-1.jpg, out-2.jpg etc.) using FFMPEG with,</p>
<pre><code>mkdir frames
ffmpeg -i "%1" -r 1 frames/out-%03d.jpg
</code></pre>
<p>However I keep getting errors like,</p>
<blockquote>
<p>[image2 @ 00000037f5a811a0] Could not open file :
fram... | 163,657 | 780,756 | 2024-08-18 22:20:05 | 34,786,929 | 115 | 2016-01-14 10:16:46 | 5,726,027 | 2016-01-14 10:43:00 | https://stackoverflow.com/q/34786669 | https://stackoverflow.com/a/34786929 | <p>Use</p>
<pre><code>ffmpeg -i "%1" frames/out-%03d.jpg
</code></pre>
<p>A sequence of image files don't have a framerate. If you want to undersample the video file, use <code>-r</code> before the input.</p>
<p><strong>Edit</strong>:</p>
<pre><code>ffmpeg -i "C:\Applications\FFMPEG\aa.mp4" "frames/out-%03d.jpg"
</... | <p>Use</p> <pre><code>ffmpeg -i "%1" frames/out-%03d.jpg </code></pre> <p>A sequence of image files don't have a framerate. If you want to undersample the video file, use <code>-r</code> before the input.</p> <p><strong>Edit</strong>:</p> <pre><code>ffmpeg -i "C:\Applications\FFMPEG\aa.mp4" "frames/out-%03d.jpg" </... | 519, 1231, 3847, 4985, 7002 | batch-file, command-line, ffmpeg, image, video | <h1>Extract all video frames as images with FFMPEG</h1>
<p>I am trying to convert a MP4 video file into a series of jpg images (out-1.jpg, out-2.jpg etc.) using FFMPEG with,</p>
<pre><code>mkdir frames
ffmpeg -i "%1" -r 1 frames/out-%03d.jpg
</code></pre>
<p>However I keep getting errors like,</p>
<blockquote>
<p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,010 | cmd | # Extract all video frames as images with FFMPEG
I am trying to convert a MP4 video file into a series of jpg images (out-1.jpg, out-2.jpg etc.) using FFMPEG with,
```
mkdir frames
ffmpeg -i "%1" -r 1 frames/out-%03d.jpg
```
However I keep getting errors like,
> [image2 @ 00000037f5a811a0] Could not open file :
> f... | Use
```
ffmpeg -i "%1" frames/out-%03d.jpg
```
A sequence of image files don't have a framerate. If you want to undersample the video file, use `-r` before the input.
**Edit**:
```
ffmpeg -i "C:\Applications\FFMPEG\aa.mp4" "frames/out-%03d.jpg"
``` |
18499797 | Less than or equal to | 49 | 2013-08-28 23:12:27 | <p>Using the pause command I found that the error is in the first line of this code:</p>
<pre><code>if %choice% == 1 if %energy% => %m2enc% set /a enemhp=%enemhp%-%m1hpd%+%earmr%
pause
set /a energy= %energy%-%m1enc%
set /a hp= %hp%-%edefense%
set /a defense= %defense%+1
goto battle
</code></pre>
<p>So don't say t... | 166,726 | 2,727,271 | 2017-10-05 19:33:33 | 18,499,854 | 114 | 2013-08-28 23:20:03 | 2,465,667 | 2013-08-29 01:40:09 | https://stackoverflow.com/q/18499797 | https://stackoverflow.com/a/18499854 | <p>In batch, the <code>></code> is a redirection sign used to output data into a text file. The compare op's available (And recommended) for cmd are below (quoted from the <code>if /?</code> help):</p>
<pre><code>where compare-op may be one of:
EQU - equal
NEQ - not equal
LSS - less than
LEQ - less... | <p>In batch, the <code>></code> is a redirection sign used to output data into a text file. The compare op's available (And recommended) for cmd are below (quoted from the <code>if /?</code> help):</p> <pre><code>where compare-op may be one of: EQU - equal NEQ - not equal LSS - less than LEQ - less... | 7002 | batch-file | <h1>Less than or equal to</h1>
<p>Using the pause command I found that the error is in the first line of this code:</p>
<pre><code>if %choice% == 1 if %energy% => %m2enc% set /a enemhp=%enemhp%-%m1hpd%+%earmr%
pause
set /a energy= %energy%-%m1enc%
set /a hp= %hp%-%edefense%
set /a defense= %defense%+1
goto battle
<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,011 | cmd | # Less than or equal to
Using the pause command I found that the error is in the first line of this code:
```
if %choice% == 1 if %energy% => %m2enc% set /a enemhp=%enemhp%-%m1hpd%+%earmr%
pause
set /a energy= %energy%-%m1enc%
set /a hp= %hp%-%edefense%
set /a defense= %defense%+1
goto battle
```
So don't say that I... | In batch, the `>` is a redirection sign used to output data into a text file. The compare op's available (And recommended) for cmd are below (quoted from the `if /?` help):
```
where compare-op may be one of:
EQU - equal
NEQ - not equal
LSS - less than
LEQ - less than or equal
GTR - greater than
... |
2951063 | How do I recursively list all files of type *.mp3 in a Windows .bat file? | 47 | 2010-06-01 15:32:00 | <p>I want to recursively list the absolute path to all files that end with <code>mp3</code> from a given directory which should be given as relative directory.</p>
<p>I would then like to strip also the directory from the file and I have read that variables which are in a <code>for</code>-scope must be enclosed in <co... | 111,908 | 97,688 | 2018-10-07 13:49:39 | 2,951,118 | 114 | 2010-06-01 15:38:32 | 89,586 | 2018-10-07 13:44:49 | https://stackoverflow.com/q/2951063 | https://stackoverflow.com/a/2951118 | <p>Use the command <code>DIR</code>:</p>
<pre><code>dir /s/b *.mp3
</code></pre>
<p>The above command will search the current path and all of its children. To get more information on how to use this command, open a command window and type <code>DIR /?</code>.</p>
| <p>Use the command <code>DIR</code>:</p> <pre><code>dir /s/b *.mp3 </code></pre> <p>The above command will search the current path and all of its children. To get more information on how to use this command, open a command window and type <code>DIR /?</code>.</p> | 64, 218, 7002 | batch-file, directory, windows | <h1>How do I recursively list all files of type *.mp3 in a Windows .bat file?</h1>
<p>I want to recursively list the absolute path to all files that end with <code>mp3</code> from a given directory which should be given as relative directory.</p>
<p>I would then like to strip also the directory from the file and I hav... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,012 | cmd | # How do I recursively list all files of type *.mp3 in a Windows .bat file?
I want to recursively list the absolute path to all files that end with `mp3` from a given directory which should be given as relative directory.
I would then like to strip also the directory from the file and I have read that variables which... | Use the command `DIR`:
```
dir /s/b *.mp3
```
The above command will search the current path and all of its children. To get more information on how to use this command, open a command window and type `DIR /?`. |
9794696 | Which HTTP status code means "Not Ready Yet, Try Again Later"? | 247 | 2012-03-20 20:49:23 | <p>I'm developing a RESTful API in which <code>http://server/thingyapi/thingyblob/1234</code> returns the file (aka "blob") associated with item #1234 to download. But the request could be made before the file has been generated. It definitely <strong>will</strong> be available at a later time.</p>
<p>There's... | 140,770 | 110,800 | 2023-08-11 15:25:51 | 12,281,287 | 113 | 2012-09-05 12:20:01 | 545,127 | 2019-03-07 17:46:36 | https://stackoverflow.com/q/9794696 | https://stackoverflow.com/a/12281287 | <p>The "problem", such as it is, is on the server side: the client has made a well formed request, but the server can not satisfy it. So I'm inclined to a "Server Error", 5xx status code.</p>
<p>Quoth <a href="https://www.rfc-editor.org/rfc/rfc7231#section-6.6" rel="noreferrer">RFC 7231</a> (the cur... | <p>The "problem", such as it is, is on the server side: the client has made a well formed request, but the server can not satisfy it. So I'm inclined to a "Server Error", 5xx status code.</p> <p>Quoth <a href="https://www.rfc-editor.org/rfc/rfc7231#section-6.6" rel="noreferrer">RFC 7231</a> (the cur... | 33, 364, 5210, 12832, 30645 | batch-processing, http, http-status-codes, language-agnostic, rest | <h1>Which HTTP status code means "Not Ready Yet, Try Again Later"?</h1>
<p>I'm developing a RESTful API in which <code>http://server/thingyapi/thingyblob/1234</code> returns the file (aka "blob") associated with item #1234 to download. But the request could be made before the file has been generated. It defin... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,013 | cmd | # Which HTTP status code means "Not Ready Yet, Try Again Later"?
I'm developing a RESTful API in which `http://server/thingyapi/thingyblob/1234` returns the file (aka "blob") associated with item #1234 to download. But the request could be made before the file has been generated. It definitely **will** be available at... | The "problem", such as it is, is on the server side: the client has made a well formed request, but the server can not satisfy it. So I'm inclined to a "Server Error", 5xx status code.
Quoth [RFC 7231](https://www.rfc-editor.org/rfc/rfc7231#section-6.6) (the current HTTP standard, emphasis added):
> The 5xx (Server E... |
24906268 | Ping with timestamp on Windows CLI | 133 | 2014-07-23 09:04:38 | <p>On the Windows command prompt <code>cmd</code>, I use <code>ping -t to 10.21.11.81</code><br/></p>
<pre><code>Reply from 10.21.11.81: bytes=32 time=3889ms TTL=238
Reply from 10.21.11.81: bytes=32 time=3738ms TTL=238
Reply from 10.21.11.81: bytes=32 time=3379ms TTL=238
</code></pre>
<p>Are there any possibilities t... | 510,271 | 1,460,189 | 2025-09-15 08:59:28 | 24,907,186 | 113 | 2014-07-23 09:48:38 | 2,861,476 | 2015-02-10 16:51:57 | https://stackoverflow.com/q/24906268 | https://stackoverflow.com/a/24907186 | <pre class="lang-dos prettyprint-override"><code>@echo off
ping -t localhost|find /v ""|cmd /q /v:on /c "for /l %%a in (0) do (set "data="&set /p "data="&if defined data echo(!time! !data!)"
</code></pre>
<p><em>note</em>: code to be used inside a batch file. To use from command line replace <code>%%a</co... | <pre class="lang-dos prettyprint-override"><code>@echo off ping -t localhost|find /v ""|cmd /q /v:on /c "for /l %%a in (0) do (set "data="&set /p "data="&if defined data echo(!time! !data!)" </code></pre> <p><em>note</em>: code to be used inside a batch file. To use from command line replace <code>%%a</co... | 64, 2177, 2631, 5649 | cmd, ping, timestamp, windows | <h1>Ping with timestamp on Windows CLI</h1>
<p>On the Windows command prompt <code>cmd</code>, I use <code>ping -t to 10.21.11.81</code><br/></p>
<pre><code>Reply from 10.21.11.81: bytes=32 time=3889ms TTL=238
Reply from 10.21.11.81: bytes=32 time=3738ms TTL=238
Reply from 10.21.11.81: bytes=32 time=3379ms TTL=238
</c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,014 | cmd | # Ping with timestamp on Windows CLI
On the Windows command prompt `cmd`, I use `ping -t to 10.21.11.81`
```
Reply from 10.21.11.81: bytes=32 time=3889ms TTL=238
Reply from 10.21.11.81: bytes=32 time=3738ms TTL=238
Reply from 10.21.11.81: bytes=32 time=3379ms TTL=238
```
Are there any possibilities to get an output ... | ```
@echo off
ping -t localhost|find /v ""|cmd /q /v:on /c "for /l %%a in (0) do (set "data="&set /p "data="&if defined data echo(!time! !data!)"
```
*note*: code to be used inside a batch file. To use from command line replace `%%a` with `%a`
Start the ping, force a correct line buffered output (`find /v`), and ... |
5553040 | batch file for loop with spaces in dir name | 67 | 2011-04-05 13:57:52 | <p>How do I modify this:</p>
<pre><code>for /f %%a IN ('dir /b /s build\release\*.dll') do echo "%%a"
</code></pre>
<p>to work when the path contains spaces?</p>
<p>For example, if this is run from</p>
<pre><code>c:\my folder with spaces
</code></pre>
<p>it will echo:</p>
<pre><code>c:\my
</code></pre>
<p>Thanks... | 89,203 | 28,543 | 2021-08-11 21:27:50 | 5,553,316 | 113 | 2011-04-05 14:15:40 | 601,493 | 2018-09-26 21:02:46 | https://stackoverflow.com/q/5553040 | https://stackoverflow.com/a/5553316 | <p>You need to use:</p>
<p><code>for /f "delims=" %%a IN ('dir /b /s build\release\*.dll') do echo "%%a"</code></p>
<p>This overrides the default delimiters which are TAB and SPACE</p>
| <p>You need to use:</p> <p><code>for /f "delims=" %%a IN ('dir /b /s build\release\*.dll') do echo "%%a"</code></p> <p>This overrides the default delimiters which are TAB and SPACE</p> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>batch file for loop with spaces in dir name</h1>
<p>How do I modify this:</p>
<pre><code>for /f %%a IN ('dir /b /s build\release\*.dll') do echo "%%a"
</code></pre>
<p>to work when the path contains spaces?</p>
<p>For example, if this is run from</p>
<pre><code>c:\my folder with spaces
</code></pre>
<p>it will... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,015 | cmd | # batch file for loop with spaces in dir name
How do I modify this:
```
for /f %%a IN ('dir /b /s build\release\*.dll') do echo "%%a"
```
to work when the path contains spaces?
For example, if this is run from
```
c:\my folder with spaces
```
it will echo:
```
c:\my
```
Thanks | You need to use:
`for /f "delims=" %%a IN ('dir /b /s build\release\*.dll') do echo "%%a"`
This overrides the default delimiters which are TAB and SPACE |
8397674 | Windows Batch File Looping Through Directories to Process Files? | 57 | 2011-12-06 09:27:30 | <p>I need to write/use a batch file that processes some imagery for me.</p>
<p>I have one folder full of nested folders, inside each of these nested folders is one more folder that contains a number of TIF images, the number of images vary in each folder. I also have a batch file, lets call it ProcessImages.bat for Win... | 131,426 | 963,481 | 2025-02-22 04:33:16 | 8,398,621 | 113 | 2011-12-06 10:47:28 | 778,560 | 2011-12-06 10:47:28 | https://stackoverflow.com/q/8397674 | https://stackoverflow.com/a/8398621 | <p>You may write a recursive algorithm in Batch that gives you exact control of what you do in every nested subdirectory:</p>
<pre><code>@echo off
call :treeProcess
goto :eof
:treeProcess
rem Do whatever you want here over the files of this subdir, for example:
for %%f in (*.tif) do echo %%f
for /D %%d in (*) do (
... | <p>You may write a recursive algorithm in Batch that gives you exact control of what you do in every nested subdirectory:</p> <pre><code>@echo off call :treeProcess goto :eof :treeProcess rem Do whatever you want here over the files of this subdir, for example: for %%f in (*.tif) do echo %%f for /D %%d in (*) do ( ... | 64, 578, 7002 | batch-file, recursion, windows | <h1>Windows Batch File Looping Through Directories to Process Files?</h1>
<p>I need to write/use a batch file that processes some imagery for me.</p>
<p>I have one folder full of nested folders, inside each of these nested folders is one more folder that contains a number of TIF images, the number of images vary in eac... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,016 | cmd | # Windows Batch File Looping Through Directories to Process Files?
I need to write/use a batch file that processes some imagery for me.
I have one folder full of nested folders, inside each of these nested folders is one more folder that contains a number of TIF images, the number of images vary in each folder. I als... | You may write a recursive algorithm in Batch that gives you exact control of what you do in every nested subdirectory:
```
@echo off
call :treeProcess
goto :eof
:treeProcess
rem Do whatever you want here over the files of this subdir, for example:
for %%f in (*.tif) do echo %%f
for /D %%d in (*) do (
cd %%d
c... |
9238953 | how to empty recyclebin through command prompt? | 100 | 2012-02-11 08:50:22 | <p>Usually we delete the recycle bin contents by right-clicking it with the mouse and selecting "Empty Recycle Bin". But I have a requirement where I need to delete the recycle bin contents using the command prompt. Is this possible? If so, how can I achieve it?</p>
| 376,473 | 1,016,403 | 2021-03-19 22:06:27 | 9,239,158 | 112 | 2012-02-11 09:30:10 | 366,904 | 2012-02-11 09:30:10 | https://stackoverflow.com/q/9238953 | https://stackoverflow.com/a/9239158 | <p>You can effectively "empty" the Recycle Bin from the command line by permanently deleting the Recycle Bin directory on the drive that contains the system files. (In most cases, this will be the <code>C:</code> drive, but you shouldn't hardcode that value because it won't always be true. Instead, use the <code>%syste... | <p>You can effectively "empty" the Recycle Bin from the command line by permanently deleting the Recycle Bin directory on the drive that contains the system files. (In most cases, this will be the <code>C:</code> drive, but you shouldn't hardcode that value because it won't always be true. Instead, use the <code>%syste... | 64, 1219, 1231, 7002, 34595 | batch-file, command-line, recycle-bin, windows, windows-7 | <h1>how to empty recyclebin through command prompt?</h1>
<p>Usually we delete the recycle bin contents by right-clicking it with the mouse and selecting "Empty Recycle Bin". But I have a requirement where I need to delete the recycle bin contents using the command prompt. Is this possible? If so, how can I achieve it?<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,017 | cmd | # how to empty recyclebin through command prompt?
Usually we delete the recycle bin contents by right-clicking it with the mouse and selecting "Empty Recycle Bin". But I have a requirement where I need to delete the recycle bin contents using the command prompt. Is this possible? If so, how can I achieve it? | You can effectively "empty" the Recycle Bin from the command line by permanently deleting the Recycle Bin directory on the drive that contains the system files. (In most cases, this will be the `C:` drive, but you shouldn't hardcode that value because it won't always be true. Instead, use the `%systemdrive%` environmen... |
5273937 | How to replace substrings in windows batch file | 87 | 2011-03-11 14:10:08 | <p>Can anyone tell me using batch file in windows ...how to read from a file and replace string=<code>bath</code> from file containing=<code>bath Abath Bbath XYZbathABC</code> with string <code>hello</code> so that the output is like <code>hello Ahello Bhello XYZhelloABC</code></p>
| 237,018 | 2,764,001 | 2020-07-16 10:57:30 | 5,274,880 | 112 | 2011-03-11 15:31:34 | 630,924 | 2018-08-24 04:56:19 | https://stackoverflow.com/q/5273937 | https://stackoverflow.com/a/5274880 | <p>Expanding from <a href="https://stackoverflow.com/users/297408/andriy-m">Andriy M</a>, and yes you can do this from a file, even one with multiple lines</p>
<pre><code>@echo off
setlocal EnableExtensions EnableDelayedExpansion
set "INTEXTFILE=test.txt"
set "OUTTEXTFILE=test_out.txt"
set "SEARCHTEXT=bath"
set "REPLA... | <p>Expanding from <a href="https://stackoverflow.com/users/297408/andriy-m">Andriy M</a>, and yes you can do this from a file, even one with multiple lines</p> <pre><code>@echo off setlocal EnableExtensions EnableDelayedExpansion set "INTEXTFILE=test.txt" set "OUTTEXTFILE=test_out.txt" set "SEARCHTEXT=bath" set "REPLA... | 7002 | batch-file | <h1>How to replace substrings in windows batch file</h1>
<p>Can anyone tell me using batch file in windows ...how to read from a file and replace string=<code>bath</code> from file containing=<code>bath Abath Bbath XYZbathABC</code> with string <code>hello</code> so that the output is like <code>hello Ahello Bhello XYZ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,018 | cmd | # How to replace substrings in windows batch file
Can anyone tell me using batch file in windows ...how to read from a file and replace string=`bath` from file containing=`bath Abath Bbath XYZbathABC` with string `hello` so that the output is like `hello Ahello Bhello XYZhelloABC` | Expanding from [Andriy M](https://stackoverflow.com/users/297408/andriy-m), and yes you can do this from a file, even one with multiple lines
```
@echo off
setlocal EnableExtensions EnableDelayedExpansion
set "INTEXTFILE=test.txt"
set "OUTTEXTFILE=test_out.txt"
set "SEARCHTEXT=bath"
set "REPLACETEXT=hello"
for /f "de... |
37515901 | Where does GOTO :EOF return to? | 71 | 2016-05-29 23:27:59 | <p>I'm trying to understand where in the code exactly does <code>GOTO :EOF</code> return to?</p>
<p>Here is the code:</p>
<pre><code>SET count=1
FOR /f "tokens=*" %%G IN (somefile.txt) DO (call :subroutine "%%G")
GOTO :EOF
:subroutine
echo %count%:%1
set /a count+=1
GOTO :EOF
</code></pre>
| 141,563 | 6,398,197 | 2022-02-12 14:24:06 | 37,518,000 | 111 | 2016-05-30 05:11:17 | 3,074,564 | 2022-02-12 14:24:06 | https://stackoverflow.com/q/37515901 | https://stackoverflow.com/a/37518000 | <p><code>:EOF</code> is a predefined label as Microsoft explains in documentation for command <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/goto" rel="noreferrer">GOTO</a>. The help output by running in a command prompt window <code>goto /?</code> explains also this special l... | <p><code>:EOF</code> is a predefined label as Microsoft explains in documentation for command <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/goto" rel="noreferrer">GOTO</a>. The help output by running in a command prompt window <code>goto /?</code> explains also this special l... | 2531, 7002 | batch-file, for-loop | <h1>Where does GOTO :EOF return to?</h1>
<p>I'm trying to understand where in the code exactly does <code>GOTO :EOF</code> return to?</p>
<p>Here is the code:</p>
<pre><code>SET count=1
FOR /f "tokens=*" %%G IN (somefile.txt) DO (call :subroutine "%%G")
GOTO :EOF
:subroutine
echo %count%:%1
set /a count+=1
G... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,019 | cmd | # Where does GOTO :EOF return to?
I'm trying to understand where in the code exactly does `GOTO :EOF` return to?
Here is the code:
```
SET count=1
FOR /f "tokens=*" %%G IN (somefile.txt) DO (call :subroutine "%%G")
GOTO :EOF
:subroutine
echo %count%:%1
set /a count+=1
GOTO :EOF
``` | `:EOF` is a predefined label as Microsoft explains in documentation for command [GOTO](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/goto). The help output by running in a command prompt window `goto /?` explains also this special label for **End Of File**. But this predefined label i... |
3903288 | Run an EXE from a different directory? | 69 | 2010-10-11 03:05:55 | <p>After a bit of googling and searching here, couldn't find the answer to this silly question!</p>
<p>For a structure like this...</p>
<pre><code>dirZero
|---dirOne
|---|---myProgram.exe
</code></pre>
<p>How do I run "myProgram" if my current directory is dirZero? I.E.,</p>
<pre><code>C:\dirZero> dirOne/... | 111,677 | 385,273 | 2022-12-24 20:11:52 | 3,903,300 | 111 | 2010-10-11 03:10:29 | 459,338 | 2010-10-11 03:10:29 | https://stackoverflow.com/q/3903288 | https://stackoverflow.com/a/3903300 | <p>You should use a backslash <code>\</code>, instead of forward slash. <code>/</code></p>
<pre><code>C:\dirZero> dirOne\myProgram.exe
</code></pre>
<p>Or, wrap it with double quotes <code>"</code></p>
<pre><code>C:\dirZero> "dirOne/myProgram.exe"
</code></pre>
| <p>You should use a backslash <code>\</code>, instead of forward slash. <code>/</code></p> <pre><code>C:\dirZero> dirOne\myProgram.exe </code></pre> <p>Or, wrap it with double quotes <code>"</code></p> <pre><code>C:\dirZero> "dirOne/myProgram.exe" </code></pre> | 2631 | cmd | <h1>Run an EXE from a different directory?</h1>
<p>After a bit of googling and searching here, couldn't find the answer to this silly question!</p>
<p>For a structure like this...</p>
<pre><code>dirZero
|---dirOne
|---|---myProgram.exe
</code></pre>
<p>How do I run "myProgram" if my current directory is dirZe... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,020 | cmd | # Run an EXE from a different directory?
After a bit of googling and searching here, couldn't find the answer to this silly question!
For a structure like this...
```
dirZero
|---dirOne
|---|---myProgram.exe
```
How do I run "myProgram" if my current directory is dirZero? I.E.,
```
C:\dirZero> dirOne/myProgram.exe... | You should use a backslash `\`, instead of forward slash. `/`
```
C:\dirZero> dirOne\myProgram.exe
```
Or, wrap it with double quotes `"`
```
C:\dirZero> "dirOne/myProgram.exe"
``` |
35957077 | How to remove all files with specific extension in folder? | 40 | 2016-03-12 11:30:12 | <p>I am looking for command to delete all files with a specific extension in a given folder. Both, for windows and mac.</p>
<p>Thanks!</p>
| 91,926 | 4,345,344 | 2021-11-15 08:20:13 | 35,958,181 | 111 | 2016-03-12 13:23:16 | 3,501,205 | 2017-05-19 17:17:53 | https://stackoverflow.com/q/35957077 | https://stackoverflow.com/a/35958181 | <p>Delete all files with extension <code>.tmp</code> in <strong>current folder</strong>:</p>
<p><em>On Windows:</em></p>
<pre><code>del *.tmp
</code></pre>
<p><em>On Mac:</em></p>
<pre><code>rm -rf ./*.tmp
</code></pre>
<p><br/>
Delete all files with extension <code>.tmp</code> in <strong>current folder Recursivel... | <p>Delete all files with extension <code>.tmp</code> in <strong>current folder</strong>:</p> <p><em>On Windows:</em></p> <pre><code>del *.tmp </code></pre> <p><em>On Mac:</em></p> <pre><code>rm -rf ./*.tmp </code></pre> <p><br/> Delete all files with extension <code>.tmp</code> in <strong>current folder Recursivel... | 391, 2631 | cmd, terminal | <h1>How to remove all files with specific extension in folder?</h1>
<p>I am looking for command to delete all files with a specific extension in a given folder. Both, for windows and mac.</p>
<p>Thanks!</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,021 | cmd | # How to remove all files with specific extension in folder?
I am looking for command to delete all files with a specific extension in a given folder. Both, for windows and mac.
Thanks! | Delete all files with extension `.tmp` in **current folder**:
*On Windows:*
```
del *.tmp
```
*On Mac:*
```
rm -rf ./*.tmp
```
Delete all files with extension `.tmp` in **current folder Recursively (including sub-folders)**:
*On Windows:*
```
del /s *.tmp
```
*On Mac:*
```
find . -name '*.tmp' -delete
``` |
48997463 | ECS unable to assume role | 79 | 2018-02-26 21:33:48 | <p>From the console, I am invoking a lambda which submits a batch job. The batch job fails, indicating that ECS is unable to assume the role that is provided to execute the job definition.</p>
<p>For the role, I've added the lambda and ECS services.</p>
<p>The error message:</p>
<blockquote>
<p>"ECS was unable to ... | 42,783 | 479,490 | 2023-05-30 04:07:13 | 49,016,565 | 108 | 2018-02-27 19:32:55 | 479,490 | 2018-02-27 19:32:55 | https://stackoverflow.com/q/48997463 | https://stackoverflow.com/a/49016565 | <p>You have to add the principal "ecs-tasks.amazonaws.com" to the trust policy for the role that's submitting a Batch job (not "ecs.amazonaws.com").</p>
<p>Revised role:</p>
<pre><code>"TrainingJobRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"RoleName": "golfnow-invoke-write-progress",
... | <p>You have to add the principal "ecs-tasks.amazonaws.com" to the trust policy for the role that's submitting a Batch job (not "ecs.amazonaws.com").</p> <p>Revised role:</p> <pre><code>"TrainingJobRole": { "Type": "AWS::IAM::Role", "Properties": { "RoleName": "golfnow-invoke-write-progress", ... | 33388, 124227, 129774 | amazon-web-services, aws-batch, aws-ecs | <h1>ECS unable to assume role</h1>
<p>From the console, I am invoking a lambda which submits a batch job. The batch job fails, indicating that ECS is unable to assume the role that is provided to execute the job definition.</p>
<p>For the role, I've added the lambda and ECS services.</p>
<p>The error message:</p>
<b... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,022 | cmd | # ECS unable to assume role
From the console, I am invoking a lambda which submits a batch job. The batch job fails, indicating that ECS is unable to assume the role that is provided to execute the job definition.
For the role, I've added the lambda and ECS services.
The error message:
> "ECS was unable to assume t... | You have to add the principal "ecs-tasks.amazonaws.com" to the trust policy for the role that's submitting a Batch job (not "ecs.amazonaws.com").
Revised role:
```
"TrainingJobRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"RoleName": "golfnow-invoke-write-progress",
"AssumeRolePolicyD... |
1199645 | How can I check the size of a file in a Windows batch script? | 77 | 2009-07-29 11:40:44 | <p>I want to have a batch file which checks what the <code>filesize</code> is of a file.</p>
<p>If it is bigger than <code>%somany% kbytes,</code> it should redirect with GOTO to somewhere else.</p>
<p>Example:</p>
<pre><code>[check for filesize]
IF %file% [filesize thing Bigger than] GOTO No
echo Great! Your filesi... | 275,042 | 111,731 | 2023-03-20 21:20:49 | 1,199,839 | 108 | 2009-07-29 12:15:34 | 3,501 | 2015-07-24 13:36:47 | https://stackoverflow.com/q/1199645 | https://stackoverflow.com/a/1199839 | <p>If the file name is used as a parameter to the batch file, all you need is <code>%~z1</code> (1 means first parameter)</p>
<p>If the file name is not a parameter, you can do something like:</p>
<pre><code>@echo off
setlocal
set file="test.cmd"
set maxbytesize=1000
FOR /F "usebackq" %%A IN ('%file%') DO set size=%... | <p>If the file name is used as a parameter to the batch file, all you need is <code>%~z1</code> (1 means first parameter)</p> <p>If the file name is not a parameter, you can do something like:</p> <pre><code>@echo off setlocal set file="test.cmd" set maxbytesize=1000 FOR /F "usebackq" %%A IN ('%file%') DO set size=%... | 7002, 8071 | batch-file, filesize | <h1>How can I check the size of a file in a Windows batch script?</h1>
<p>I want to have a batch file which checks what the <code>filesize</code> is of a file.</p>
<p>If it is bigger than <code>%somany% kbytes,</code> it should redirect with GOTO to somewhere else.</p>
<p>Example:</p>
<pre><code>[check for filesize]... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,023 | cmd | # How can I check the size of a file in a Windows batch script?
I want to have a batch file which checks what the `filesize` is of a file.
If it is bigger than `%somany% kbytes,` it should redirect with GOTO to somewhere else.
Example:
```
[check for filesize]
IF %file% [filesize thing Bigger than] GOTO No
echo Gre... | If the file name is used as a parameter to the batch file, all you need is `%~z1` (1 means first parameter)
If the file name is not a parameter, you can do something like:
```
@echo off
setlocal
set file="test.cmd"
set maxbytesize=1000
FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA
if %size% LSS %maxbytesize... |
840831 | How can I execute a set of .SQL files from within SSMS? | 77 | 2009-05-08 17:00:27 | <p>How could I execute a set of .SQL files (each does some data transformations) from within SQL Server Management Studio? </p>
<p>What other alternative are there for executing .SQL files in batch?</p>
| 87,773 | 73,794 | 2024-06-10 17:11:32 | 840,847 | 108 | 2009-05-08 17:04:47 | 30,419 | 2013-01-10 17:27:56 | https://stackoverflow.com/q/840831 | https://stackoverflow.com/a/840847 | <p>While SQLCMD.exe is the best way, SSMS also has a SQLCMD mode where you can execute a SQLCMD script. To enable this mode click <strong>Query</strong> in menu bar then select <strong>SQLCMD Mode</strong>.</p>
<p>The ":r filename.sql" command is the SQLCMD script command to import and execute a sql script file. You ... | <p>While SQLCMD.exe is the best way, SSMS also has a SQLCMD mode where you can execute a SQLCMD script. To enable this mode click <strong>Query</strong> in menu bar then select <strong>SQLCMD Mode</strong>.</p> <p>The ":r filename.sql" command is the SQLCMD script command to import and execute a sql script file. You ... | 72, 2295, 7002 | batch-file, sql-server, ssms | <h1>How can I execute a set of .SQL files from within SSMS?</h1>
<p>How could I execute a set of .SQL files (each does some data transformations) from within SQL Server Management Studio? </p>
<p>What other alternative are there for executing .SQL files in batch?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,024 | cmd | # How can I execute a set of .SQL files from within SSMS?
How could I execute a set of .SQL files (each does some data transformations) from within SQL Server Management Studio?
What other alternative are there for executing .SQL files in batch? | While SQLCMD.exe is the best way, SSMS also has a SQLCMD mode where you can execute a SQLCMD script. To enable this mode click **Query** in menu bar then select **SQLCMD Mode**.
The ":r filename.sql" command is the SQLCMD script command to import and execute a sql script file. You know you are in SQLCMD mode because a... |
13551829 | Escape percent in bat file | 73 | 2012-11-25 14:16:22 | <p>I was trying to write a VPN dialer/disconnector using a batch file, but I got stuck. After some investigation I found that the presence of <code>%</code> in the password is not playing well.</p>
<p>Here is the code</p>
<pre><code>@echo OFF
SET SWITCHPARSE1=%1
SET SWITCHPARSE2=%2
REM echo %SWITCHPARSE1%
SHIFT
SHIFT... | 51,668 | 129,206 | 2020-10-11 15:20:52 | 13,552,702 | 108 | 2012-11-25 15:58:05 | 1,248,295 | 2018-11-02 19:06:24 | https://stackoverflow.com/q/13551829 | https://stackoverflow.com/a/13552702 | <p>Two <strong>%%</strong> equals to one <strong>%</strong>. That's right (but only in a script, not directly in the cmd), no need to use the escape operator <strong>^</strong>.</p>
<p>But you are missing the agrupation operator <strong>)</strong>. That's the problem; the IF closes when it finds the <strong>)</strong>... | <p>Two <strong>%%</strong> equals to one <strong>%</strong>. That's right (but only in a script, not directly in the cmd), no need to use the escape operator <strong>^</strong>.</p> <p>But you are missing the agrupation operator <strong>)</strong>. That's the problem; the IF closes when it finds the <strong>)</strong>... | 64, 2631, 4804, 7002 | batch-file, cmd, escaping, windows | <h1>Escape percent in bat file</h1>
<p>I was trying to write a VPN dialer/disconnector using a batch file, but I got stuck. After some investigation I found that the presence of <code>%</code> in the password is not playing well.</p>
<p>Here is the code</p>
<pre><code>@echo OFF
SET SWITCHPARSE1=%1
SET SWITCHPARSE2=%2... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,025 | cmd | # Escape percent in bat file
I was trying to write a VPN dialer/disconnector using a batch file, but I got stuck. After some investigation I found that the presence of `%` in the password is not playing well.
Here is the code
```
@echo OFF
SET SWITCHPARSE1=%1
SET SWITCHPARSE2=%2
REM echo %SWITCHPARSE1%
SHIFT
SHIFT
I... | Two **%%** equals to one **%**. That's right (but only in a script, not directly in the cmd), no need to use the escape operator **^**.
But you are missing the agrupation operator **)**. That's the problem; the IF closes when it finds the **)** at your command.
Use this:
```
rasdial sl employee1 K%%%%Pxev3=^)g:{#Swc... |
25554254 | Batch command to delete all subfolders with a specific name | 65 | 2014-08-28 17:03:19 | <p>I have a directory as such:</p>
<pre><code>D:\Movies
D:\Movies\MovieTitle1\backdrops\
D:\Movies\MovieTitle2\backdrops\
D:\Movies\MovieTitle3\backdrops\
D:\Movies\MovieTitle4\backdrops\
</code></pre>
<p>How could I have a batch file delete all folders named "Backdrops"? I would prefer it to run recursive from just ... | 92,304 | 3,984,674 | 2025-07-24 06:37:30 | 25,554,347 | 108 | 2014-08-28 17:09:03 | 430,997 | 2025-07-24 06:37:30 | https://stackoverflow.com/q/25554254 | https://stackoverflow.com/a/25554347 | <p>Short answer:</p>
<p>Cd into the parent directory you want to navigate, e.g. <code>cd C:\</code>.</p>
<p>To recursively delete all subdirectories named <code>backdrops</code>, run</p>
<pre><code>FOR /d /r . %d IN (backdrops) DO @IF EXIST "%d" rd /S /Q "%d"
</code></pre>
<p>Remove the <code>/Q</co... | <p>Short answer:</p> <p>Cd into the parent directory you want to navigate, e.g. <code>cd C:\</code>.</p> <p>To recursively delete all subdirectories named <code>backdrops</code>, run</p> <pre><code>FOR /d /r . %d IN (backdrops) DO @IF EXIST "%d" rd /S /Q "%d" </code></pre> <p>Remove the <code>/Q</co... | 4963, 7002, 20795 | batch-file, window, xbmc | <h1>Batch command to delete all subfolders with a specific name</h1>
<p>I have a directory as such:</p>
<pre><code>D:\Movies
D:\Movies\MovieTitle1\backdrops\
D:\Movies\MovieTitle2\backdrops\
D:\Movies\MovieTitle3\backdrops\
D:\Movies\MovieTitle4\backdrops\
</code></pre>
<p>How could I have a batch file delete all fol... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,026 | cmd | # Batch command to delete all subfolders with a specific name
I have a directory as such:
```
D:\Movies
D:\Movies\MovieTitle1\backdrops\
D:\Movies\MovieTitle2\backdrops\
D:\Movies\MovieTitle3\backdrops\
D:\Movies\MovieTitle4\backdrops\
```
How could I have a batch file delete all folders named "Backdrops"? I would p... | Short answer:
Cd into the parent directory you want to navigate, e.g. `cd C:\`.
To recursively delete all subdirectories named `backdrops`, run
```
FOR /d /r . %d IN (backdrops) DO @IF EXIST "%d" rd /S /Q "%d"
```
Remove the `/Q` option if you want to confirm each deletion.
If you put this commands in a batch file... |
12881854 | How to use GNU Make on Windows? | 101 | 2012-10-14 11:38:18 | <p>I installed MinGW and MSYS, added <code>C:\MinGW\bin</code> to <code>PATH</code> but I still can't run Makefile on Windows' <code>cmd</code>. I would like to run cmd.exe and there type, for example, <code>make all</code> but my cmd says that there is no such command. </p>
<p>What should I do? I don't want to use MS... | 191,184 | 1,582,481 | 2022-05-01 00:26:00 | 12,885,705 | 106 | 2012-10-14 19:26:08 | 1,594,322 | 2022-05-01 00:26:00 | https://stackoverflow.com/q/12881854 | https://stackoverflow.com/a/12885705 | <h3>Explanation</h3>
<p>Inside directory <code>C:\MinGW\bin</code> there is an executable file <code>mingw32-make.exe</code> which is the program <code>make</code> you are trying to run. You can use the keyword <code>mingw32-make</code> and run the program <code>make</code> since you have added the needed directory to ... | <h3>Explanation</h3> <p>Inside directory <code>C:\MinGW\bin</code> there is an executable file <code>mingw32-make.exe</code> which is the program <code>make</code> you are trying to run. You can use the keyword <code>mingw32-make</code> and run the program <code>make</code> since you have added the needed directory to ... | 64, 2631, 4301, 13213 | cmd, gnu-make, makefile, windows | <h1>How to use GNU Make on Windows?</h1>
<p>I installed MinGW and MSYS, added <code>C:\MinGW\bin</code> to <code>PATH</code> but I still can't run Makefile on Windows' <code>cmd</code>. I would like to run cmd.exe and there type, for example, <code>make all</code> but my cmd says that there is no such command. </p>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,027 | cmd | # How to use GNU Make on Windows?
I installed MinGW and MSYS, added `C:\MinGW\bin` to `PATH` but I still can't run Makefile on Windows' `cmd`. I would like to run cmd.exe and there type, for example, `make all` but my cmd says that there is no such command.
What should I do? I don't want to use MSYS shell, that's not... | ### Explanation
Inside directory `C:\MinGW\bin` there is an executable file `mingw32-make.exe` which is the program `make` you are trying to run. You can use the keyword `mingw32-make` and run the program `make` since you have added the needed directory to the system path, but it is not an easy to remember keyword.
-... |
5811425 | Dummy SMTP server for development purposes | 42 | 2011-04-27 22:32:12 | <p>I've been using a dummy smtp server called DevNull SMTP so that I can test my app which sends out notification emails. It has a nice simple GUI, very helpful, but can't be scripted easily. I can't even start it listening to port 25. I have to run the app and then click on the start button...</p>
<p>Is there a si... | 24,019 | 326,389 | 2021-01-16 13:23:16 | 6,344,240 | 106 | 2011-06-14 13:28:55 | 749,199 | 2021-01-16 13:23:16 | https://stackoverflow.com/q/5811425 | https://stackoverflow.com/a/6344240 | <p>there is a nice trick with python: <a href="http://muffinresearch.co.uk/archives/2010/10/15/fake-smtp-server-with-python/" rel="noreferrer">http://muffinresearch.co.uk/archives/2010/10/15/fake-smtp-server-with-python/</a></p>
<p>Just one liner can do the job (listens on port <code>2500</code>):</p>
<pre><code>python... | <p>there is a nice trick with python: <a href="http://muffinresearch.co.uk/archives/2010/10/15/fake-smtp-server-with-python/" rel="noreferrer">http://muffinresearch.co.uk/archives/2010/10/15/fake-smtp-server-with-python/</a></p> <p>Just one liner can do the job (listens on port <code>2500</code>):</p> <pre><code>python... | 146, 531, 2900, 7002 | batch-file, email, scripting, smtp | <h1>Dummy SMTP server for development purposes</h1>
<p>I've been using a dummy smtp server called DevNull SMTP so that I can test my app which sends out notification emails. It has a nice simple GUI, very helpful, but can't be scripted easily. I can't even start it listening to port 25. I have to run the app and the... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,029 | cmd | # Dummy SMTP server for development purposes
I've been using a dummy smtp server called DevNull SMTP so that I can test my app which sends out notification emails. It has a nice simple GUI, very helpful, but can't be scripted easily. I can't even start it listening to port 25. I have to run the app and then click on t... | there is a nice trick with python: <http://muffinresearch.co.uk/archives/2010/10/15/fake-smtp-server-with-python/>
Just one liner can do the job (listens on port `2500`):
```
python -m smtpd -n -c DebuggingServer localhost:2500
``` |
6828751 | Batch character escaping | 74 | 2011-07-26 10:37:22 | <p>I'm fairly proficient at writing Batch scripts for Windows, but even after all these years how to correctly escape characters puzzles me. It's especially difficult when trying figure out the correct way to escape a regular expression for use with sed. Is there any tool that can help me? Perhaps something that allo... | 165,380 | 500,312 | 2022-07-05 10:50:18 | 16,018,942 | 105 | 2013-04-15 15:22:40 | 173,497 | 2021-10-16 14:08:29 | https://stackoverflow.com/q/6828751 | https://stackoverflow.com/a/16018942 | <p>As <a href="https://stackoverflow.com/questions/6828751/batch-character-escaping/16018942#comment96708694_16018942">dbhenham points out in this comment</a>, a (MUCH) more detailed answer can be found in portions of <a href="https://stackoverflow.com/a/4095133/173497">this answer</a> (originally by another user jeb a... | <p>As <a href="https://stackoverflow.com/questions/6828751/batch-character-escaping/16018942#comment96708694_16018942">dbhenham points out in this comment</a>, a (MUCH) more detailed answer can be found in portions of <a href="https://stackoverflow.com/a/4095133/173497">this answer</a> (originally by another user jeb a... | 64, 531, 2631, 4804, 7002 | batch-file, cmd, escaping, scripting, windows | <h1>Batch character escaping</h1>
<p>I'm fairly proficient at writing Batch scripts for Windows, but even after all these years how to correctly escape characters puzzles me. It's especially difficult when trying figure out the correct way to escape a regular expression for use with sed. Is there any tool that can hel... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,030 | cmd | # Batch character escaping
I'm fairly proficient at writing Batch scripts for Windows, but even after all these years how to correctly escape characters puzzles me. It's especially difficult when trying figure out the correct way to escape a regular expression for use with sed. Is there any tool that can help me? Perh... | As [dbhenham points out in this comment](https://stackoverflow.com/questions/6828751/batch-character-escaping/16018942#comment96708694_16018942), a (MUCH) more detailed answer can be found in portions of [this answer](https://stackoverflow.com/a/4095133/173497) (originally by another user jeb and significantly edited a... |
16203629 | Assign command output to variable in batch file | 55 | 2013-04-24 22:57:13 | <p>I'm trying to assign the output of a command to a variable - as in, I'm trying to set the current flash version to a variable. I know this is wrong, but this is what I've tried:</p>
<pre><code>set var=reg query hklm\SOFTWARE\Macromedia\FlashPlayer\CurrentVersion>
</code></pre>
<p>or</p>
<pre><code>reg query hk... | 151,036 | 2,283,234 | 2019-06-05 17:24:07 | 16,203,904 | 105 | 2013-04-24 23:23:10 | 2,045,818 | 2013-04-24 23:23:10 | https://stackoverflow.com/q/16203629 | https://stackoverflow.com/a/16203904 | <p>A method has already been devised, however this way you don't need a temp file.</p>
<pre><code>for /f "delims=" %%i in ('command') do set output=%%i
</code></pre>
<p>However, I'm sure this has its own exceptions and limitations.</p>
| <p>A method has already been devised, however this way you don't need a temp file.</p> <pre><code>for /f "delims=" %%i in ('command') do set output=%%i </code></pre> <p>However, I'm sure this has its own exceptions and limitations.</p> | 263, 276, 299, 2631, 7002 | batch-file, cmd, flash, registry, variables | <h1>Assign command output to variable in batch file</h1>
<p>I'm trying to assign the output of a command to a variable - as in, I'm trying to set the current flash version to a variable. I know this is wrong, but this is what I've tried:</p>
<pre><code>set var=reg query hklm\SOFTWARE\Macromedia\FlashPlayer\CurrentVers... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,031 | cmd | # Assign command output to variable in batch file
I'm trying to assign the output of a command to a variable - as in, I'm trying to set the current flash version to a variable. I know this is wrong, but this is what I've tried:
```
set var=reg query hklm\SOFTWARE\Macromedia\FlashPlayer\CurrentVersion>
```
or
```
re... | A method has already been devised, however this way you don't need a temp file.
```
for /f "delims=" %%i in ('command') do set output=%%i
```
However, I'm sure this has its own exceptions and limitations. |
12365374 | 'else' is not recognized as an internal or external command, operable program or batch file | 47 | 2012-09-11 08:08:24 | <p>I try to use with "else" command but I get the foloowing error:</p>
<p><strong>'else' is not recognized as an internal or external command,
operable program or batch file.</strong></p>
<p>My code is:</p>
<pre><code>if "zz"=="TRUE" (
copy /a zz + /a ee=/a zz
)
else (
copy /a e + /a %TMP%=/... | 64,237 | 1,632,792 | 2012-09-11 08:15:53 | 12,365,410 | 105 | 2012-09-11 08:11:15 | 15,393 | 2012-09-11 08:15:53 | https://stackoverflow.com/q/12365374 | https://stackoverflow.com/a/12365410 | <p>The <code>else</code> needs to be on the same "line" <sup>(a)</sup> as the <code>if</code>. Remove the new-line before the <code>else</code> like so:</p>
<pre><code>if "zz"=="TRUE" (
copy /a zz + /a ee=/a zz
) else (
copy /a e + /a %TMP%=/a e
)
</code></pre>
<p>Please also note that <code>"zz"=="TRUE"</cod... | <p>The <code>else</code> needs to be on the same "line" <sup>(a)</sup> as the <code>if</code>. Remove the new-line before the <code>else</code> like so:</p> <pre><code>if "zz"=="TRUE" ( copy /a zz + /a ee=/a zz ) else ( copy /a e + /a %TMP%=/a e ) </code></pre> <p>Please also note that <code>"zz"=="TRUE"</cod... | 2631, 2773, 7002 | batch-file, cmd, if-statement | <h1>'else' is not recognized as an internal or external command, operable program or batch file</h1>
<p>I try to use with "else" command but I get the foloowing error:</p>
<p><strong>'else' is not recognized as an internal or external command,
operable program or batch file.</strong></p>
<p>My code is:</p>
<pre><cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,033 | cmd | # 'else' is not recognized as an internal or external command, operable program or batch file
I try to use with "else" command but I get the foloowing error:
**'else' is not recognized as an internal or external command,
operable program or batch file.**
My code is:
```
if "zz"=="TRUE" (
copy /a zz + /a ee=... | The `else` needs to be on the same "line" (a) as the `if`. Remove the new-line before the `else` like so:
```
if "zz"=="TRUE" (
copy /a zz + /a ee=/a zz
) else (
copy /a e + /a %TMP%=/a e
)
```
Please also note that `"zz"=="TRUE"` will never evaluate to `true` - I suspect you meant `"%zz%"=="TRUE"`?
---
(a)... |
6359318 | How do I send a message to stderr from cmd? | 85 | 2011-06-15 14:28:09 | <p>In a standard windows .cmd file I can send messages to stdout simply by doing:</p>
<pre><code>echo message
</code></pre>
<p>How can I send a message to stderr?</p>
<p><strong>Example</strong>:</p>
<p>Let's say I have the script parent.cmd containing:</p>
<pre><code>call child.cmd 1>>stdout.log 2>>st... | 35,940 | 587,279 | 2024-08-12 01:27:07 | 6,359,438 | 103 | 2011-06-15 14:35:22 | 772,208 | 2024-05-29 04:42:52 | https://stackoverflow.com/q/6359318 | https://stackoverflow.com/a/6359438 | <p>You can try redirecting the handle of STDOUT to the handle of STDERR. In your child process, perform the echo with a handle redirect:</p>
<pre><code>:: Writes a message to stdout
:: (which in the parent is piped to stdout.log)
echo message
:: Now I want to write a message to stderr
:: (which in the parent is pipe... | <p>You can try redirecting the handle of STDOUT to the handle of STDERR. In your child process, perform the echo with a handle redirect:</p> <pre><code>:: Writes a message to stdout :: (which in the parent is piped to stdout.log) echo message :: Now I want to write a message to stderr :: (which in the parent is pipe... | 2631, 7002 | batch-file, cmd | <h1>How do I send a message to stderr from cmd?</h1>
<p>In a standard windows .cmd file I can send messages to stdout simply by doing:</p>
<pre><code>echo message
</code></pre>
<p>How can I send a message to stderr?</p>
<p><strong>Example</strong>:</p>
<p>Let's say I have the script parent.cmd containing:</p>
<pre... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,034 | cmd | # How do I send a message to stderr from cmd?
In a standard windows .cmd file I can send messages to stdout simply by doing:
```
echo message
```
How can I send a message to stderr?
**Example**:
Let's say I have the script parent.cmd containing:
```
call child.cmd 1>>stdout.log 2>>stderr.log
```
and a child cont... | You can try redirecting the handle of STDOUT to the handle of STDERR. In your child process, perform the echo with a handle redirect:
```
:: Writes a message to stdout
:: (which in the parent is piped to stdout.log)
echo message
:: Now I want to write a message to stderr
:: (which in the parent is piped to stderr.l... |
6379619 | Explain how Windows batch newline variable hack works | 80 | 2011-06-16 23:05:12 | <p>Can someone please explain how this works?</p>
<pre><code>@echo off
REM Creating a Newline variable (the two blank lines are required!)
set NLM=^
set NL=^^^%NLM%%NLM%^%NLM%%NLM%
REM Example Usage:
echo There should be a newline%NL%inserted here.
</code></pre>
<p>emits:</p>
<pre><code>There should be a newline
i... | 40,551 | 14,420 | 2019-03-08 08:26:41 | 6,379,861 | 103 | 2011-06-16 23:37:32 | 463,115 | 2018-08-20 06:46:06 | https://stackoverflow.com/q/6379619 | https://stackoverflow.com/a/6379861 | <p>The trick uses the behaviour of the caret.<br>
Also explained at <a href="https://stackoverflow.com/questions/69068/long-commands-split-over-multiple-lines-in-vista-dos-batch-bat-file/4455750#4455750">Long commands split over multiple lines in Windows Vista batch (.bat) file</a> </p>
<p>The caret is an escape char... | <p>The trick uses the behaviour of the caret.<br> Also explained at <a href="https://stackoverflow.com/questions/69068/long-commands-split-over-multiple-lines-in-vista-dos-batch-bat-file/4455750#4455750">Long commands split over multiple lines in Windows Vista batch (.bat) file</a> </p> <p>The caret is an escape char... | 7002 | batch-file | <h1>Explain how Windows batch newline variable hack works</h1>
<p>Can someone please explain how this works?</p>
<pre><code>@echo off
REM Creating a Newline variable (the two blank lines are required!)
set NLM=^
set NL=^^^%NLM%%NLM%^%NLM%%NLM%
REM Example Usage:
echo There should be a newline%NL%inserted here.
</cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,035 | cmd | # Explain how Windows batch newline variable hack works
Can someone please explain how this works?
```
@echo off
REM Creating a Newline variable (the two blank lines are required!)
set NLM=^
set NL=^^^%NLM%%NLM%^%NLM%%NLM%
REM Example Usage:
echo There should be a newline%NL%inserted here.
```
emits:
```
There sh... | The trick uses the behaviour of the caret.
Also explained at [Long commands split over multiple lines in Windows Vista batch (.bat) file](https://stackoverflow.com/questions/69068/long-commands-split-over-multiple-lines-in-vista-dos-batch-bat-file/4455750#4455750)
The caret is an escape character for the next charac... |
605522 | Print time in a batch file (milliseconds) | 66 | 2009-03-03 08:16:57 | <p>How do I print the time (in ms) in a Windows batch file?</p>
<p>I want to measure the time that passes between lines in my batch file, but Windows's "time /T" does not print milliseconds.</p>
| 191,741 | 11,208 | 2020-08-05 08:19:50 | 606,078 | 103 | 2009-03-03 11:48:05 | 7,903 | 2009-03-03 11:48:05 | https://stackoverflow.com/q/605522 | https://stackoverflow.com/a/606078 | <p><code>%time%</code> should work, provided enough time has elapsed between calls:</p>
<pre><code>@echo OFF
@echo %time%
ping -n 1 -w 1 127.0.0.1 1>nul
@echo %time%
</code></pre>
<p>On my system I get the following output:</p>
<blockquote>
<p>6:46:13.50<br>
6:46:13.60</p>
</blockquote>
| <p><code>%time%</code> should work, provided enough time has elapsed between calls:</p> <pre><code>@echo OFF @echo %time% ping -n 1 -w 1 127.0.0.1 1>nul @echo %time% </code></pre> <p>On my system I get the following output:</p> <blockquote> <p>6:46:13.50<br> 6:46:13.60</p> </blockquote> | 64, 603, 7002 | batch-file, time, windows | <h1>Print time in a batch file (milliseconds)</h1>
<p>How do I print the time (in ms) in a Windows batch file?</p>
<p>I want to measure the time that passes between lines in my batch file, but Windows's "time /T" does not print milliseconds.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,036 | cmd | # Print time in a batch file (milliseconds)
How do I print the time (in ms) in a Windows batch file?
I want to measure the time that passes between lines in my batch file, but Windows's "time /T" does not print milliseconds. | `%time%` should work, provided enough time has elapsed between calls:
```
@echo OFF
@echo %time%
ping -n 1 -w 1 127.0.0.1 1>nul
@echo %time%
```
On my system I get the following output:
> 6:46:13.50
> 6:46:13.60 |
22084561 | Difference between IISRESET and IIS Stop-Start command | 90 | 2014-02-28 01:45:51 | <p>Is there any difference between commands <code>iisreset</code> and <code>iisreset /stop</code> followed by <code>iisreset /start</code> ? </p>
| 309,443 | 2,746,670 | 2025-04-22 16:28:18 | 22,123,439 | 102 | 2014-03-02 03:21:05 | 1,415,364 | 2025-04-22 16:28:18 | https://stackoverflow.com/q/22084561 | https://stackoverflow.com/a/22123439 | <p>Take IISReset as a suite of commands that helps you manage IIS start / stop etc.</p>
<p>This means you need to specify the option (<code>/switch</code>) what you want to do to carry out any operation.</p>
<p>Default behavior OR default switch is <code>/restart</code> with <code>iisreset</code> so you do not need to ... | <p>Take IISReset as a suite of commands that helps you manage IIS start / stop etc.</p> <p>This means you need to specify the option (<code>/switch</code>) what you want to do to carry out any operation.</p> <p>Default behavior OR default switch is <code>/restart</code> with <code>iisreset</code> so you do not need to ... | 64, 215, 1231, 1796, 7002 | batch-file, command, command-line, iis, windows | <h1>Difference between IISRESET and IIS Stop-Start command</h1>
<p>Is there any difference between commands <code>iisreset</code> and <code>iisreset /stop</code> followed by <code>iisreset /start</code> ? </p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,037 | cmd | # Difference between IISRESET and IIS Stop-Start command
Is there any difference between commands `iisreset` and `iisreset /stop` followed by `iisreset /start` ? | Take IISReset as a suite of commands that helps you manage IIS start / stop etc.
This means you need to specify the option (`/switch`) what you want to do to carry out any operation.
Default behavior OR default switch is `/restart` with `iisreset` so you do not need to run the command twice with `/start` and `/stop`.... |
232651 | Why "The system cannot find the batch label specified" is thrown even if label exists? | 89 | 2008-10-24 06:34:01 | <p>While running a batch file in Windows XP I have found randomly occurring error message:</p>
<blockquote>
<p>The system cannot find the batch label specified name_of_label</p>
</blockquote>
<p>Of course label existed. What causes this error?</p>
| 98,588 | 31,086 | 2025-05-19 20:12:20 | 232,674 | 102 | 2008-10-24 06:49:52 | 6,309 | 2025-05-19 20:12:20 | https://stackoverflow.com/q/232651 | https://stackoverflow.com/a/232674 | <p>Actually, you need 2 conditions for this to happen:</p>
<ul>
<li>the batch file must not use CRLF line endings</li>
<li>the label you jump to must span a block boundary (as opposed to and :end label wich is just a shortcut to the end of your script)</li>
</ul>
<p>See. <a href="https://web.archive.org/web/20160305063... | <p>Actually, you need 2 conditions for this to happen:</p> <ul> <li>the batch file must not use CRLF line endings</li> <li>the label you jump to must span a block boundary (as opposed to and :end label wich is just a shortcut to the end of your script)</li> </ul> <p>See. <a href="https://web.archive.org/web/20160305063... | 64, 7002, 55251 | batch-file, labeled-statements, windows | <h1>Why "The system cannot find the batch label specified" is thrown even if label exists?</h1>
<p>While running a batch file in Windows XP I have found randomly occurring error message:</p>
<blockquote>
<p>The system cannot find the batch label specified name_of_label</p>
</blockquote>
<p>Of course label existed. ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,038 | cmd | # Why "The system cannot find the batch label specified" is thrown even if label exists?
While running a batch file in Windows XP I have found randomly occurring error message:
> The system cannot find the batch label specified name_of_label
Of course label existed. What causes this error? | Actually, you need 2 conditions for this to happen:
- the batch file must not use CRLF line endings
- the label you jump to must span a block boundary (as opposed to and :end label wich is just a shortcut to the end of your script)
See. [The system cannot find the batch label specified](https://web.archive.org/web/20... |
7872113 | How to remove a folder and all its content from the current directory? | 47 | 2011-10-24 06:47:47 | <p>This code that does not work:</p>
<pre><code>@echo off
if exist output @set /p checkdir= Output directory found. Do you wish to overwrite it?:
if /I %checkdir% == Y deltree /s /output
pause
</code></pre>
| 77,818 | 866,800 | 2018-03-23 16:26:50 | 7,874,557 | 102 | 2011-10-24 10:57:24 | 1,001,360 | 2018-03-23 16:26:50 | https://stackoverflow.com/q/7872113 | https://stackoverflow.com/a/7874557 | <p>You were looking for this command:</p>
<pre><code>RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path
/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.
/Q Quiet mode, do not ask if ok ... | <p>You were looking for this command:</p> <pre><code>RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path /S Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree. /Q Quiet mode, do not ask if ok ... | 64, 7002 | batch-file, windows | <h1>How to remove a folder and all its content from the current directory?</h1>
<p>This code that does not work:</p>
<pre><code>@echo off
if exist output @set /p checkdir= Output directory found. Do you wish to overwrite it?:
if /I %checkdir% == Y deltree /s /output
pause
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,039 | cmd | # How to remove a folder and all its content from the current directory?
This code that does not work:
```
@echo off
if exist output @set /p checkdir= Output directory found. Do you wish to overwrite it?:
if /I %checkdir% == Y deltree /s /output
pause
``` | You were looking for this command:
```
RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path
/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.
/Q Quiet mode, do not ask if ok to remove a di... |
5837418 | How do you get the string length in a batch file? | 83 | 2011-04-29 21:08:17 | <p>There doesn't appear to be an easy way to get the length of a string in a batch file. E.g.,</p>
<pre><code>SET MY_STRING=abcdefg
SET /A MY_STRING_LEN=???
</code></pre>
<p>How would I find the string length of <code>MY_STRING</code>?</p>
<p>Bonus points if the string length function handles all possible character... | 218,899 | 19,719 | 2024-11-29 21:10:15 | 5,841,587 | 101 | 2011-04-30 12:01:47 | 463,115 | 2019-08-22 18:56:29 | https://stackoverflow.com/q/5837418 | https://stackoverflow.com/a/5841587 | <p>As there is no built in function for string length, you can write your own function like this one: </p>
<pre><code>@echo off
setlocal
REM *** Some tests, to check the functionality ***
REM *** An emptyStr has the length 0
set "emptyString="
call :strlen result emptyString
echo %result%
REM *** This string has the ... | <p>As there is no built in function for string length, you can write your own function like this one: </p> <pre><code>@echo off setlocal REM *** Some tests, to check the functionality *** REM *** An emptyStr has the length 0 set "emptyString=" call :strlen result emptyString echo %result% REM *** This string has the ... | 64, 139, 7002 | batch-file, string, windows | <h1>How do you get the string length in a batch file?</h1>
<p>There doesn't appear to be an easy way to get the length of a string in a batch file. E.g.,</p>
<pre><code>SET MY_STRING=abcdefg
SET /A MY_STRING_LEN=???
</code></pre>
<p>How would I find the string length of <code>MY_STRING</code>?</p>
<p>Bonus points i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,040 | cmd | # How do you get the string length in a batch file?
There doesn't appear to be an easy way to get the length of a string in a batch file. E.g.,
```
SET MY_STRING=abcdefg
SET /A MY_STRING_LEN=???
```
How would I find the string length of `MY_STRING`?
Bonus points if the string length function handles all possible ch... | As there is no built in function for string length, you can write your own function like this one:
```
@echo off
setlocal
REM *** Some tests, to check the functionality ***
REM *** An emptyStr has the length 0
set "emptyString="
call :strlen result emptyString
echo %result%
REM *** This string has the length 14
set "... |
12028372 | How do I change the command-line prompt in Windows? | 74 | 2012-08-19 17:12:23 | <p>How do I change the command-line prompt into a console?</p>
<p>I've been looking in the <a href="https://learn.microsoft.com/en-us/windows/console/console-functions" rel="noreferrer">console functions API</a>, but I could not find anything for it.</p>
| 113,480 | null | 2024-04-13 23:09:52 | 12,028,412 | 101 | 2012-08-19 17:18:01 | 118,068 | 2019-10-21 23:46:15 | https://stackoverflow.com/q/12028372 | https://stackoverflow.com/a/12028412 | <p>There's the PROMPT environment variable:</p>
<pre><code>set PROMPT=$P$G
</code></pre>
<p><code>$P$G</code> is the default value, giving you the usual <code>C:\></code> type output. There are more format variables <a href="http://www.hanselman.com/blog/ABetterPROMPTForCMDEXEOrCoolPromptEnvironmentVariablesAndANi... | <p>There's the PROMPT environment variable:</p> <pre><code>set PROMPT=$P$G </code></pre> <p><code>$P$G</code> is the default value, giving you the usual <code>C:\></code> type output. There are more format variables <a href="http://www.hanselman.com/blog/ABetterPROMPTForCMDEXEOrCoolPromptEnvironmentVariablesAndANi... | 64, 2631, 5003 | cmd, prompt, windows | <h1>How do I change the command-line prompt in Windows?</h1>
<p>How do I change the command-line prompt into a console?</p>
<p>I've been looking in the <a href="https://learn.microsoft.com/en-us/windows/console/console-functions" rel="noreferrer">console functions API</a>, but I could not find anything for it.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,041 | cmd | # How do I change the command-line prompt in Windows?
How do I change the command-line prompt into a console?
I've been looking in the [console functions API](https://learn.microsoft.com/en-us/windows/console/console-functions), but I could not find anything for it. | There's the PROMPT environment variable:
```
set PROMPT=$P$G
```
`$P$G` is the default value, giving you the usual `C:\>` type output. There are more format variables [available here](http://www.hanselman.com/blog/ABetterPROMPTForCMDEXEOrCoolPromptEnvironmentVariablesAndANiceTransparentMultiprompt.aspx). |
245840 | How do I rename files in sub directories? | 49 | 2008-10-29 04:57:44 | <p>Is there any way of batch renaming files in sub directories?</p>
<p>For example:</p>
<p>Rename <code>*.html</code> to <code>*.htm</code> in a folder which has directories and sub directories.</p>
| 118,127 | 12,178 | 2024-08-13 16:26:46 | 245,862 | 101 | 2008-10-29 05:14:39 | 19,650 | 2015-07-13 20:20:08 | https://stackoverflow.com/q/245840 | https://stackoverflow.com/a/245862 | <p>Windows command prompt: (If inside a batch file, change %x to %%x)</p>
<pre><code>for /r %x in (*.html) do ren "%x" *.htm
</code></pre>
<p>This also works for renaming the middle of the files</p>
<pre><code>for /r %x in (website*.html) do ren "%x" site*.htm
</code></pre>
| <p>Windows command prompt: (If inside a batch file, change %x to %%x)</p> <pre><code>for /r %x in (*.html) do ren "%x" *.htm </code></pre> <p>This also works for renaming the middle of the files</p> <pre><code>for /r %x in (website*.html) do ren "%x" site*.htm </code></pre> | 64, 724, 13475 | batch-rename, file-io, windows | <h1>How do I rename files in sub directories?</h1>
<p>Is there any way of batch renaming files in sub directories?</p>
<p>For example:</p>
<p>Rename <code>*.html</code> to <code>*.htm</code> in a folder which has directories and sub directories.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,042 | cmd | # How do I rename files in sub directories?
Is there any way of batch renaming files in sub directories?
For example:
Rename `*.html` to `*.htm` in a folder which has directories and sub directories. | Windows command prompt: (If inside a batch file, change %x to %%x)
```
for /r %x in (*.html) do ren "%x" *.htm
```
This also works for renaming the middle of the files
```
for /r %x in (website*.html) do ren "%x" site*.htm
``` |
14731877 | To "Call" or "Not to Call" a batch file? | 96 | 2013-02-06 14:49:53 | <p>If from inside a bat file you called another batch file but still had a few remaining operations to complete, how can you make sure that the call to first bat file will after completion or error, will return to the file that called it in the first instance?</p>
<p>Example:</p>
<pre><code>CD:\MyFolder\MyFiles
Mybat... | 126,899 | 1,073,481 | 2025-01-05 14:47:00 | 14,732,373 | 99 | 2013-02-06 15:15:52 | 1,012,053 | 2017-04-23 14:24:31 | https://stackoverflow.com/q/14731877 | https://stackoverflow.com/a/14732373 | <p>As others have said, <code>CALL</code> is the normal way to call another bat file within a .bat and return to the caller.</p>
<p>However, all batch file processing will cease (control will not return to the caller) if the CALLed batch file has a fatal syntax error, or if the CALLed script terminates with EXIT witho... | <p>As others have said, <code>CALL</code> is the normal way to call another bat file within a .bat and return to the caller.</p> <p>However, all batch file processing will cease (control will not return to the caller) if the CALLed batch file has a fatal syntax error, or if the CALLed script terminates with EXIT witho... | 1231, 2631, 7002, 8632 | batch-file, call, cmd, command-line | <h1>To "Call" or "Not to Call" a batch file?</h1>
<p>If from inside a bat file you called another batch file but still had a few remaining operations to complete, how can you make sure that the call to first bat file will after completion or error, will return to the file that called it in the first instance?</p>
<p>E... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,044 | cmd | # To "Call" or "Not to Call" a batch file?
If from inside a bat file you called another batch file but still had a few remaining operations to complete, how can you make sure that the call to first bat file will after completion or error, will return to the file that called it in the first instance?
Example:
```
CD:... | As others have said, `CALL` is the normal way to call another bat file within a .bat and return to the caller.
However, all batch file processing will cease (control will not return to the caller) if the CALLed batch file has a fatal syntax error, or if the CALLed script terminates with EXIT without the /B option.
Yo... |
28736666 | Curl not recognized as an internal or external command, operable program or batch file | 46 | 2015-02-26 07:26:29 | <p>I have installed <code>curl</code> and have set it as <code>environment variable</code> in my system. But when running the <code>curl</code> command its giving an error <code>'curl' is not recognized as an internal or external command, operable program or batch file.</code>I tried restarting my system but is of no u... | 205,871 | 4,222,376 | 2019-10-08 20:35:31 | 28,757,477 | 99 | 2015-02-27 04:21:14 | 4,222,376 | 2019-10-08 20:35:31 | https://stackoverflow.com/q/28736666 | https://stackoverflow.com/a/28757477 | <p><strong>Steps to install curl in windows</strong></p>
<p><strong>Install cURL on Windows</strong></p>
<p>There are 4 steps to follow to get cURL installed on Windows.</p>
<p>Step 1 and Step 2 is to install SSL library.
Step 3 is to install cURL.
Step 4 is to install a recent certificate</p>
<p><strong>Step One: ... | <p><strong>Steps to install curl in windows</strong></p> <p><strong>Install cURL on Windows</strong></p> <p>There are 4 steps to follow to get cURL installed on Windows.</p> <p>Step 1 and Step 2 is to install SSL library. Step 3 is to install cURL. Step 4 is to install a recent certificate</p> <p><strong>Step One: ... | 64, 1554, 2631, 7002, 98265 | batch-file, cmd, curl, hockeyapp, windows | <h1>Curl not recognized as an internal or external command, operable program or batch file</h1>
<p>I have installed <code>curl</code> and have set it as <code>environment variable</code> in my system. But when running the <code>curl</code> command its giving an error <code>'curl' is not recognized as an internal or ext... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,045 | cmd | # Curl not recognized as an internal or external command, operable program or batch file
I have installed `curl` and have set it as `environment variable` in my system. But when running the `curl` command its giving an error `'curl' is not recognized as an internal or external command, operable program or batch file.`... | **Steps to install curl in windows**
**Install cURL on Windows**
There are 4 steps to follow to get cURL installed on Windows.
Step 1 and Step 2 is to install SSL library.
Step 3 is to install cURL.
Step 4 is to install a recent certificate
**Step One: Install Visual C++ 2008 Redistributables**
From <https://www.m... |
15736898 | Running a shell script through Cygwin on Windows | 73 | 2013-04-01 02:30:42 | <p>I have a bunch of shell scripts that used to run on a Linux machine. Now, we've switched over to Windows, and I need to run these scripts there. I have <a href="http://en.wikipedia.org/wiki/Cygwin">Cygwin</a> installed, but is there a way to make the script run using Cygwin, but the <strong>call is made from Windows... | 206,075 | 2,087,639 | 2019-03-18 09:06:20 | 15,737,000 | 97 | 2013-04-01 02:45:14 | 1,960,027 | 2013-04-01 02:45:14 | https://stackoverflow.com/q/15736898 | https://stackoverflow.com/a/15737000 | <p>Sure. On my (pretty vanilla) Cygwin setup, <code>bash</code> is in <code>c:\cygwin\bin</code> so I can run a <code>bash</code> script (say <code>testit.sh</code>) from a Windows batch file using a command like:</p>
<pre><code>C:\cygwin\bin\bash testit.sh
</code></pre>
<p>... which can be included in a <code>.bat</... | <p>Sure. On my (pretty vanilla) Cygwin setup, <code>bash</code> is in <code>c:\cygwin\bin</code> so I can run a <code>bash</code> script (say <code>testit.sh</code>) from a Windows batch file using a command like:</p> <pre><code>C:\cygwin\bin\bash testit.sh </code></pre> <p>... which can be included in a <code>.bat</... | 1731, 7002 | batch-file, cygwin | <h1>Running a shell script through Cygwin on Windows</h1>
<p>I have a bunch of shell scripts that used to run on a Linux machine. Now, we've switched over to Windows, and I need to run these scripts there. I have <a href="http://en.wikipedia.org/wiki/Cygwin">Cygwin</a> installed, but is there a way to make the script r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,046 | cmd | # Running a shell script through Cygwin on Windows
I have a bunch of shell scripts that used to run on a Linux machine. Now, we've switched over to Windows, and I need to run these scripts there. I have [Cygwin](http://en.wikipedia.org/wiki/Cygwin) installed, but is there a way to make the script run using Cygwin, but... | Sure. On my (pretty vanilla) Cygwin setup, `bash` is in `c:\cygwin\bin` so I can run a `bash` script (say `testit.sh`) from a Windows batch file using a command like:
```
C:\cygwin\bin\bash testit.sh
```
... which can be included in a `.bat` file as easily as it can be typed at the command line, and with the same eff... |
353161 | How to test whether a service is running from the command line | 71 | 2008-12-09 15:37:37 | <p>I would like to be able to query whether or not a service is running from a windows batch file. I know I can use: </p>
<blockquote>
<p>sc query "ServiceName" </p>
</blockquote>
<p>but, this dumps out some text. What I really want is for it to set the <code>errorlevel</code> environment variable so that I can t... | 339,168 | 11,898 | 2023-06-16 11:05:09 | 353,196 | 97 | 2008-12-09 15:46:14 | 25,737 | 2008-12-09 15:46:14 | https://stackoverflow.com/q/353161 | https://stackoverflow.com/a/353196 | <pre><code>sc query "ServiceName" | find "RUNNING"
</code></pre>
| <pre><code>sc query "ServiceName" | find "RUNNING" </code></pre> | 64, 7002 | batch-file, windows | <h1>How to test whether a service is running from the command line</h1>
<p>I would like to be able to query whether or not a service is running from a windows batch file. I know I can use: </p>
<blockquote>
<p>sc query "ServiceName" </p>
</blockquote>
<p>but, this dumps out some text. What I really want is for it... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,047 | cmd | # How to test whether a service is running from the command line
I would like to be able to query whether or not a service is running from a windows batch file. I know I can use:
> sc query "ServiceName"
but, this dumps out some text. What I really want is for it to set the `errorlevel` environment variable so that ... | ```
sc query "ServiceName" | find "RUNNING"
``` |
9252980 | How to split the filename from a full path in batch? | 70 | 2012-02-12 21:42:47 | <p>How do I split the filename out of a full path in batch scripting?</p>
| 145,397 | 288,280 | 2023-03-03 20:49:02 | 9,253,018 | 97 | 2012-02-12 21:48:14 | 595,787 | 2012-02-12 21:48:14 | https://stackoverflow.com/q/9252980 | https://stackoverflow.com/a/9253018 | <pre><code>@echo off
Set filename=C:\Documents and Settings\All Users\Desktop\Dostips.cmd
For %%A in ("%filename%") do (
Set Folder=%%~dpA
Set Name=%%~nxA
)
echo.Folder is: %Folder%
echo.Name is: %Name%
</code></pre>
<p>But I can't take credit for this; Google found this at <a href="http://www.dostips.com/foru... | <pre><code>@echo off Set filename=C:\Documents and Settings\All Users\Desktop\Dostips.cmd For %%A in ("%filename%") do ( Set Folder=%%~dpA Set Name=%%~nxA ) echo.Folder is: %Folder% echo.Name is: %Name% </code></pre> <p>But I can't take credit for this; Google found this at <a href="http://www.dostips.com/foru... | 7002 | batch-file | <h1>How to split the filename from a full path in batch?</h1>
<p>How do I split the filename out of a full path in batch scripting?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,048 | cmd | # How to split the filename from a full path in batch?
How do I split the filename out of a full path in batch scripting? | ```
@echo off
Set filename=C:\Documents and Settings\All Users\Desktop\Dostips.cmd
For %%A in ("%filename%") do (
Set Folder=%%~dpA
Set Name=%%~nxA
)
echo.Folder is: %Folder%
echo.Name is: %Name%
```
But I can't take credit for this; Google found this at <http://www.dostips.com/forum/viewtopic.php?f=3&t=409> |
338895 | What ever happened to deltree, and what's its replacement? | 88 | 2008-12-03 21:59:56 | <p>In earlier versions of MS-DOS - I want to say version 7, but I could be wrong - there was a <code>deltree</code> command, which recursively deleted all subdirectories and files from a given path. </p>
<p><code>deltree</code> no longer exists, but <code>del</code> didn't seem to inherit the ability to delete a tree... | 94,226 | 2,197 | 2023-02-03 22:01:21 | 14,345,791 | 96 | 2013-01-15 19:57:45 | 119,540 | 2013-01-15 20:03:44 | https://stackoverflow.com/q/338895 | https://stackoverflow.com/a/14345791 | <p>As others have mentioned, the <code>rd</code> command has the <code>/s</code> switch to recursively remove sub-directories. You can combine it with the <code>/q</code> switch to forcibly delete a sub-directory (and its contents) without prompting as so</p>
<pre><code>rd /s /q c:\foobar
</code></pre>
<p>What everyb... | <p>As others have mentioned, the <code>rd</code> command has the <code>/s</code> switch to recursively remove sub-directories. You can combine it with the <code>/q</code> switch to forcibly delete a sub-directory (and its contents) without prompting as so</p> <pre><code>rd /s /q c:\foobar </code></pre> <p>What everyb... | 64, 2631, 5370, 7002 | batch-file, cmd, dos, windows | <h1>What ever happened to deltree, and what's its replacement?</h1>
<p>In earlier versions of MS-DOS - I want to say version 7, but I could be wrong - there was a <code>deltree</code> command, which recursively deleted all subdirectories and files from a given path. </p>
<p><code>deltree</code> no longer exists, but ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,049 | cmd | # What ever happened to deltree, and what's its replacement?
In earlier versions of MS-DOS - I want to say version 7, but I could be wrong - there was a `deltree` command, which recursively deleted all subdirectories and files from a given path.
`deltree` no longer exists, but `del` didn't seem to inherit the ability... | As others have mentioned, the `rd` command has the `/s` switch to recursively remove sub-directories. You can combine it with the `/q` switch to forcibly delete a sub-directory (and its contents) without prompting as so
```
rd /s /q c:\foobar
```
What everybody is missing is that `rd` is *not* an exact replacement fo... |
16632524 | What does :: (double colon) mean in DOS batch files? | 72 | 2013-05-19 07:57:27 | <p>I found this program <a href="https://web.archive.org/web/20140225075758/http://baiyunmanor.com/blog/work/get-current-date-time-in-dos-batch-file/" rel="noreferrer">web.archive.org: http://baiyunmanor.com/blog/work/get-current-date-time-in-dos-batch-file/</a></p>
<pre><code>::::::::::::::::::::::::::::::::::::::::::... | 56,045 | 310,291 | 2021-04-08 07:38:54 | 16,632,555 | 96 | 2013-05-19 08:02:30 | 1,850,609 | 2021-01-15 21:56:52 | https://stackoverflow.com/q/16632524 | https://stackoverflow.com/a/16632555 | <p><code>::</code> is a label (inaccurately also known as <em>comment label</em>) can be, in practice, considered a comment just as <code>REM</code> is, because it is an "un-goto-able" label.</p>
<p>There are some <strong>differences</strong> between <code>REM</code> and <code>::</code>, though. The main ones... | <p><code>::</code> is a label (inaccurately also known as <em>comment label</em>) can be, in practice, considered a comment just as <code>REM</code> is, because it is an "un-goto-able" label.</p> <p>There are some <strong>differences</strong> between <code>REM</code> and <code>::</code>, though. The main ones... | 7002 | batch-file | <h1>What does :: (double colon) mean in DOS batch files?</h1>
<p>I found this program <a href="https://web.archive.org/web/20140225075758/http://baiyunmanor.com/blog/work/get-current-date-time-in-dos-batch-file/" rel="noreferrer">web.archive.org: http://baiyunmanor.com/blog/work/get-current-date-time-in-dos-batch-file/... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,050 | cmd | # What does :: (double colon) mean in DOS batch files?
I found this program [web.archive.org: http://baiyunmanor.com/blog/work/get-current-date-time-in-dos-batch-file/](https://web.archive.org/web/20140225075758/http://baiyunmanor.com/blog/work/get-current-date-time-in-dos-batch-file/)
```
:::::::::::::::::::::::::::... | `::` is a label (inaccurately also known as *comment label*) can be, in practice, considered a comment just as `REM` is, because it is an "un-goto-able" label.
There are some **differences** between `REM` and `::`, though. The main ones are:
- With `ECHO ON` a `REM` line is shown but not a line commented with `::`
- ... |
9681863 | Windows Batch Variables Won't Set | 51 | 2012-03-13 10:00:31 | <p>I think I ran into a bug in Window's batch scripting.</p>
<p>I cannot set variables that are in an expanded if statement.</p>
<p>Here is an isolated part of my script:</p>
<pre><code>@echo off
set success=1
set Version=12345
set Target=Client
set Type=456
set dir=
set zip=
if "%Version%"=="" set success=0
if "%... | 51,727 | 1,258,524 | 2021-10-05 11:12:26 | 9,681,923 | 96 | 2012-03-13 10:04:28 | 73,070 | 2021-10-05 11:12:26 | https://stackoverflow.com/q/9681863 | https://stackoverflow.com/a/9681923 | <p>You missed something ;-)</p>
<p><code>cmd</code> expands variables when commands are <em>parsed</em>, not when they are run. It so happens that an <code>if</code> or <code>for</code> statement with a block <code>( ... )</code> (or actually any block) counts as a single command in that case. So when you set variables... | <p>You missed something ;-)</p> <p><code>cmd</code> expands variables when commands are <em>parsed</em>, not when they are run. It so happens that an <code>if</code> or <code>for</code> statement with a block <code>( ... )</code> (or actually any block) counts as a single command in that case. So when you set variables... | 64, 2631, 2773, 7002, 19675 | batch-file, cmd, delayedvariableexpansion, if-statement, windows | <h1>Windows Batch Variables Won't Set</h1>
<p>I think I ran into a bug in Window's batch scripting.</p>
<p>I cannot set variables that are in an expanded if statement.</p>
<p>Here is an isolated part of my script:</p>
<pre><code>@echo off
set success=1
set Version=12345
set Target=Client
set Type=456
set dir=
set z... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,051 | cmd | # Windows Batch Variables Won't Set
I think I ran into a bug in Window's batch scripting.
I cannot set variables that are in an expanded if statement.
Here is an isolated part of my script:
```
@echo off
set success=1
set Version=12345
set Target=Client
set Type=456
set dir=
set zip=
if "%Version%"=="" set succes... | You missed something ;-)
`cmd` expands variables when commands are *parsed*, not when they are run. It so happens that an `if` or `for` statement with a block `( ... )` (or actually any block) counts as a single command in that case. So when you set variables inside a block *and* try using them in the same block there... |
19829516 | e pyhow to get python installed path from command line | 39 | 2013-11-07 06:39:47 | <p>I am trying to get the installed path of python?
Any idea how to get the python installed path from command line in windows. I don't want to set the environment variable?</p>
<p>Thanks,</p>
| 145,541 | 2,499,879 | 2024-06-26 13:45:19 | 19,829,542 | 96 | 2013-11-07 06:41:42 | 2,581,969 | 2013-11-07 06:47:17 | https://stackoverflow.com/q/19829516 | https://stackoverflow.com/a/19829542 | <p>try opening up <code>cmd</code> and simply:</p>
<pre><code>where python
</code></pre>
<p>By default, this searches your PATH for matches. More precisely:</p>
<blockquote>
<p>Description:
Displays the location of files that match the search pattern.
By default, the search is done along the current d... | <p>try opening up <code>cmd</code> and simply:</p> <pre><code>where python </code></pre> <p>By default, this searches your PATH for matches. More precisely:</p> <blockquote> <p>Description: Displays the location of files that match the search pattern. By default, the search is done along the current d... | 16, 64, 2631, 59047 | cmd, python, python-2.7, windows | <h1>e pyhow to get python installed path from command line</h1>
<p>I am trying to get the installed path of python?
Any idea how to get the python installed path from command line in windows. I don't want to set the environment variable?</p>
<p>Thanks,</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,052 | cmd | # e pyhow to get python installed path from command line
I am trying to get the installed path of python?
Any idea how to get the python installed path from command line in windows. I don't want to set the environment variable?
Thanks, | try opening up `cmd` and simply:
```
where python
```
By default, this searches your PATH for matches. More precisely:
> Description:
> Displays the location of files that match the search pattern.
> By default, the search is done along the current directory and
> in the paths specified by the PATH environment varia... |
4313422 | Generate GUID in Windows with batch file | 71 | 2010-11-30 11:54:54 | <p>How can I generate a GUID in a batch file running using the commandline in Windows?</p>
| 89,730 | 368,472 | 2023-08-07 12:46:12 | 4,313,447 | 95 | 2010-11-30 11:57:47 | 32,133 | 2016-07-20 12:30:44 | https://stackoverflow.com/q/4313422 | https://stackoverflow.com/a/4313447 | <p>The Windows SDK comes with a tool called <code>uuidgen</code> (if you have Visual Studio, you'll have the Windows SDK, and you need to run the <a href="https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx" rel="noreferrer">Visual Studio Command Prompt</a> to set proper paths).</p>
<pre><code>C:\>uuid... | <p>The Windows SDK comes with a tool called <code>uuidgen</code> (if you have Visual Studio, you'll have the Windows SDK, and you need to run the <a href="https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx" rel="noreferrer">Visual Studio Command Prompt</a> to set proper paths).</p> <pre><code>C:\>uuid... | 1231, 2631, 3567, 7002 | batch-file, cmd, command-line, guid | <h1>Generate GUID in Windows with batch file</h1>
<p>How can I generate a GUID in a batch file running using the commandline in Windows?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,053 | cmd | # Generate GUID in Windows with batch file
How can I generate a GUID in a batch file running using the commandline in Windows? | The Windows SDK comes with a tool called `uuidgen` (if you have Visual Studio, you'll have the Windows SDK, and you need to run the [Visual Studio Command Prompt](https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx) to set proper paths).
```
C:\>uuidgen
```
This will output a new GUID, e.g.
> cc23b318-1... |
11270453 | How to remove spaces from file names (in bulk) | 36 | 2012-06-30 00:22:20 | <p>How to remove spaces (not replace with underscores) from several thousand files in bulk in Windows? Can I do this from the DOS command?</p>
<p>Currently:</p>
<pre><code>file one.mp3
file two.mp3
</code></pre>
<p>All files need to become:</p>
<pre><code>fileone.mp3
filetwo.mp3
</code></pre>
| 142,307 | 275,390 | 2022-11-23 16:10:54 | 11,278,987 | 95 | 2012-07-01 01:40:16 | 1,012,053 | 2016-05-13 20:48:37 | https://stackoverflow.com/q/11270453 | https://stackoverflow.com/a/11278987 | <p>Here is a script that can efficiently bulk rename files, stripping all spaces from the name.</p>
<pre><code>:renameNoSpace [/R] [FolderPath]
@echo off
setlocal disableDelayedExpansion
if /i "%~1"=="/R" (
set "forOption=%~1 %2"
set "inPath="
) else (
set "forOption="
if "%~1" neq "" (set "inPath=%~1\") els... | <p>Here is a script that can efficiently bulk rename files, stripping all spaces from the name.</p> <pre><code>:renameNoSpace [/R] [FolderPath] @echo off setlocal disableDelayedExpansion if /i "%~1"=="/R" ( set "forOption=%~1 %2" set "inPath=" ) else ( set "forOption=" if "%~1" neq "" (set "inPath=%~1\") els... | 64, 7002, 9802 | batch-file, renaming, windows | <h1>How to remove spaces from file names (in bulk)</h1>
<p>How to remove spaces (not replace with underscores) from several thousand files in bulk in Windows? Can I do this from the DOS command?</p>
<p>Currently:</p>
<pre><code>file one.mp3
file two.mp3
</code></pre>
<p>All files need to become:</p>
<pre><code>file... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,055 | cmd | # How to remove spaces from file names (in bulk)
How to remove spaces (not replace with underscores) from several thousand files in bulk in Windows? Can I do this from the DOS command?
Currently:
```
file one.mp3
file two.mp3
```
All files need to become:
```
fileone.mp3
filetwo.mp3
``` | Here is a script that can efficiently bulk rename files, stripping all spaces from the name.
```
:renameNoSpace [/R] [FolderPath]
@echo off
setlocal disableDelayedExpansion
if /i "%~1"=="/R" (
set "forOption=%~1 %2"
set "inPath="
) else (
set "forOption="
if "%~1" neq "" (set "inPath=%~1\") else set "inPath=... |
773610 | Add a new line to a text file in MS-DOS | 51 | 2009-04-21 17:07:20 | <p>I am making a <code>.bat</code> file, and I would like it to write <a href="http://en.wikipedia.org/wiki/ASCII_art" rel="noreferrer">ASCII art</a> into a text file.</p>
<p>I was able to find the command to append a new line to the file when echoing text, but when I read that text file, all I see is a layout-sign an... | 248,457 | 93,896 | 2017-07-12 04:18:58 | 773,617 | 94 | 2009-04-21 17:10:21 | 37,923 | 2009-04-21 17:39:45 | https://stackoverflow.com/q/773610 | https://stackoverflow.com/a/773617 | <pre><code>echo Hello, > file.txt
echo. >>file.txt
echo world >>file.txt
</code></pre>
<p>and you can always run:</p>
<pre><code>wordpad file.txt
</code></pre>
<p>on any version of Windows.</p>
<hr>
<p>On Windows 2000 and above you can do:</p>
<pre><code>( echo Hello, & echo. & echo ... | <pre><code>echo Hello, > file.txt echo. >>file.txt echo world >>file.txt </code></pre> <p>and you can always run:</p> <pre><code>wordpad file.txt </code></pre> <p>on any version of Windows.</p> <hr> <p>On Windows 2000 and above you can do:</p> <pre><code>( echo Hello, & echo. & echo ... | 3705, 7002 | batch-file, newline | <h1>Add a new line to a text file in MS-DOS</h1>
<p>I am making a <code>.bat</code> file, and I would like it to write <a href="http://en.wikipedia.org/wiki/ASCII_art" rel="noreferrer">ASCII art</a> into a text file.</p>
<p>I was able to find the command to append a new line to the file when echoing text, but when I r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,056 | cmd | # Add a new line to a text file in MS-DOS
I am making a `.bat` file, and I would like it to write [ASCII art](http://en.wikipedia.org/wiki/ASCII_art) into a text file.
I was able to find the command to append a new line to the file when echoing text, but when I read that text file, all I see is a layout-sign and not ... | ```
echo Hello, > file.txt
echo. >>file.txt
echo world >>file.txt
```
and you can always run:
```
wordpad file.txt
```
on any version of Windows.
---
On Windows 2000 and above you can do:
```
( echo Hello, & echo. & echo world ) > file.txt
```
---
Another way of showing a message for a small amount of te... |
29227208 | how to kill a program by process name using cmd in windows 8? | 44 | 2015-03-24 07:39:25 | <p>it seems that whenever i open a program in windows 8, the process name is <code>WWAHost.exe</code></p>
<p>i would like to be able to do something like <code>TASKKILL /F /IM notepad.exe</code> and terminate a specific process by name</p>
<p>if i kill <code>WWAHost.exe</code> then all open programs will die.</p>
<p... | 65,868 | 642,022 | 2019-02-06 10:52:41 | 29,233,238 | 93 | 2015-03-24 12:55:54 | null | 2019-02-06 10:52:41 | https://stackoverflow.com/q/29227208 | https://stackoverflow.com/a/29233238 | <p>You can kill the process <strong>and</strong> all its children (ie. all processes started by it) using the <code>/t</code> switch:</p>
<pre><code>taskkill /f /t /im wwahost.exe
</code></pre>
<hr>
<p>See the documentation for <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands... | <p>You can kill the process <strong>and</strong> all its children (ie. all processes started by it) using the <code>/t</code> switch:</p> <pre><code>taskkill /f /t /im wwahost.exe </code></pre> <hr> <p>See the documentation for <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands... | 64, 2631, 5910, 12488, 32466 | cmd, process, taskkill, uid, windows | <h1>how to kill a program by process name using cmd in windows 8?</h1>
<p>it seems that whenever i open a program in windows 8, the process name is <code>WWAHost.exe</code></p>
<p>i would like to be able to do something like <code>TASKKILL /F /IM notepad.exe</code> and terminate a specific process by name</p>
<p>if i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,057 | cmd | # how to kill a program by process name using cmd in windows 8?
it seems that whenever i open a program in windows 8, the process name is `WWAHost.exe`
i would like to be able to do something like `TASKKILL /F /IM notepad.exe` and terminate a specific process by name
if i kill `WWAHost.exe` then all open programs wi... | You can kill the process **and** all its children (ie. all processes started by it) using the `/t` switch:
```
taskkill /f /t /im wwahost.exe
```
---
See the documentation for [taskkill](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill) ([ss64](https://ss64.com/nt/taskkill.ht... |
29955217 | Global NPM package installed but command not found | 63 | 2015-04-29 21:49:44 | <p>I have globally installed two npm packages <a href="https://www.npmjs.com/package/download">"download"</a> and <a href="https://www.npmjs.com/package/enigmavirtualbox">"enigmavirtualbox"</a> via command line:</p>
<p><code>npm install -g download</code> and
<code>npm install -g engimavirtualbox</code></p>
<p>I'm tr... | 73,127 | 3,248,285 | 2022-07-20 09:30:43 | 29,955,218 | 92 | 2015-04-29 21:49:44 | 3,248,285 | 2022-02-15 21:39:12 | https://stackoverflow.com/q/29955217 | https://stackoverflow.com/a/29955218 | <p>The executable binaries and .cmd files end up in <code>C:\Users\<username>\AppData\Roaming\npm</code> (minus the <code>node_modules</code> at the end) so adding that path to the PATH env. variable fixed the issue.</p>
<p>With environment variables, the path can be abbreviated: <code>%appdata\npm</code>.</p>
| <p>The executable binaries and .cmd files end up in <code>C:\Users\<username>\AppData\Roaming\npm</code> (minus the <code>node_modules</code> at the end) so adding that path to the PATH env. variable fixed the issue.</p> <p>With environment variables, the path can be abbreviated: <code>%appdata\npm</code>.</p> | 64, 7002, 13613, 46426, 61387 | batch-file, node.js, npm, package, windows | <h1>Global NPM package installed but command not found</h1>
<p>I have globally installed two npm packages <a href="https://www.npmjs.com/package/download">"download"</a> and <a href="https://www.npmjs.com/package/enigmavirtualbox">"enigmavirtualbox"</a> via command line:</p>
<p><code>npm install -g download</code> and... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,059 | cmd | # Global NPM package installed but command not found
I have globally installed two npm packages ["download"](https://www.npmjs.com/package/download) and ["enigmavirtualbox"](https://www.npmjs.com/package/enigmavirtualbox) via command line:
`npm install -g download` and
`npm install -g engimavirtualbox`
I'm trying to... | The executable binaries and .cmd files end up in `C:\Users\<username>\AppData\Roaming\npm` (minus the `node_modules` at the end) so adding that path to the PATH env. variable fixed the issue.
With environment variables, the path can be abbreviated: `%appdata\npm`. |
15346863 | Windows Batch Script: Redirect ALL output to a file | 50 | 2013-03-11 19:24:53 | <p>I am running various Java benchmarks and would like to archive the results. I execute the (dacapo) benchmark like this:</p>
<pre><code>C:\VM\jre\bin\java -jar C:\benchmarks\dacapo-9.12-bach.jar %arg1% > %time::=%
</code></pre>
<p>I pass the type of benchmark in over a parameter, thats what %arg1% is.</p>
<p>Y... | 63,297 | 497,393 | 2018-05-14 20:39:47 | 15,346,929 | 92 | 2013-03-11 19:27:59 | 283,361 | 2018-05-14 20:39:47 | https://stackoverflow.com/q/15346863 | https://stackoverflow.com/a/15346929 | <p>You must redirect <em>STDOUT</em> and <em>STDERR</em>.</p>
<p><code>command > logfile 2>&1</code></p>
<p><em>STDIN</em> is file descriptor #0, <em>STDOUT</em> is file descriptor #1 and <em>STDERR</em> is file descriptor #2.<br>
Just as "command > file" redirects <em>STDOUT</em> to a file, you may also re... | <p>You must redirect <em>STDOUT</em> and <em>STDERR</em>.</p> <p><code>command > logfile 2>&1</code></p> <p><em>STDIN</em> is file descriptor #0, <em>STDOUT</em> is file descriptor #1 and <em>STDERR</em> is file descriptor #2.<br> Just as "command > file" redirects <em>STDOUT</em> to a file, you may also re... | 64, 7002, 105946 | batch-file, dacapo, windows | <h1>Windows Batch Script: Redirect ALL output to a file</h1>
<p>I am running various Java benchmarks and would like to archive the results. I execute the (dacapo) benchmark like this:</p>
<pre><code>C:\VM\jre\bin\java -jar C:\benchmarks\dacapo-9.12-bach.jar %arg1% > %time::=%
</code></pre>
<p>I pass the type of b... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,060 | cmd | # Windows Batch Script: Redirect ALL output to a file
I am running various Java benchmarks and would like to archive the results. I execute the (dacapo) benchmark like this:
```
C:\VM\jre\bin\java -jar C:\benchmarks\dacapo-9.12-bach.jar %arg1% > %time::=%
```
I pass the type of benchmark in over a parameter, thats ... | You must redirect *STDOUT* and *STDERR*.
`command > logfile 2>&1`
*STDIN* is file descriptor #0, *STDOUT* is file descriptor #1 and *STDERR* is file descriptor #2.
Just as "command > file" redirects *STDOUT* to a file, you may also redirect arbitrary file descriptors to each other. The `>&` operator redirects betwe... |
19899316 | How to print the current time in a Batch-File? | 103 | 2013-11-11 05:16:37 | <p>I need to print time in a batch file but command prompt tells me that the syntax is incorrect.
Here is the code i have so far:</p>
<pre><code>@echo %time%
ping -n 1 -w 1 127.0.0.1 1>nul
@echo %time%
pause
cls
</code></pre>
<p>I don't know why it isn't working, Please help Me.</p>
| 299,461 | 2,975,367 | 2025-09-11 18:46:05 | 19,899,343 | 90 | 2013-11-11 05:18:42 | 2,392,683 | 2016-05-11 21:22:07 | https://stackoverflow.com/q/19899316 | https://stackoverflow.com/a/19899343 | <p>If you use the command</p>
<pre><code>time /T
</code></pre>
<p>that will print the time. (without the /T, it will try to set the time)</p>
<pre><code>date /T
</code></pre>
<p>is similar for the date.</p>
<p>If cmd's Command Extensions are enabled (they are enabled by default, but in this question they appear to... | <p>If you use the command</p> <pre><code>time /T </code></pre> <p>that will print the time. (without the /T, it will try to set the time)</p> <pre><code>date /T </code></pre> <p>is similar for the date.</p> <p>If cmd's Command Extensions are enabled (they are enabled by default, but in this question they appear to... | 603, 7002 | batch-file, time | <h1>How to print the current time in a Batch-File?</h1>
<p>I need to print time in a batch file but command prompt tells me that the syntax is incorrect.
Here is the code i have so far:</p>
<pre><code>@echo %time%
ping -n 1 -w 1 127.0.0.1 1>nul
@echo %time%
pause
cls
</code></pre>
<p>I don't know why it isn't work... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,062 | cmd | # How to print the current time in a Batch-File?
I need to print time in a batch file but command prompt tells me that the syntax is incorrect.
Here is the code i have so far:
```
@echo %time%
ping -n 1 -w 1 127.0.0.1 1>nul
@echo %time%
pause
cls
```
I don't know why it isn't working, Please help Me. | If you use the command
```
time /T
```
that will print the time. (without the /T, it will try to set the time)
```
date /T
```
is similar for the date.
If cmd's Command Extensions are enabled (they are enabled by default, but in this question they appear to be disabled), then the environment variables `%DATE%` and... |
24121046 | Difference between xcopy and robocopy | 87 | 2014-06-09 13:09:58 | <p>I'm kind of new to batch scripting.
As a newbie I find both both of them useful while scripting
What are the key differences between xcopy and robocopy?</p>
| 174,370 | 2,706,419 | 2023-09-12 21:21:08 | 24,121,244 | 90 | 2014-06-09 13:21:18 | 2,027,232 | 2023-04-20 17:26:56 | https://stackoverflow.com/q/24121046 | https://stackoverflow.com/a/24121244 | <p>Robocopy replaces XCopy in the newer versions of windows</p>
<ol>
<li>Uses Mirroring, XCopy does not</li>
<li>Has a /RH option to allow a set time for the copy to run</li>
<li>Has a /MON:n option to check differences in files</li>
<li>Copies over more file attributes than XCopy</li>
</ol>
<p>Yes i agree with Mark Se... | <p>Robocopy replaces XCopy in the newer versions of windows</p> <ol> <li>Uses Mirroring, XCopy does not</li> <li>Has a /RH option to allow a set time for the copy to run</li> <li>Has a /MON:n option to check differences in files</li> <li>Copies over more file attributes than XCopy</li> </ol> <p>Yes i agree with Mark Se... | 64, 7002, 30645 | batch-file, batch-processing, windows | <h1>Difference between xcopy and robocopy</h1>
<p>I'm kind of new to batch scripting.
As a newbie I find both both of them useful while scripting
What are the key differences between xcopy and robocopy?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,063 | cmd | # Difference between xcopy and robocopy
I'm kind of new to batch scripting.
As a newbie I find both both of them useful while scripting
What are the key differences between xcopy and robocopy? | Robocopy replaces XCopy in the newer versions of windows
1. Uses Mirroring, XCopy does not
2. Has a /RH option to allow a set time for the copy to run
3. Has a /MON:n option to check differences in files
4. Copies over more file attributes than XCopy
Yes i agree with Mark Setchell, They are both crap. (brought to you... |
14626178 | How to close the command line window after running a batch file? | 75 | 2013-01-31 12:47:42 | <p>I've got a batch file. After it finished running, i.e. all command lines have been executed, the <em>cmd.exe</em> window stays open. However, I'd like to have it closed right after the batch file finishes its job. </p>
<p>So far I've tried using the <code>exit</code> command within the batch file to close the cmd w... | 377,469 | 1,987,459 | 2023-06-11 18:46:48 | 14,626,301 | 90 | 2013-01-31 12:53:47 | 799,586 | 2013-01-31 12:53:47 | https://stackoverflow.com/q/14626178 | https://stackoverflow.com/a/14626301 | <p>It should close automatically, if it doesn't it means that it is stuck on the first command.</p>
<p>In your example it should close either automatically (without the <code>exit</code>) or explicitly with the <code>exit</code>. I think the issue is with the first command you are running not returning properly.</p>
... | <p>It should close automatically, if it doesn't it means that it is stuck on the first command.</p> <p>In your example it should close either automatically (without the <code>exit</code>) or explicitly with the <code>exit</code>. I think the issue is with the first command you are running not returning properly.</p> ... | 7002, 30645, 34595 | batch-file, batch-processing, windows-7 | <h1>How to close the command line window after running a batch file?</h1>
<p>I've got a batch file. After it finished running, i.e. all command lines have been executed, the <em>cmd.exe</em> window stays open. However, I'd like to have it closed right after the batch file finishes its job. </p>
<p>So far I've tried us... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,064 | cmd | # How to close the command line window after running a batch file?
I've got a batch file. After it finished running, i.e. all command lines have been executed, the *cmd.exe* window stays open. However, I'd like to have it closed right after the batch file finishes its job.
So far I've tried using the `exit` command w... | It should close automatically, if it doesn't it means that it is stuck on the first command.
In your example it should close either automatically (without the `exit`) or explicitly with the `exit`. I think the issue is with the first command you are running not returning properly.
As a work around you can try using
... |
1427796 | Batch file encoding | 65 | 2009-09-15 15:11:53 | <p>I would like to deal with filename containing strange characters, like the French é.</p>
<p>Everything is working fine in the shell:</p>
<pre><code>C:\somedir\>ren -hélice hélice
</code></pre>
<p>I know if I put this line in a .bat file, I obtain the following result:</p>
<pre><code>C:\somedir\>ren -hÚlice... | 124,203 | 11,589 | 2022-05-11 06:54:21 | 1,427,817 | 90 | 2009-09-15 15:15:23 | 73,070 | 2009-09-16 07:36:35 | https://stackoverflow.com/q/1427796 | https://stackoverflow.com/a/1427817 | <p>You have to save the batch file with OEM encoding. How to do this varies depending on your text editor. The encoding used in that case varies as well. For Western cultures it's usually CP850.</p>
<p>Batch files and encoding are really two things that don't particularly like each other. You'll notice that Unicode is... | <p>You have to save the batch file with OEM encoding. How to do this varies depending on your text editor. The encoding used in that case varies as well. For Western cultures it's usually CP850.</p> <p>Batch files and encoding are really two things that don't particularly like each other. You'll notice that Unicode is... | 64, 1124, 2631, 7002 | batch-file, cmd, encoding, windows | <h1>Batch file encoding</h1>
<p>I would like to deal with filename containing strange characters, like the French é.</p>
<p>Everything is working fine in the shell:</p>
<pre><code>C:\somedir\>ren -hélice hélice
</code></pre>
<p>I know if I put this line in a .bat file, I obtain the following result:</p>
<pre><co... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,065 | cmd | # Batch file encoding
I would like to deal with filename containing strange characters, like the French é.
Everything is working fine in the shell:
```
C:\somedir\>ren -hélice hélice
```
I know if I put this line in a .bat file, I obtain the following result:
```
C:\somedir\>ren -hÚlice hÚlice
```
See ? é have be... | You have to save the batch file with OEM encoding. How to do this varies depending on your text editor. The encoding used in that case varies as well. For Western cultures it's usually CP850.
Batch files and encoding are really two things that don't particularly like each other. You'll notice that Unicode is also impo... |
33276921 | Batch script to execute some commands in each sub-folder | 49 | 2015-10-22 08:50:05 | <p>I need to write a script to work in Windows, that when executed will run a command in some of sub-directories, but unfortunately I have never done anything in batch, and I don't know where to start.</p>
<p>With the example structure of folders:</p>
<pre><code>\root
\one
\two
\three
\four
</code></pre>
... | 98,382 | 4,490,442 | 2023-06-27 10:51:15 | 33,277,085 | 90 | 2015-10-22 08:57:04 | 1,354,537 | 2017-09-06 08:53:04 | https://stackoverflow.com/q/33276921 | https://stackoverflow.com/a/33277085 | <p>You can tell the batch to iterate directories:</p>
<pre><code>for /d %i in (C:\temp\*) do ( cd "%i" & *enter your command here* )
</code></pre>
<p>Use a percent sign when run directly on the command line, two when run from a batch</p>
<p>In a batch this would look something like this:</p>
<pre><code>@echo ... | <p>You can tell the batch to iterate directories:</p> <pre><code>for /d %i in (C:\temp\*) do ( cd "%i" & *enter your command here* ) </code></pre> <p>Use a percent sign when run directly on the command line, two when run from a batch</p> <p>In a batch this would look something like this:</p> <pre><code>@echo ... | 64, 7002 | batch-file, windows | <h1>Batch script to execute some commands in each sub-folder</h1>
<p>I need to write a script to work in Windows, that when executed will run a command in some of sub-directories, but unfortunately I have never done anything in batch, and I don't know where to start.</p>
<p>With the example structure of folders:</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,066 | cmd | # Batch script to execute some commands in each sub-folder
I need to write a script to work in Windows, that when executed will run a command in some of sub-directories, but unfortunately I have never done anything in batch, and I don't know where to start.
With the example structure of folders:
```
\root
\one
... | You can tell the batch to iterate directories:
```
for /d %i in (C:\temp\*) do ( cd "%i" & *enter your command here* )
```
Use a percent sign when run directly on the command line, two when run from a batch
In a batch this would look something like this:
```
@echo off
set back=%cd%
for /d %%i in (C:\temp\*) do (
c... |
2050505 | Way to run Excel macros from command line or batch file? | 84 | 2010-01-12 16:32:58 | <p>I have an Excel VBA macro which I need to run when accessing the file from a batch file, but not every time I open it (hence not using the open file event). Is there a way to run the macro from the command line or batch file? I'm not familiar with such a command.</p>
<p>Assume a Windows NT environment.</p>
| 342,628 | 134,948 | 2020-01-15 21:42:33 | 2,056,066 | 89 | 2010-01-13 10:56:47 | 5,050 | 2010-01-26 22:06:13 | https://stackoverflow.com/q/2050505 | https://stackoverflow.com/a/2056066 | <p>You can launch Excel, open the workbook and run the macro from a VBScript file.</p>
<p>Copy the code below into Notepad.</p>
<p>Update the '<em>MyWorkbook.xls</em>' and '<em>MyMacro</em>' parameters.</p>
<p>Save it with a vbs extension and run it.</p>
<pre><code>Option Explicit
On Error Resume Next
ExcelMacroE... | <p>You can launch Excel, open the workbook and run the macro from a VBScript file.</p> <p>Copy the code below into Notepad.</p> <p>Update the '<em>MyWorkbook.xls</em>' and '<em>MyMacro</em>' parameters.</p> <p>Save it with a vbs extension and run it.</p> <pre><code>Option Explicit On Error Resume Next ExcelMacroE... | 522, 1231, 1449, 7002 | batch-file, command-line, excel, vba | <h1>Way to run Excel macros from command line or batch file?</h1>
<p>I have an Excel VBA macro which I need to run when accessing the file from a batch file, but not every time I open it (hence not using the open file event). Is there a way to run the macro from the command line or batch file? I'm not familiar with suc... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,068 | cmd | # Way to run Excel macros from command line or batch file?
I have an Excel VBA macro which I need to run when accessing the file from a batch file, but not every time I open it (hence not using the open file event). Is there a way to run the macro from the command line or batch file? I'm not familiar with such a comma... | You can launch Excel, open the workbook and run the macro from a VBScript file.
Copy the code below into Notepad.
Update the '*MyWorkbook.xls*' and '*MyMacro*' parameters.
Save it with a vbs extension and run it.
```
Option Explicit
On Error Resume Next
ExcelMacroExample
Sub ExcelMacroExample()
Dim xlApp
... |
1672580 | Get number of pages in a pdf using a cmd batch file | 67 | 2009-11-04 09:16:31 | <p>I can see there are a lot of questions for getting the number of pages in a a pdf with C, PHP and others but am wondering with a batch file or cmd is there a simple way of getting the number of pages?</p>
| 67,878 | 77,466 | 2024-12-19 23:34:42 | 1,672,607 | 89 | 2009-11-04 09:22:08 | 136,725 | 2018-11-05 20:30:27 | https://stackoverflow.com/q/1672580 | https://stackoverflow.com/a/1672607 | <p>Using <a href="http://www.accesspdf.com/pdftk/" rel="noreferrer">pdftk</a>:</p>
<p><code>pdftk my.pdf dump_data | grep NumberOfPages</code></p>
<p>does the trick.</p>
| <p>Using <a href="http://www.accesspdf.com/pdftk/" rel="noreferrer">pdftk</a>:</p> <p><code>pdftk my.pdf dump_data | grep NumberOfPages</code></p> <p>does the trick.</p> | 90, 2631, 7002 | batch-file, cmd, pdf | <h1>Get number of pages in a pdf using a cmd batch file</h1>
<p>I can see there are a lot of questions for getting the number of pages in a a pdf with C, PHP and others but am wondering with a batch file or cmd is there a simple way of getting the number of pages?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,069 | cmd | # Get number of pages in a pdf using a cmd batch file
I can see there are a lot of questions for getting the number of pages in a a pdf with C, PHP and others but am wondering with a batch file or cmd is there a simple way of getting the number of pages? | Using [pdftk](http://www.accesspdf.com/pdftk/):
`pdftk my.pdf dump_data | grep NumberOfPages`
does the trick. |
8688846 | Resize command prompt through commands | 57 | 2011-12-31 15:10:25 | <p>I want to resize the command prompt window in a batch file, is it possible to set a height and width through something I can just add in the batch file?</p>
| 220,614 | 1,009,123 | 2020-04-13 14:26:52 | 8,688,866 | 89 | 2011-12-31 15:14:53 | 1,055,398 | 2011-12-31 15:14:53 | https://stackoverflow.com/q/8688846 | https://stackoverflow.com/a/8688866 | <p><a href="https://stackoverflow.com/questions/945527/modify-cmd-exe-properties-using-the-command-prompt">Modify cmd.exe properties using the command prompt</a> Pretty much has what you're asking for. More on the topic, <code>mode con: cols=160 lines=78</code> should achieve what you want.
Change 160 and 78 to your va... | <p><a href="https://stackoverflow.com/questions/945527/modify-cmd-exe-properties-using-the-command-prompt">Modify cmd.exe properties using the command prompt</a> Pretty much has what you're asking for. More on the topic, <code>mode con: cols=160 lines=78</code> should achieve what you want. Change 160 and 78 to your va... | 7002 | batch-file | <h1>Resize command prompt through commands</h1>
<p>I want to resize the command prompt window in a batch file, is it possible to set a height and width through something I can just add in the batch file?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,070 | cmd | # Resize command prompt through commands
I want to resize the command prompt window in a batch file, is it possible to set a height and width through something I can just add in the batch file? | [Modify cmd.exe properties using the command prompt](https://stackoverflow.com/questions/945527/modify-cmd-exe-properties-using-the-command-prompt) Pretty much has what you're asking for. More on the topic, `mode con: cols=160 lines=78` should achieve what you want.
Change 160 and 78 to your values. |
46305569 | How to make batch files run in anaconda prompt | 85 | 2017-09-19 16:33:08 | <p>After installing anaconda3 in windows, I can run python commands from the anaconda prompt, but not from the windows command prompt.
I would like to make a desktop shortcut to activate my environment and run spyder from it. Previously, I would do this with a <code>.bat</code> file, but now that I cannot run python co... | 137,223 | 8,020,201 | 2023-12-13 02:37:14 | 46,306,420 | 88 | 2017-09-19 17:23:37 | 5,322,574 | 2019-07-25 07:45:36 | https://stackoverflow.com/q/46305569 | https://stackoverflow.com/a/46306420 | <p>I believe all the Anaconda prompt does is open CMD and run a batch file. Make the first command of your script:</p>
<pre><code>call <anaconda_dir>/Scripts/activate.bat <anaconda_dir>
</code></pre>
| <p>I believe all the Anaconda prompt does is open CMD and run a batch file. Make the first command of your script:</p> <pre><code>call <anaconda_dir>/Scripts/activate.bat <anaconda_dir> </code></pre> | 64, 2631, 7002, 92746 | anaconda, batch-file, cmd, windows | <h1>How to make batch files run in anaconda prompt</h1>
<p>After installing anaconda3 in windows, I can run python commands from the anaconda prompt, but not from the windows command prompt.
I would like to make a desktop shortcut to activate my environment and run spyder from it. Previously, I would do this with a <co... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,071 | cmd | # How to make batch files run in anaconda prompt
After installing anaconda3 in windows, I can run python commands from the anaconda prompt, but not from the windows command prompt.
I would like to make a desktop shortcut to activate my environment and run spyder from it. Previously, I would do this with a `.bat` file,... | I believe all the Anaconda prompt does is open CMD and run a batch file. Make the first command of your script:
```
call <anaconda_dir>/Scripts/activate.bat <anaconda_dir>
``` |
16255184 | How do I find the current directory of a batch file, and then use it for the path? | 74 | 2013-04-27 17:50:50 | <p>I have a batch file that I intend to distribute to our customers to run a software task. </p>
<p>We distribute them as a folder or <code>.zip</code> with the files inside. Inside, there is the batch files and another folder with the files needed to run the batch.</p>
<p>Normally, when you make a batch, you type th... | 183,045 | 2,327,428 | 2017-10-15 09:39:49 | 16,255,921 | 88 | 2013-04-27 19:15:15 | 1,248,295 | 2015-05-16 21:12:21 | https://stackoverflow.com/q/16255184 | https://stackoverflow.com/a/16255921 | <p>There is no need to know where the files are, because when you launch a bat file the working directory is the directory where it was launched (the "master folder"), so if you have this structure:</p>
<pre><code>.\mydocuments\folder\mybat.bat
.\mydocuments\folder\subfolder\file.txt
</code></pre>
<p>And the user sta... | <p>There is no need to know where the files are, because when you launch a bat file the working directory is the directory where it was launched (the "master folder"), so if you have this structure:</p> <pre><code>.\mydocuments\folder\mybat.bat .\mydocuments\folder\subfolder\file.txt </code></pre> <p>And the user sta... | 218, 3718, 5310, 7002, 10193 | batch-file, cd, directory, file, find | <h1>How do I find the current directory of a batch file, and then use it for the path?</h1>
<p>I have a batch file that I intend to distribute to our customers to run a software task. </p>
<p>We distribute them as a folder or <code>.zip</code> with the files inside. Inside, there is the batch files and another folder ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,072 | cmd | # How do I find the current directory of a batch file, and then use it for the path?
I have a batch file that I intend to distribute to our customers to run a software task.
We distribute them as a folder or `.zip` with the files inside. Inside, there is the batch files and another folder with the files needed to run... | There is no need to know where the files are, because when you launch a bat file the working directory is the directory where it was launched (the "master folder"), so if you have this structure:
```
.\mydocuments\folder\mybat.bat
.\mydocuments\folder\subfolder\file.txt
```
And the user starts the "mybat.bat", the wo... |
1100452 | Get filename in batch for loop | 47 | 2009-07-08 20:42:00 | <p>I have the following For loop in a batch file:</p>
<pre><code>for /R c:\test\src %%i IN (*.*) DO (
MOVE %%i C:\test\destination
ECHO %%i
exit
)
</code></pre>
<p>The result of the ECHO outputs the entire file path Ex: <strong>C:\Foldername\Filename</strong>
I need to ECHO out only the <strong>Filename</strong>.Is t... | 205,071 | 24,958 | 2024-01-19 23:47:24 | 1,100,466 | 88 | 2009-07-08 20:46:22 | 51,685 | 2015-03-23 23:31:42 | https://stackoverflow.com/q/1100452 | https://stackoverflow.com/a/1100466 | <p>When Command Extensions are enabled (Windows XP and newer, roughly), you can use the syntax %~nF (where F is the variable and ~n is the request for its name) to only get the filename.</p>
<pre><code>FOR /R C:\Directory %F in (*.*) do echo %~nF
</code></pre>
<p>should echo only the filenames.</p>
| <p>When Command Extensions are enabled (Windows XP and newer, roughly), you can use the syntax %~nF (where F is the variable and ~n is the request for its name) to only get the filename.</p> <pre><code>FOR /R C:\Directory %F in (*.*) do echo %~nF </code></pre> <p>should echo only the filenames.</p> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Get filename in batch for loop</h1>
<p>I have the following For loop in a batch file:</p>
<pre><code>for /R c:\test\src %%i IN (*.*) DO (
MOVE %%i C:\test\destination
ECHO %%i
exit
)
</code></pre>
<p>The result of the ECHO outputs the entire file path Ex: <strong>C:\Foldername\Filename</strong>
I need to ECHO out... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,073 | cmd | # Get filename in batch for loop
I have the following For loop in a batch file:
```
for /R c:\test\src %%i IN (*.*) DO (
MOVE %%i C:\test\destination
ECHO %%i
exit
)
```
The result of the ECHO outputs the entire file path Ex: **C:\Foldername\Filename**
I need to ECHO out only the **Filename**.Is there a specific com... | When Command Extensions are enabled (Windows XP and newer, roughly), you can use the syntax %~nF (where F is the variable and ~n is the request for its name) to only get the filename.
```
FOR /R C:\Directory %F in (*.*) do echo %~nF
```
should echo only the filenames. |
7727114 | Batch command date and time in file name | 82 | 2011-10-11 13:49:01 | <p>I am compressing files using <a href="https://en.wikipedia.org/wiki/WinZip" rel="noreferrer">WinZip</a> on the command line. Since we archive on a daily basis, I am trying to add date and time to these files so that a new one is auto generated every time.</p>
<p>I use the following to generate a file name. Copy pas... | 324,599 | 109,035 | 2021-04-13 21:23:20 | 18,024,049 | 87 | 2013-08-02 18:46:41 | 2,152,082 | 2019-12-24 19:02:24 | https://stackoverflow.com/q/7727114 | https://stackoverflow.com/a/18024049 | <p>Another solution:</p>
<pre><code>for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
</code></pre>
<p>It will give you (independent of locale settings!):</p>
<pre><code> 20130802203023.304000+120
( YYYYMMDDhhmmss.<milliseconds><always 000>+/-<minutes di... | <p>Another solution:</p> <pre><code>for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I </code></pre> <p>It will give you (independent of locale settings!):</p> <pre><code> 20130802203023.304000+120 ( YYYYMMDDhhmmss.<milliseconds><always 000>+/-<minutes di... | 64, 1231, 2631, 7002 | batch-file, cmd, command-line, windows | <h1>Batch command date and time in file name</h1>
<p>I am compressing files using <a href="https://en.wikipedia.org/wiki/WinZip" rel="noreferrer">WinZip</a> on the command line. Since we archive on a daily basis, I am trying to add date and time to these files so that a new one is auto generated every time.</p>
<p>I u... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,074 | cmd | # Batch command date and time in file name
I am compressing files using [WinZip](https://en.wikipedia.org/wiki/WinZip) on the command line. Since we archive on a daily basis, I am trying to add date and time to these files so that a new one is auto generated every time.
I use the following to generate a file name. Co... | Another solution:
```
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
```
It will give you (independent of locale settings!):
```
20130802203023.304000+120
( YYYYMMDDhhmmss.<milliseconds><always 000>+/-<minutes difference to UTC> )
```
From here, it is easy:
```
... |
5401229 | How do I execute several git commands in a batch file without terminating after the first command? | 71 | 2011-03-23 05:32:32 | <p>I tried to put a series of GIT commands that I always use continuously togeter as batch files so that I don't repeat myself too much. For example, I have this batch file called <code>update_repo_branch.bat</code> to update a local repo and synch a branch with the remote branch: </p>
<blockquote>
<p>@echo off<br>... | 86,489 | 672,441 | 2022-10-14 09:23:33 | 5,401,466 | 87 | 2011-03-23 06:10:40 | 12,711 | 2011-03-23 06:37:17 | https://stackoverflow.com/q/5401229 | https://stackoverflow.com/a/5401466 | <p>I'm not sure if this is true for all Windows git packages, but at least some use a <code>git.cmd</code> script as a wrapper around the actual git executables (for example <code>git.exe</code>). So when you're batch file uses a <code>git</code> command, Windows is actually running another batch file.</p>
<p>Unfortun... | <p>I'm not sure if this is true for all Windows git packages, but at least some use a <code>git.cmd</code> script as a wrapper around the actual git executables (for example <code>git.exe</code>). So when you're batch file uses a <code>git</code> command, Windows is actually running another batch file.</p> <p>Unfortun... | 64, 119, 7002 | batch-file, git, windows | <h1>How do I execute several git commands in a batch file without terminating after the first command?</h1>
<p>I tried to put a series of GIT commands that I always use continuously togeter as batch files so that I don't repeat myself too much. For example, I have this batch file called <code>update_repo_branch.bat</co... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,075 | cmd | # How do I execute several git commands in a batch file without terminating after the first command?
I tried to put a series of GIT commands that I always use continuously togeter as batch files so that I don't repeat myself too much. For example, I have this batch file called `update_repo_branch.bat` to update a loca... | I'm not sure if this is true for all Windows git packages, but at least some use a `git.cmd` script as a wrapper around the actual git executables (for example `git.exe`). So when you're batch file uses a `git` command, Windows is actually running another batch file.
Unfortunately, when one batch file invokes another,... |
20329355 | How to make a batch file delete itself? | 52 | 2013-12-02 13:21:25 | <p>Is it possible to make a batch file delete itself?</p>
<p>I have tried to make it execute another file to delete it but this did not work.</p>
<p>Does any one know how I could do it?</p>
<p>The batch file I am using is elevated. My OS is Windows 7 32 bit.</p>
| 78,569 | 2,964,427 | 2022-04-11 15:12:44 | 20,333,575 | 87 | 2013-12-02 16:53:51 | 1,012,053 | 2019-09-16 13:25:17 | https://stackoverflow.com/q/20329355 | https://stackoverflow.com/a/20333575 | <p>npocmaka's answer works, but it generates the following error message: "<strong><em>The batch file cannot be found.</em></strong>" This isn't a problem if the console window closes when the script terminates, as the message will flash by so fast, no one will see it. But it is very undesirable if the console remains ... | <p>npocmaka's answer works, but it generates the following error message: "<strong><em>The batch file cannot be found.</em></strong>" This isn't a problem if the console window closes when the script terminates, as the message will flash by so fast, no one will see it. But it is very undesirable if the console remains ... | 64, 7002, 34595, 37510, 60888 | batch-file, delete-file, elevated-privileges, windows, windows-7 | <h1>How to make a batch file delete itself?</h1>
<p>Is it possible to make a batch file delete itself?</p>
<p>I have tried to make it execute another file to delete it but this did not work.</p>
<p>Does any one know how I could do it?</p>
<p>The batch file I am using is elevated. My OS is Windows 7 32 bit.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,076 | cmd | # How to make a batch file delete itself?
Is it possible to make a batch file delete itself?
I have tried to make it execute another file to delete it but this did not work.
Does any one know how I could do it?
The batch file I am using is elevated. My OS is Windows 7 32 bit. | npocmaka's answer works, but it generates the following error message: "***The batch file cannot be found.***" This isn't a problem if the console window closes when the script terminates, as the message will flash by so fast, no one will see it. But it is very undesirable if the console remains open after the script t... |
7347501 | How to write a full path in a batch file having a folder name with space? | 40 | 2011-09-08 11:44:19 | <p>I am writing following command in batch file</p>
<pre><code>REGSVR32 E:\Documents and Settings\All Users\Application Data\xyz.dll
</code></pre>
<p>After running this command I am getting following error</p>
<pre><code>LodLibrary(e:\Documents) failed specified module could not be found.
</code></pre>
<p>How can I... | 251,159 | 133,098 | 2019-01-18 10:58:15 | 7,347,518 | 87 | 2011-09-08 11:45:48 | 799,586 | 2011-09-08 11:48:10 | https://stackoverflow.com/q/7347501 | https://stackoverflow.com/a/7347518 | <p>Put double quotes around the path that has spaces like this:</p>
<p><code>REGSVR32 "E:\Documents and Settings\All Users\Application Data\xyz.dll"</code></p>
| <p>Put double quotes around the path that has spaces like this:</p> <p><code>REGSVR32 "E:\Documents and Settings\All Users\Application Data\xyz.dll"</code></p> | 7002 | batch-file | <h1>How to write a full path in a batch file having a folder name with space?</h1>
<p>I am writing following command in batch file</p>
<pre><code>REGSVR32 E:\Documents and Settings\All Users\Application Data\xyz.dll
</code></pre>
<p>After running this command I am getting following error</p>
<pre><code>LodLibrary(e:... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,077 | cmd | # How to write a full path in a batch file having a folder name with space?
I am writing following command in batch file
```
REGSVR32 E:\Documents and Settings\All Users\Application Data\xyz.dll
```
After running this command I am getting following error
```
LodLibrary(e:\Documents) failed specified module could no... | Put double quotes around the path that has spaces like this:
`REGSVR32 "E:\Documents and Settings\All Users\Application Data\xyz.dll"` |
5139157 | Append text with .bat | 37 | 2011-02-28 07:17:09 | <p>I want to create a log of every operation processed in a batch file and used the following but to no avail. How do I fix it (the file was not created)?</p>
<pre><code>REM>> C:\"VTS\ADVANCED TOOLS\SYSTEM\LOG\Advanced tools %date%.log"
</code></pre>
| 157,703 | 626,148 | 2016-03-15 12:41:52 | 5,143,293 | 87 | 2011-02-28 14:32:43 | 2,441 | 2016-03-15 12:41:52 | https://stackoverflow.com/q/5139157 | https://stackoverflow.com/a/5143293 | <p>You need to use <code>ECHO</code>. Also, put the quotes around the entire file path if it contains spaces.</p>
<p>One other note, use <code>></code> to overwrite a file if it exists or create if it does not exist. Use <code>>></code> to append to an existing file or create if it does not exist.</p>
<p>Ove... | <p>You need to use <code>ECHO</code>. Also, put the quotes around the entire file path if it contains spaces.</p> <p>One other note, use <code>></code> to overwrite a file if it exists or create if it does not exist. Use <code>>></code> to append to an existing file or create if it does not exist.</p> <p>Ove... | 942, 7002 | batch-file, logging | <h1>Append text with .bat</h1>
<p>I want to create a log of every operation processed in a batch file and used the following but to no avail. How do I fix it (the file was not created)?</p>
<pre><code>REM>> C:\"VTS\ADVANCED TOOLS\SYSTEM\LOG\Advanced tools %date%.log"
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,078 | cmd | # Append text with .bat
I want to create a log of every operation processed in a batch file and used the following but to no avail. How do I fix it (the file was not created)?
```
REM>> C:\"VTS\ADVANCED TOOLS\SYSTEM\LOG\Advanced tools %date%.log"
``` | You need to use `ECHO`. Also, put the quotes around the entire file path if it contains spaces.
One other note, use `>` to overwrite a file if it exists or create if it does not exist. Use `>>` to append to an existing file or create if it does not exist.
Overwrite the file with a blank line:
```
ECHO.>"C:\My folder... |
34959038 | NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native) | 278 | 2016-01-23 02:43:37 | <p>I am stuck with this error no matter what directory I am in, and what I type after "npm" in cmd.exe. Here is the npm-debug.log: </p>
<pre><code>0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js' ]... | 544,067 | 1,251,069 | 2024-07-30 14:42:31 | 35,429,397 | 86 | 2016-02-16 10:04:37 | 1,460,043 | 2016-02-16 10:04:37 | https://stackoverflow.com/q/34959038 | https://stackoverflow.com/a/35429397 | <p>I ran into the same problem while I was changing some npm settings. I did a mistake with one <code>npm config set</code> command and this added a line referring to a non-existing directory to <code>C:\Users\{User}\.npmrc</code>. After I deleted that line manually from <code>.npmrc</code>, the problem was gone.</p>
| <p>I ran into the same problem while I was changing some npm settings. I did a mistake with one <code>npm config set</code> command and this added a line referring to a non-existing directory to <code>C:\Users\{User}\.npmrc</code>. After I deleted that line manually from <code>.npmrc</code>, the problem was gone.</p> | 64, 2120, 2631, 46426, 61387 | cmd, file-permissions, node.js, npm, windows | <h1>NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native)</h1>
<p>I am stuck with this error no matter what directory I am in, and what I type after "npm" in cmd.exe. Here is the npm-debug.log: </p>
<pre><code>0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program F... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,079 | cmd | # NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native)
I am stuck with this error no matter what directory I am in, and what I type after "npm" in cmd.exe. Here is the npm-debug.log:
```
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.ex... | I ran into the same problem while I was changing some npm settings. I did a mistake with one `npm config set` command and this added a line referring to a non-existing directory to `C:\Users\{User}\.npmrc`. After I deleted that line manually from `.npmrc`, the problem was gone. |
165938 | How can I debug a .BAT script? | 123 | 2008-10-03 06:46:53 | <p>Is there a way to step through a .bat script? The thing is, I have a build script , which calls a lot of other scripts, and I would like to see what is the order in which they are called, so that I may know where exactly I have to go about and add my modifications.</p>
| 229,602 | 11,234 | 2024-12-04 17:26:01 | 165,942 | 86 | 2008-10-03 06:50:13 | 3,957 | 2008-10-03 06:55:22 | https://stackoverflow.com/q/165938 | https://stackoverflow.com/a/165942 | <p>I don't know of anyway to step through the execution of a .bat file but you can use <code>echo</code> and <code>pause</code> to help with debugging.</p>
<blockquote>
<p><strong>ECHO</strong><br>
Will echo a message in the batch file. Such as ECHO Hello World will print Hello World on the screen when executed. H... | <p>I don't know of anyway to step through the execution of a .bat file but you can use <code>echo</code> and <code>pause</code> to help with debugging.</p> <blockquote> <p><strong>ECHO</strong><br> Will echo a message in the batch file. Such as ECHO Hello World will print Hello World on the screen when executed. H... | 64, 277, 2631, 5370, 7002 | batch-file, cmd, debugging, dos, windows | <h1>How can I debug a .BAT script?</h1>
<p>Is there a way to step through a .bat script? The thing is, I have a build script , which calls a lot of other scripts, and I would like to see what is the order in which they are called, so that I may know where exactly I have to go about and add my modifications.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,080 | cmd | # How can I debug a .BAT script?
Is there a way to step through a .bat script? The thing is, I have a build script , which calls a lot of other scripts, and I would like to see what is the order in which they are called, so that I may know where exactly I have to go about and add my modifications. | I don't know of anyway to step through the execution of a .bat file but you can use `echo` and `pause` to help with debugging.
> **ECHO**
> Will echo a message in the batch file. Such as ECHO Hello World will print Hello World on the screen when executed. However, without @ECHO OFF at the beginning of the batch file... |
6078009 | How to get access to job parameters from ItemReader, in Spring Batch? | 85 | 2011-05-20 22:03:22 | <p>This is part of my <code>job.xml</code>:</p>
<pre><code><job id="foo" job-repository="job-repository">
<step id="bar">
<tasklet transaction-manager="transaction-manager">
<chunk commit-interval="1"
reader="foo-reader" writer="foo-writer"
/>
</tasklet>
&l... | 189,420 | 187,141 | 2025-10-30 11:05:52 | 7,218,848 | 86 | 2011-08-28 03:21:06 | 517,254 | 2011-08-28 03:21:06 | https://stackoverflow.com/q/6078009 | https://stackoverflow.com/a/7218848 | <p>As was stated, your reader needs to be 'step' scoped. You can accomplish this via the <code>@Scope("step")</code> annotation. It should work for you if you add that annotation to your reader, like the following:</p>
<pre><code>import org.springframework.batch.item.ItemReader;
import org.springframework.beans.factor... | <p>As was stated, your reader needs to be 'step' scoped. You can accomplish this via the <code>@Scope("step")</code> annotation. It should work for you if you add that annotation to your reader, like the following:</p> <pre><code>import org.springframework.batch.item.ItemReader; import org.springframework.beans.factor... | 17, 1211, 41895 | java, spring, spring-batch | <h1>How to get access to job parameters from ItemReader, in Spring Batch?</h1>
<p>This is part of my <code>job.xml</code>:</p>
<pre><code><job id="foo" job-repository="job-repository">
<step id="bar">
<tasklet transaction-manager="transaction-manager">
<chunk commit-interval="1"
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,081 | cmd | # How to get access to job parameters from ItemReader, in Spring Batch?
This is part of my `job.xml`:
```
<job id="foo" job-repository="job-repository">
<step id="bar">
<tasklet transaction-manager="transaction-manager">
<chunk commit-interval="1"
reader="foo-reader" writer="foo-writer"
/>
... | As was stated, your reader needs to be 'step' scoped. You can accomplish this via the `@Scope("step")` annotation. It should work for you if you add that annotation to your reader, like the following:
```
import org.springframework.batch.item.ItemReader;
import org.springframework.beans.factory.annotation.Value;
impor... |
13809856 | Run reg command in cmd (bat file)? | 67 | 2012-12-10 21:49:22 | <p>I'm trying to run this reg code in cmd (bat file), but I couldn't make it work. Where am I doing wrong?</p>
<pre><code>[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"HomePage"=dword:00000001
</code></pre>
<p>It works if I make it a reg file and double click.</p>
<p>Bat file code ... | 375,541 | 198,989 | 2017-04-18 12:38:55 | 13,811,568 | 86 | 2012-12-11 00:13:41 | 511,529 | 2017-04-18 12:38:55 | https://stackoverflow.com/q/13809856 | https://stackoverflow.com/a/13811568 | <p>You will probably get an UAC prompt when importing the reg file. If you accept that, you have more rights.</p>
<p>Since you are writing to the 'policies' key, you need to have elevated rights. This part of the registry protected, because it contains settings that are administered by your system administrator.</p>
... | <p>You will probably get an UAC prompt when importing the reg file. If you accept that, you have more rights.</p> <p>Since you are writing to the 'policies' key, you need to have elevated rights. This part of the registry protected, because it contains settings that are administered by your system administrator.</p> ... | 64, 263, 2631, 7002 | batch-file, cmd, registry, windows | <h1>Run reg command in cmd (bat file)?</h1>
<p>I'm trying to run this reg code in cmd (bat file), but I couldn't make it work. Where am I doing wrong?</p>
<pre><code>[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"HomePage"=dword:00000001
</code></pre>
<p>It works if I make it a reg f... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,082 | cmd | # Run reg command in cmd (bat file)?
I'm trying to run this reg code in cmd (bat file), but I couldn't make it work. Where am I doing wrong?
```
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"HomePage"=dword:00000001
```
It works if I make it a reg file and double click.
Bat file c... | You will probably get an UAC prompt when importing the reg file. If you accept that, you have more rights.
Since you are writing to the 'policies' key, you need to have elevated rights. This part of the registry protected, because it contains settings that are administered by your system administrator.
Alternatively,... |
5471556 | 'Pretty print' windows %PATH% variable - how to split on ';' in CMD shell | 64 | 2011-03-29 11:09:26 | <p>I want to run a simple one-liner in the Windows CMD prompt to print my <code>%PATH%</code> variable, one entry per line.</p>
<p>I tried this: <code>for /f "delims=;" %a in ("%path%") do echo %a</code> but this only prints the first entry:</p>
<pre><code>Z:\>for /f "delims=;" %a in ("%path%") do echo %a
Z:\>... | 34,388 | 335,362 | 2025-06-10 10:00:43 | 5,472,168 | 86 | 2011-03-29 12:03:24 | 463,115 | 2018-07-04 17:50:30 | https://stackoverflow.com/q/5471556 | https://stackoverflow.com/a/5472168 | <p>The simple way is to use</p>
<pre><code>for %a in ("%path:;=";"%") do @echo %~a
</code></pre>
<p>This works for all without <code>;</code> in the path and without <code>"</code> around a single element<br>
Tested with path=C:\qt\4.6.3\bin;C:\Program Files;C:\documents & Settings</p>
<p>But a "always" solution... | <p>The simple way is to use</p> <pre><code>for %a in ("%path:;=";"%") do @echo %~a </code></pre> <p>This works for all without <code>;</code> in the path and without <code>"</code> around a single element<br> Tested with path=C:\qt\4.6.3\bin;C:\Program Files;C:\documents & Settings</p> <p>But a "always" solution... | 64, 2631, 6268, 7002 | batch-file, cmd, path, windows | <h1>'Pretty print' windows %PATH% variable - how to split on ';' in CMD shell</h1>
<p>I want to run a simple one-liner in the Windows CMD prompt to print my <code>%PATH%</code> variable, one entry per line.</p>
<p>I tried this: <code>for /f "delims=;" %a in ("%path%") do echo %a</code> but this only prints the first e... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,083 | cmd | # 'Pretty print' windows %PATH% variable - how to split on ';' in CMD shell
I want to run a simple one-liner in the Windows CMD prompt to print my `%PATH%` variable, one entry per line.
I tried this: `for /f "delims=;" %a in ("%path%") do echo %a` but this only prints the first entry:
```
Z:\>for /f "delims=;" %a in... | The simple way is to use
```
for %a in ("%path:;=";"%") do @echo %~a
```
This works for all without `;` in the path and without `"` around a single element
Tested with path=C:\qt\4.6.3\bin;C:\Program Files;C:\documents & Settings
But a "always" solution is a bit complicated
**EDIT: Now a working variant**
```
@... |
57735695 | How to submit Plink "Access granted. Press Return to begin session" prompt automatically | 42 | 2019-08-31 06:23:07 | <p>I'm writing a simple Windows batch script to allow me to execute some Linux command on my remote server with the help of <code>plink.exe</code>.</p>
<pre><code>call set argument1=plink -pw mypwsswd username@172.19.48.111 cd ~/project; make clean; make -j8
call plink %%argument1%%
</code></pre>
<p>In a word, it wil... | 56,368 | 3,305,546 | 2020-06-01 07:46:21 | 57,736,579 | 86 | 2019-08-31 08:58:07 | 850,848 | 2020-06-01 07:46:21 | https://stackoverflow.com/q/57735695 | https://stackoverflow.com/a/57736579 | <p>Since PuTTY 0.71 you get that prompt for security purposes, when you login in an interactive mode. See <a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/vuln-auth-prompt-spoofing.html" rel="noreferrer">PuTTY vulnerability vuln-auth-prompt-spoofing</a>.</p>
<p>To use a batch mode, use <a href="htt... | <p>Since PuTTY 0.71 you get that prompt for security purposes, when you login in an interactive mode. See <a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/vuln-auth-prompt-spoofing.html" rel="noreferrer">PuTTY vulnerability vuln-auth-prompt-spoofing</a>.</p> <p>To use a batch mode, use <a href="htt... | 64, 386, 1768, 2306, 7002 | batch-file, plink, putty, ssh, windows | <h1>How to submit Plink "Access granted. Press Return to begin session" prompt automatically</h1>
<p>I'm writing a simple Windows batch script to allow me to execute some Linux command on my remote server with the help of <code>plink.exe</code>.</p>
<pre><code>call set argument1=plink -pw mypwsswd username@172.19.48.1... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,084 | cmd | # How to submit Plink "Access granted. Press Return to begin session" prompt automatically
I'm writing a simple Windows batch script to allow me to execute some Linux command on my remote server with the help of `plink.exe`.
```
call set argument1=plink -pw mypwsswd username@172.19.48.111 cd ~/project; make clean; ma... | Since PuTTY 0.71 you get that prompt for security purposes, when you login in an interactive mode. See [PuTTY vulnerability vuln-auth-prompt-spoofing](https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/vuln-auth-prompt-spoofing.html).
To use a batch mode, use [`-batch` switch](https://the.earth.li/~sgtatham/p... |
4248220 | How can I retrieve the seconds part of TIME in cmd? | 51 | 2010-11-22 17:23:31 | <p>I'm trying to write a cmd script that gets the current date and time and formats it into a way that sqlserver can input it as a <code>datetime</code>.</p>
<p>So far, I have:</p>
<pre><code>@echo off
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set dow=%%i
set mon=%%j
set day=%%k
set yr=%%l
set mydate=%%j/... | 102,136 | 266,261 | 2023-02-24 23:39:03 | 4,248,527 | 85 | 2010-11-22 17:54:17 | 73,070 | 2010-11-22 17:54:17 | https://stackoverflow.com/q/4248220 | https://stackoverflow.com/a/4248527 | <p>Use the <code>%TIME%</code> pseudo-variable.</p>
<p>You can also use <code>%DATE%</code> in above script.</p>
<p>Both have the same limitations, in that they depend on your locale. The code is not portable and you'll be up for surprises in other environments. But that's how date and time in cmd works.</p>
| <p>Use the <code>%TIME%</code> pseudo-variable.</p> <p>You can also use <code>%DATE%</code> in above script.</p> <p>Both have the same limitations, in that they depend on your locale. The code is not portable and you'll be up for surprises in other environments. But that's how date and time in cmd works.</p> | 2631, 7002 | batch-file, cmd | <h1>How can I retrieve the seconds part of TIME in cmd?</h1>
<p>I'm trying to write a cmd script that gets the current date and time and formats it into a way that sqlserver can input it as a <code>datetime</code>.</p>
<p>So far, I have:</p>
<pre><code>@echo off
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,085 | cmd | # How can I retrieve the seconds part of TIME in cmd?
I'm trying to write a cmd script that gets the current date and time and formats it into a way that sqlserver can input it as a `datetime`.
So far, I have:
```
@echo off
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set dow=%%i
set mon=%%j
set day=%%k
set... | Use the `%TIME%` pseudo-variable.
You can also use `%DATE%` in above script.
Both have the same limitations, in that they depend on your locale. The code is not portable and you'll be up for surprises in other environments. But that's how date and time in cmd works. |
6811372 | How to code a BAT file to always run as admin mode? | 201 | 2011-07-25 02:51:29 | <p>I have this line inside my BAT file:</p>
<pre><code>"Example1Server.exe"
</code></pre>
<p>I would like to execute this in Administrator mode. How to modify the bat code to run this as admin?</p>
<p>Is this correct? Do I need to put the quotes?</p>
<pre><code>runas /user:Administrator invis.vbs Example1Server.exe... | 986,443 | 192,173 | 2023-12-29 12:03:08 | 6,811,394 | 84 | 2011-07-25 02:54:49 | 596,781 | 2011-07-25 02:54:49 | https://stackoverflow.com/q/6811372 | https://stackoverflow.com/a/6811394 | <p>You use <code>runas</code> to launch a program as a specific user:</p>
<pre><code>runas /user:Administrator Example1Server.exe
</code></pre>
| <p>You use <code>runas</code> to launch a program as a specific user:</p> <pre><code>runas /user:Administrator Example1Server.exe </code></pre> | 64, 7002 | batch-file, windows | <h1>How to code a BAT file to always run as admin mode?</h1>
<p>I have this line inside my BAT file:</p>
<pre><code>"Example1Server.exe"
</code></pre>
<p>I would like to execute this in Administrator mode. How to modify the bat code to run this as admin?</p>
<p>Is this correct? Do I need to put the quotes?</p>
<pre... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,086 | cmd | # How to code a BAT file to always run as admin mode?
I have this line inside my BAT file:
```
"Example1Server.exe"
```
I would like to execute this in Administrator mode. How to modify the bat code to run this as admin?
Is this correct? Do I need to put the quotes?
```
runas /user:Administrator invis.vbs Example1... | You use `runas` to launch a program as a specific user:
```
runas /user:Administrator Example1Server.exe
``` |
6737064 | Execute SQL script from command line | 83 | 2011-07-18 17:49:27 | <p>I need to alter a database using a batch file, for a simple example, drop a table. I´m using local SQL Express (SQL Server 2008 R2) with user <code>sa</code> and its password.</p>
<p>How would the bat file be? </p>
<p>How can I specify in the script the password and that I use in SQL Express? </p>
| 256,199 | 850,311 | 2025-03-03 15:13:33 | 6,737,097 | 84 | 2011-07-18 17:52:11 | 342,113 | 2011-07-18 17:52:11 | https://stackoverflow.com/q/6737064 | https://stackoverflow.com/a/6737097 | <p>Take a look at the <code>sqlcmd</code> utility. It allows you to execute SQL from the command line.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms162773.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms162773.aspx</a></p>
<p>It's all in there in the documentation, but the syntax should ... | <p>Take a look at the <code>sqlcmd</code> utility. It allows you to execute SQL from the command line.</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms162773.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms162773.aspx</a></p> <p>It's all in there in the documentation, but the syntax should ... | 22, 72, 531, 1231, 7002 | batch-file, command-line, scripting, sql, sql-server | <h1>Execute SQL script from command line</h1>
<p>I need to alter a database using a batch file, for a simple example, drop a table. I´m using local SQL Express (SQL Server 2008 R2) with user <code>sa</code> and its password.</p>
<p>How would the bat file be? </p>
<p>How can I specify in the script the password and th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,087 | cmd | # Execute SQL script from command line
I need to alter a database using a batch file, for a simple example, drop a table. I´m using local SQL Express (SQL Server 2008 R2) with user `sa` and its password.
How would the bat file be?
How can I specify in the script the password and that I use in SQL Express? | Take a look at the `sqlcmd` utility. It allows you to execute SQL from the command line.
<http://msdn.microsoft.com/en-us/library/ms162773.aspx>
It's all in there in the documentation, but the syntax should look something like this:
```
sqlcmd -U myLogin -P myPassword -S MyServerName -d MyDatabaseName
-Q "DROP ... |
4571244 | Creating a BAT file for python script | 81 | 2010-12-31 16:51:46 | <p>How can I create a simple BAT file that will run my python script located at C:\somescript.py?</p>
| 449,116 | 316,824 | 2025-01-20 21:10:53 | 4,571,260 | 84 | 2010-12-31 16:55:06 | 68,105 | 2010-12-31 16:55:06 | https://stackoverflow.com/q/4571244 | https://stackoverflow.com/a/4571260 | <pre><code>c:\python27\python.exe c:\somescript.py %*
</code></pre>
| <pre><code>c:\python27\python.exe c:\somescript.py %* </code></pre> | 16, 7002 | batch-file, python | <h1>Creating a BAT file for python script</h1>
<p>How can I create a simple BAT file that will run my python script located at C:\somescript.py?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,088 | cmd | # Creating a BAT file for python script
How can I create a simple BAT file that will run my python script located at C:\somescript.py? | ```
c:\python27\python.exe c:\somescript.py %*
``` |
28889954 | What does "&&" do in this batch file? | 75 | 2015-03-05 23:41:12 | <p>I received a line of code from someone who answered one of my questions, but I am confused: what do the "&&" do in this batch file.</p>
<pre class="lang-bat prettyprint-override"><code>@echo off
set /p Quest="How are you today? "
echo %Quest% > Results.txt
findstr /r /i "not.*good not.*well" Results.txt ... | 155,430 | 4,573,473 | 2022-12-15 21:46:53 | 28,889,980 | 84 | 2015-03-05 23:44:16 | 4,158,862 | 2021-06-24 21:24:58 | https://stackoverflow.com/q/28889954 | https://stackoverflow.com/a/28889980 | <p><code>&&</code> runs the second command on the line when the first command comes back successfully (i.e. <code>errorlevel == 0</code>). The opposite of <code>&&</code> is <code>||</code>, which runs the second command when the first command is unsuccessful (i.e. <code>errorlevel != 0</code>).</p>
| <p><code>&&</code> runs the second command on the line when the first command comes back successfully (i.e. <code>errorlevel == 0</code>). The opposite of <code>&&</code> is <code>||</code>, which runs the second command when the first command is unsuccessful (i.e. <code>errorlevel != 0</code>).</p> | 367, 2631, 7002 | batch-file, cmd, syntax | <h1>What does "&&" do in this batch file?</h1>
<p>I received a line of code from someone who answered one of my questions, but I am confused: what do the "&&" do in this batch file.</p>
<pre class="lang-bat prettyprint-override"><code>@echo off
set /p Quest="How are you today? "
echo %Quest% > Results.txt
f... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,089 | cmd | # What does "&&" do in this batch file?
I received a line of code from someone who answered one of my questions, but I am confused: what do the "&&" do in this batch file.
```
@echo off
set /p Quest="How are you today? "
echo %Quest% > Results.txt
findstr /r /i "not.*good not.*well" Results.txt >nul && echo Sorry && ... | `&&` runs the second command on the line when the first command comes back successfully (i.e. `errorlevel == 0`). The opposite of `&&` is `||`, which runs the second command when the first command is unsuccessful (i.e. `errorlevel != 0`). |
10558316 | Example of delayed expansion in batch file | 64 | 2012-05-11 20:39:27 | <p>Can someone give me an example of where a batch script would act differently with or without delayed expansion? Are there any situations where you would NOT want to use delayed expansion? Thanks.</p>
| 78,856 | 1,231,882 | 2024-05-24 15:16:48 | 10,558,905 | 84 | 2012-05-11 21:30:31 | 1,057,961 | 2016-08-18 20:23:30 | https://stackoverflow.com/q/10558316 | https://stackoverflow.com/a/10558905 | <p>Look at the following examples...</p>
<p><strong>Example 1:</strong> The following code DOESN'T use delayed expansion, so the variables in the for loop are expanded only one time. This means that <code>%Count%</code> will always expand to <code>0</code> in each iteration of the loop, no matter what we do to it with... | <p>Look at the following examples...</p> <p><strong>Example 1:</strong> The following code DOESN'T use delayed expansion, so the variables in the for loop are expanded only one time. This means that <code>%Count%</code> will always expand to <code>0</code> in each iteration of the loop, no matter what we do to it with... | 64, 2631, 7002, 9013, 19675 | batch-file, cmd, delayedvariableexpansion, environment-variables, windows | <h1>Example of delayed expansion in batch file</h1>
<p>Can someone give me an example of where a batch script would act differently with or without delayed expansion? Are there any situations where you would NOT want to use delayed expansion? Thanks.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,090 | cmd | # Example of delayed expansion in batch file
Can someone give me an example of where a batch script would act differently with or without delayed expansion? Are there any situations where you would NOT want to use delayed expansion? Thanks. | Look at the following examples...
**Example 1:** The following code DOESN'T use delayed expansion, so the variables in the for loop are expanded only one time. This means that `%Count%` will always expand to `0` in each iteration of the loop, no matter what we do to it with the set command:
```
@echo off
set COUNT=0
... |
31217771 | Change directory in Node.js command prompt | 48 | 2015-07-04 06:44:43 | <p>I want to move to another directory in Node.js command prompt but when I open the Node.js cmd window it doesn't show me any path. Here is the screenshot of the Node.js cmd window:</p>
<p><img src="https://i.sstatic.net/iHv48.png" alt="enter image description here"></p>
<p>Now if i want to change directory to <code... | 217,175 | 4,574,888 | 2024-08-19 06:54:43 | 31,217,857 | 84 | 2015-07-04 06:54:55 | 404,623 | 2016-09-08 04:19:29 | https://stackoverflow.com/q/31217771 | https://stackoverflow.com/a/31217857 | <p>That isn't the Node.js command prompt window. That is a language shell to run JavaScript commands, also known as a <a href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop" rel="noreferrer">REPL</a>.</p>
<p>In Windows, there should be a <strong>Node.js command prompt</strong> in your Start menu o... | <p>That isn't the Node.js command prompt window. That is a language shell to run JavaScript commands, also known as a <a href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop" rel="noreferrer">REPL</a>.</p> <p>In Windows, there should be a <strong>Node.js command prompt</strong> in your Start menu o... | 218, 2631, 46426 | cmd, directory, node.js | <h1>Change directory in Node.js command prompt</h1>
<p>I want to move to another directory in Node.js command prompt but when I open the Node.js cmd window it doesn't show me any path. Here is the screenshot of the Node.js cmd window:</p>
<p><img src="https://i.sstatic.net/iHv48.png" alt="enter image description here"... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,091 | cmd | # Change directory in Node.js command prompt
I want to move to another directory in Node.js command prompt but when I open the Node.js cmd window it doesn't show me any path. Here is the screenshot of the Node.js cmd window:

Now if i want to change dir... | That isn't the Node.js command prompt window. That is a language shell to run JavaScript commands, also known as a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop).
In Windows, there should be a **Node.js command prompt** in your Start menu or start screen:
 and using the job parameter.I am starting the job in a new thread as I ... | 65,246 | 5,759,902 | 2020-05-19 14:47:54 | 38,780,983 | 84 | 2016-08-05 04:11:31 | 1,572,269 | 2016-08-05 04:11:31 | https://stackoverflow.com/q/38780796 | https://stackoverflow.com/a/38780983 | <p>A spring batch <code>StepScope</code> object is one which is unique to a specific step and not a singleton. As you probably know, the default bean scope in Spring is a singleton. But by specifying a spring batch component being <code>StepScope</code> means that Spring Batch will use the spring container to instant... | <p>A spring batch <code>StepScope</code> object is one which is unique to a specific step and not a singleton. As you probably know, the default bean scope in Spring is a singleton. But by specifying a spring batch component being <code>StepScope</code> means that Spring Batch will use the spring container to instant... | 1211, 41895 | spring, spring-batch | <h1>How Does Spring Batch Step Scope Work</h1>
<p>I have a requirement where I need to process files based on the rest call in which I get the name of the file, I am adding it to the job parameter and using it while creating the beans.</p>
<p>I am creating step scope Beans for (reader,writer) and using the job parame... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,092 | cmd | # How Does Spring Batch Step Scope Work
I have a requirement where I need to process files based on the rest call in which I get the name of the file, I am adding it to the job parameter and using it while creating the beans.
I am creating step scope Beans for (reader,writer) and using the job parameter.I am starting... | A spring batch `StepScope` object is one which is unique to a specific step and not a singleton. As you probably know, the default bean scope in Spring is a singleton. But by specifying a spring batch component being `StepScope` means that Spring Batch will use the spring container to instantiate a new instance of that... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.