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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7160342 | How to skip "are you sure Y/N" when deleting files in batch files | 178 | 2011-08-23 11:32:58 | <p>I can't for the life of me remember how to bypass the annoying prompt <code>are you sure? Y/N</code> when deleting files.</p>
<p>I seem to recall it was something like:</p>
<pre><code>del C:\Test && ECHO Y
</code></pre>
| 379,123 | 907,471 | 2022-01-25 06:32:52 | 7,160,366 | 277 | 2011-08-23 11:34:35 | 596,781 | 2018-09-12 20:06:54 | https://stackoverflow.com/q/7160342 | https://stackoverflow.com/a/7160366 | <p>Use <code>del /F /Q</code> to force deletion of read-only files (<code>/F</code>) and directories and not ask to confirm (<code>/Q</code>) when deleting via wildcard.</p>
| <p>Use <code>del /F /Q</code> to force deletion of read-only files (<code>/F</code>) and directories and not ask to confirm (<code>/Q</code>) when deleting via wildcard.</p> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>How to skip "are you sure Y/N" when deleting files in batch files</h1>
<p>I can't for the life of me remember how to bypass the annoying prompt <code>are you sure? Y/N</code> when deleting files.</p>
<p>I seem to recall it was something like:</p>
<pre><code>del C:\Test && ECHO Y
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,868 | cmd | # How to skip "are you sure Y/N" when deleting files in batch files
I can't for the life of me remember how to bypass the annoying prompt `are you sure? Y/N` when deleting files.
I seem to recall it was something like:
```
del C:\Test && ECHO Y
``` | Use `del /F /Q` to force deletion of read-only files (`/F`) and directories and not ask to confirm (`/Q`) when deleting via wildcard. |
4798879 | How do I run a batch script from within a batch script? | 133 | 2011-01-25 21:12:29 | <p>How do I call another batch script from within a batch script?</p>
<p>I want it to execute in an <code>if</code> statement.</p>
| 323,819 | 589,718 | 2022-01-03 18:12:21 | 4,798,965 | 277 | 2011-01-25 21:20:10 | 57,237 | 2016-11-15 23:44:38 | https://stackoverflow.com/q/4798879 | https://stackoverflow.com/a/4798965 | <p>Use <code>CALL</code> as in</p>
<pre><code>CALL nameOfOtherFile.bat
</code></pre>
<p>This will block (pause) the execution of the current batch file, and it will wait until the <code>CALL</code>ed one completes.</p>
<p>If you don't want it to block, use <code>START</code> instead. </p>
<p>Get the nitty-gritty de... | <p>Use <code>CALL</code> as in</p> <pre><code>CALL nameOfOtherFile.bat </code></pre> <p>This will block (pause) the execution of the current batch file, and it will wait until the <code>CALL</code>ed one completes.</p> <p>If you don't want it to block, use <code>START</code> instead. </p> <p>Get the nitty-gritty de... | 1231, 2631, 7002 | batch-file, cmd, command-line | <h1>How do I run a batch script from within a batch script?</h1>
<p>How do I call another batch script from within a batch script?</p>
<p>I want it to execute in an <code>if</code> statement.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,869 | cmd | # How do I run a batch script from within a batch script?
How do I call another batch script from within a batch script?
I want it to execute in an `if` statement. | Use `CALL` as in
```
CALL nameOfOtherFile.bat
```
This will block (pause) the execution of the current batch file, and it will wait until the `CALL`ed one completes.
If you don't want it to block, use `START` instead.
Get the nitty-gritty details by using `CALL /?` or `START /?` from the cmd prompt. |
16137713 | How do I run a Java program from the command line on Windows? | 270 | 2013-04-22 00:26:51 | <p>I'm trying to execute a Java program from the command line in Windows.<br />
Here is my code:</p>
<pre><code>import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class CopyFile {
public s... | 1,705,776 | 2,226,153 | 2024-06-27 18:02:55 | 16,137,745 | 273 | 2013-04-22 00:31:01 | 2,303,547 | 2017-11-02 10:26:24 | https://stackoverflow.com/q/16137713 | https://stackoverflow.com/a/16137745 | <p>Source: <a href="http://www.skylit.com/javamethods/faqs/javaindos.html" rel="noreferrer">javaindos.</a></p>
<blockquote>
<p>Let's say your file is in C:\mywork\</p>
<p>Run Command Prompt </p>
<pre><code>C:\> cd \mywork
</code></pre>
<p>This makes C:\mywork the current directory.</p>
<pre><code>C:\m... | <p>Source: <a href="http://www.skylit.com/javamethods/faqs/javaindos.html" rel="noreferrer">javaindos.</a></p> <blockquote> <p>Let's say your file is in C:\mywork\</p> <p>Run Command Prompt </p> <pre><code>C:\> cd \mywork </code></pre> <p>This makes C:\mywork the current directory.</p> <pre><code>C:\m... | 17, 1231, 2149, 2631 | cmd, command-line, java, jvm | <h1>How do I run a Java program from the command line on Windows?</h1>
<p>I'm trying to execute a Java program from the command line in Windows.<br />
Here is my code:</p>
<pre><code>import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,870 | cmd | # How do I run a Java program from the command line on Windows?
I'm trying to execute a Java program from the command line in Windows.
Here is my code:
```
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Out... | Source: [javaindos.](http://www.skylit.com/javamethods/faqs/javaindos.html)
> Let's say your file is in C:\mywork\
>
> Run Command Prompt
>
> ```
> C:\> cd \mywork
> ```
>
> This makes C:\mywork the current directory.
>
> ```
> C:\mywork> dir
> ```
>
> This displays the directory contents. You should see
> filenameher... |
1607271 | How do you find the current user in a Windows environment? | 208 | 2009-10-22 13:38:15 | <p>When running a command-line script, is it possible to get the name of the current user?</p>
| 545,308 | 31,610 | 2025-10-13 18:31:17 | 1,607,287 | 272 | 2009-10-22 13:41:01 | 35,501 | 2009-10-22 14:06:50 | https://stackoverflow.com/q/1607271 | https://stackoverflow.com/a/1607287 | <p>You can use the username variable: <code>%USERNAME%</code></p>
| <p>You can use the username variable: <code>%USERNAME%</code></p> | 64, 7002 | batch-file, windows | <h1>How do you find the current user in a Windows environment?</h1>
<p>When running a command-line script, is it possible to get the name of the current 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,872 | cmd | # How do you find the current user in a Windows environment?
When running a command-line script, is it possible to get the name of the current user? | You can use the username variable: `%USERNAME%` |
8486042 | What does "@" mean in Windows batch scripts | 196 | 2011-12-13 08:10:01 | <p>I saw <code>@</code> is used in such contexts:</p>
<pre><code>@echo off
@echo start eclipse.exe
</code></pre>
<p>What does <code>@</code> mean here?</p>
| 367,078 | 70,198 | 2023-07-02 06:05:46 | 8,486,061 | 271 | 2011-12-13 08:13:02 | 73,070 | 2011-12-13 08:13:02 | https://stackoverflow.com/q/8486042 | https://stackoverflow.com/a/8486061 | <p>It means not to output the respective command. Compare the following two batch files:</p>
<pre><code>@echo foo
</code></pre>
<p>and</p>
<pre><code>echo foo
</code></pre>
<p>The former has only <code>foo</code> as output while the latter prints</p>
<pre><code>H:\Stuff>echo foo
foo
</code></pre>
<p>(here, at... | <p>It means not to output the respective command. Compare the following two batch files:</p> <pre><code>@echo foo </code></pre> <p>and</p> <pre><code>echo foo </code></pre> <p>The former has only <code>foo</code> as output while the latter prints</p> <pre><code>H:\Stuff>echo foo foo </code></pre> <p>(here, at... | 64, 7002 | batch-file, windows | <h1>What does "@" mean in Windows batch scripts</h1>
<p>I saw <code>@</code> is used in such contexts:</p>
<pre><code>@echo off
@echo start eclipse.exe
</code></pre>
<p>What does <code>@</code> mean here?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,873 | cmd | # What does "@" mean in Windows batch scripts
I saw `@` is used in such contexts:
```
@echo off
@echo start eclipse.exe
```
What does `@` mean here? | It means not to output the respective command. Compare the following two batch files:
```
@echo foo
```
and
```
echo foo
```
The former has only `foo` as output while the latter prints
```
H:\Stuff>echo foo
foo
```
(here, at least). As can be seen the command that is run is visible, too.
`echo off` will turn th... |
34716454 | Where do I call the BatchNormalization function in Keras? | 213 | 2016-01-11 07:47:53 | <p>If I want to use the BatchNormalization function in Keras, then do I need to call it once only at the beginning?</p>
<p>I read this documentation for it: <a href="http://keras.io/layers/normalization/">http://keras.io/layers/normalization/</a></p>
<p>I don't see where I'm supposed to call it. Below is my code atte... | 258,633 | 4,984,897 | 2024-04-29 19:09:06 | 37,979,391 | 270 | 2016-06-22 22:40:51 | 4,727,781 | 2024-04-29 19:09:00 | https://stackoverflow.com/q/34716454 | https://stackoverflow.com/a/37979391 | <p>As <a href="https://stackoverflow.com/questions/34716454/where-do-i-call-the-batchnormalization-function-in-keras/34751249#34751249">Pavel said</a>, Batch Normalization is just another layer, so you can use it as such to create your desired network architecture.</p>
<p>The general use case is to use BN between the l... | <p>As <a href="https://stackoverflow.com/questions/34716454/where-do-i-call-the-batchnormalization-function-in-keras/34751249#34751249">Pavel said</a>, Batch Normalization is just another layer, so you can use it as such to create your desired network architecture.</p> <p>The general use case is to use BN between the l... | 16, 40102, 112144, 124994 | batch-normalization, keras, neural-network, python | <h1>Where do I call the BatchNormalization function in Keras?</h1>
<p>If I want to use the BatchNormalization function in Keras, then do I need to call it once only at the beginning?</p>
<p>I read this documentation for it: <a href="http://keras.io/layers/normalization/">http://keras.io/layers/normalization/</a></p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,874 | cmd | # Where do I call the BatchNormalization function in Keras?
If I want to use the BatchNormalization function in Keras, then do I need to call it once only at the beginning?
I read this documentation for it: <http://keras.io/layers/normalization/>
I don't see where I'm supposed to call it. Below is my code attempting... | As [Pavel said](https://stackoverflow.com/questions/34716454/where-do-i-call-the-batchnormalization-function-in-keras/34751249#34751249), Batch Normalization is just another layer, so you can use it as such to create your desired network architecture.
The general use case is to use BN between the linear and non-linear... |
980331 | Redirecting passed arguments to a windows batch file | 133 | 2009-06-11 10:12:32 | <p>I would like to call a jar file from a windows batch file. One requirement is to be able to pass all the batch file arguments as-is to the jar file invocation. For example,</p>
<p>Required Command line:</p>
<pre><code>foo.bat --flag1=x --flag2=y --flag3=z
</code></pre>
<p>The batch file <code>foo.bat</code> shoul... | 67,040 | 378 | 2013-09-23 15:03:49 | 980,372 | 266 | 2009-06-11 10:25:03 | 119,123 | 2009-06-11 10:25:03 | https://stackoverflow.com/q/980331 | https://stackoverflow.com/a/980372 | <p>Does </p>
<pre><code>java -jar foo.jar %*
</code></pre>
<p>meet your needs? It should add all parameters from the batch execution to your application call within the batch file.</p>
| <p>Does </p> <pre><code>java -jar foo.jar %* </code></pre> <p>meet your needs? It should add all parameters from the batch execution to your application call within the batch file.</p> | 64, 2313, 7002 | arguments, batch-file, windows | <h1>Redirecting passed arguments to a windows batch file</h1>
<p>I would like to call a jar file from a windows batch file. One requirement is to be able to pass all the batch file arguments as-is to the jar file invocation. For example,</p>
<p>Required Command line:</p>
<pre><code>foo.bat --flag1=x --flag2=y --flag3... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,875 | cmd | # Redirecting passed arguments to a windows batch file
I would like to call a jar file from a windows batch file. One requirement is to be able to pass all the batch file arguments as-is to the jar file invocation. For example,
Required Command line:
```
foo.bat --flag1=x --flag2=y --flag3=z
```
The batch file `foo... | Does
```
java -jar foo.jar %*
```
meet your needs? It should add all parameters from the batch execution to your application call within the batch file. |
18180060 | How to zip a file using cmd line? | 152 | 2013-08-12 05:27:21 | <p>I want to zip a directory using the batch file command (Windows XP batch file).</p>
<p>For example, if I want to unzip a file means I can use the <code>jar -xf file.zip</code>(java) bat file command.</p>
<p>Like that I want a command line batch to zip a directory.</p>
| 687,002 | 1,990,589 | 2025-12-24 10:16:42 | 18,180,154 | 263 | 2013-08-12 05:35:07 | 2,673,375 | 2025-04-17 17:52:03 | https://stackoverflow.com/q/18180060 | https://stackoverflow.com/a/18180154 | <h2>If you are using Ubuntu Linux:</h2>
<ol>
<li><p>Install <code>zip</code></p>
<pre><code> sudo apt-get install zip
</code></pre>
</li>
<li><p>Zip your folder:</p>
<pre><code> zip -r {filename.zip} {foldername}
</code></pre>
</li>
</ol>
<h2>If you are using Microsoft Windows:</h2>
<p>As <a href="https://stackoverflow... | <h2>If you are using Ubuntu Linux:</h2> <ol> <li><p>Install <code>zip</code></p> <pre><code> sudo apt-get install zip </code></pre> </li> <li><p>Zip your folder:</p> <pre><code> zip -r {filename.zip} {foldername} </code></pre> </li> </ol> <h2>If you are using Microsoft Windows:</h2> <p>As <a href="https://stackoverflow... | 64, 1231, 7002, 9938 | batch-file, command-line, command-prompt, windows | <h1>How to zip a file using cmd line?</h1>
<p>I want to zip a directory using the batch file command (Windows XP batch file).</p>
<p>For example, if I want to unzip a file means I can use the <code>jar -xf file.zip</code>(java) bat file command.</p>
<p>Like that I want a command line batch to zip a directory.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,876 | cmd | # How to zip a file using cmd line?
I want to zip a directory using the batch file command (Windows XP batch file).
For example, if I want to unzip a file means I can use the `jar -xf file.zip`(java) bat file command.
Like that I want a command line batch to zip a directory. | ## If you are using Ubuntu Linux:
1. Install `zip`
```
sudo apt-get install zip
```
2. Zip your folder:
```
zip -r {filename.zip} {foldername}
```
## If you are using Microsoft Windows:
As [Katsutoshi Hayashida's answer](https://stackoverflow.com/a/73980139/1518546) notes,
[starting with Window... |
5898131 | Set a persistent environment variable from cmd.exe | 181 | 2011-05-05 13:03:00 | <p>I have to set environment variables on different windows machines, but I don't want to be bothered changing them manually by getting on the properties screen of "My Computer"</p>
<p>I want to do it from the command line, with a batch file. As far as I understand, using set will only change the variable for... | 231,138 | 109,525 | 2023-11-23 05:40:34 | 5,898,197 | 261 | 2011-05-05 13:09:14 | 171,676 | 2022-10-22 12:28:09 | https://stackoverflow.com/q/5898131 | https://stackoverflow.com/a/5898197 | <p>Use the <a href="http://technet.microsoft.com/en-us/library/cc755104%28WS.10%29.aspx" rel="noreferrer">SETX command</a> (note the 'x' suffix) to set variables that persist after the cmd window has been closed.</p>
<p>For example, to set an env var "foo" with value of "bar":</p>
<pre><code>setx fo... | <p>Use the <a href="http://technet.microsoft.com/en-us/library/cc755104%28WS.10%29.aspx" rel="noreferrer">SETX command</a> (note the 'x' suffix) to set variables that persist after the cmd window has been closed.</p> <p>For example, to set an env var "foo" with value of "bar":</p> <pre><code>setx fo... | 64, 2631, 7002, 9013 | batch-file, cmd, environment-variables, windows | <h1>Set a persistent environment variable from cmd.exe</h1>
<p>I have to set environment variables on different windows machines, but I don't want to be bothered changing them manually by getting on the properties screen of "My Computer"</p>
<p>I want to do it from the command line, with a batch file. As far ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,877 | cmd | # Set a persistent environment variable from cmd.exe
I have to set environment variables on different windows machines, but I don't want to be bothered changing them manually by getting on the properties screen of "My Computer"
I want to do it from the command line, with a batch file. As far as I understand, using se... | Use the [SETX command](http://technet.microsoft.com/en-us/library/cc755104%28WS.10%29.aspx) (note the 'x' suffix) to set variables that persist after the cmd window has been closed.
For example, to set an env var "foo" with value of "bar":
```
setx foo bar /m
```
Though it's worth reading the 'notes' that are displa... |
5909012 | Windows batch script launch program and exit console | 122 | 2011-05-06 08:52:49 | <p>I have a batch script that I use to launch a program, such as <code>notepad.exe</code>. When I double click on this batch file, notepad starts normally, but the black window of the <code>cmd</code> who launched <code>notepad.exe</code> remains in the background. What do I have to do in order to launch <code>notepad.... | 214,495 | 329,584 | 2023-03-06 05:43:16 | 12,848,306 | 261 | 2012-10-11 20:50:22 | 407,685 | 2017-08-08 09:59:08 | https://stackoverflow.com/q/5909012 | https://stackoverflow.com/a/12848306 | <pre><code>start "" "%SystemRoot%\Notepad.exe"
</code></pre>
<p>Keep the <code>""</code> in between start and your application path.</p>
<hr>
<p><strong>Added explanation:</strong></p>
<p>Normally when we launch a program from a batch file like below, we'll have the black windows at the background like OP said.</p>... | <pre><code>start "" "%SystemRoot%\Notepad.exe" </code></pre> <p>Keep the <code>""</code> in between start and your application path.</p> <hr> <p><strong>Added explanation:</strong></p> <p>Normally when we launch a program from a batch file like below, we'll have the black windows at the background like OP said.</p>... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Windows batch script launch program and exit console</h1>
<p>I have a batch script that I use to launch a program, such as <code>notepad.exe</code>. When I double click on this batch file, notepad starts normally, but the black window of the <code>cmd</code> who launched <code>notepad.exe</code> remains in the back... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,878 | cmd | # Windows batch script launch program and exit console
I have a batch script that I use to launch a program, such as `notepad.exe`. When I double click on this batch file, notepad starts normally, but the black window of the `cmd` who launched `notepad.exe` remains in the background. What do I have to do in order to l... | ```
start "" "%SystemRoot%\Notepad.exe"
```
Keep the `""` in between start and your application path.
---
**Added explanation:**
Normally when we launch a program from a batch file like below, we'll have the black windows at the background like OP said.
```
%SystemRoot%\Notepad.exe
```
This was cause by Notepad r... |
210201 | How to create empty text file from a batch file? | 294 | 2008-10-16 20:38:18 | <p>Can somebody remember what was the command to create an empty file in MSDOS using BAT file?</p>
| 643,472 | 446,104 | 2023-02-20 11:11:31 | 210,209 | 259 | 2008-10-16 20:39:25 | 1,975,282 | 2023-02-20 11:11:31 | https://stackoverflow.com/q/210201 | https://stackoverflow.com/a/210209 | <pre><code>echo. 2>EmptyFile.txt
</code></pre>
<hr />
<p>This redirects output stream 2 (<code>stderr</code>) to a file. The command <code>echo</code> doesn't output anything to <code>stderr</code>, so the file becomes empty.</p>
<p>Plain <code>echo</code> would work too, but <code>echo.</code> is better because it ... | <pre><code>echo. 2>EmptyFile.txt </code></pre> <hr /> <p>This redirects output stream 2 (<code>stderr</code>) to a file. The command <code>echo</code> doesn't output anything to <code>stderr</code>, so the file becomes empty.</p> <p>Plain <code>echo</code> would work too, but <code>echo.</code> is better because it ... | 2631, 5370, 7002 | batch-file, cmd, dos | <h1>How to create empty text file from a batch file?</h1>
<p>Can somebody remember what was the command to create an empty file in MSDOS using BAT file?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,879 | cmd | # How to create empty text file from a batch file?
Can somebody remember what was the command to create an empty file in MSDOS using BAT file? | ```
echo. 2>EmptyFile.txt
```
---
This redirects output stream 2 (`stderr`) to a file. The command `echo` doesn't output anything to `stderr`, so the file becomes empty.
Plain `echo` would work too, but `echo.` is better because it doesn't print the useless and potentially confusing message `ECHO is on.` |
17957076 | Keep CMD open after BAT file executes | 276 | 2013-07-30 20:48:27 | <p>I have a bat file like this:</p>
<pre><code>ipconfig
</code></pre>
<p>That will print out the IP info to the screen, but before the user can read that info CMD closes itself.</p>
<p>I believe that CMD assumes the script has finished, so it closes.</p>
<p>How do I keep CMD open after the script is finished?</p>
| 599,118 | 2,400,000 | 2024-12-03 05:11:28 | 17,957,220 | 256 | 2013-07-30 20:55:10 | 2,611,049 | 2020-06-23 19:17:38 | https://stackoverflow.com/q/17957076 | https://stackoverflow.com/a/17957220 | <p>Depending on how you are running the command, you can put <code>/k</code> after <code>cmd</code> to keep the window open.</p>
<pre><code>cmd /k my_script.bat
</code></pre>
<p>Simply adding <code>cmd /k</code> to the end of your batch file will work too. Credit to <a href="https://stackoverflow.com/users/4141943/luig... | <p>Depending on how you are running the command, you can put <code>/k</code> after <code>cmd</code> to keep the window open.</p> <pre><code>cmd /k my_script.bat </code></pre> <p>Simply adding <code>cmd /k</code> to the end of your batch file will work too. Credit to <a href="https://stackoverflow.com/users/4141943/luig... | 2631, 5310, 7002 | batch-file, cmd, file | <h1>Keep CMD open after BAT file executes</h1>
<p>I have a bat file like this:</p>
<pre><code>ipconfig
</code></pre>
<p>That will print out the IP info to the screen, but before the user can read that info CMD closes itself.</p>
<p>I believe that CMD assumes the script has finished, so it closes.</p>
<p>How do I ke... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,881 | cmd | # Keep CMD open after BAT file executes
I have a bat file like this:
```
ipconfig
```
That will print out the IP info to the screen, but before the user can read that info CMD closes itself.
I believe that CMD assumes the script has finished, so it closes.
How do I keep CMD open after the script is finished? | Depending on how you are running the command, you can put `/k` after `cmd` to keep the window open.
```
cmd /k my_script.bat
```
Simply adding `cmd /k` to the end of your batch file will work too. Credit to [Luigi D'Amico](https://stackoverflow.com/users/4141943/luigi-damico) who posted about this in the comments bel... |
9102422 | windows batch SET inside IF not working | 133 | 2012-02-01 20:01:11 | <p>when I'm running this script (from a .bat file):</p>
<pre><code>set var1=true
if "%var1%"=="true" (
set var2=myvalue
echo %var2%
)
</code></pre>
<p>I always get:</p>
<pre><code>ECHO is on.
</code></pre>
<p>Meaning the <code>var2</code> variable was not really set.
Can anyone please help me understand why?</p... | 104,076 | 198,482 | 2022-06-28 07:16:14 | 9,102,569 | 255 | 2012-02-01 20:12:12 | 463,115 | 2018-05-29 10:08:15 | https://stackoverflow.com/q/9102422 | https://stackoverflow.com/a/9102569 | <p>var2 is set, but the expansion in the line <code>echo %var2%</code> occurs before the block is executed.<br>
At this time <code>var2</code> is empty. </p>
<p>Therefore the delayedExpansion syntax exists, it uses <code>!</code> instead of <code>%</code> and it is evaluated at execution time, not parse time.</p>
<p... | <p>var2 is set, but the expansion in the line <code>echo %var2%</code> occurs before the block is executed.<br> At this time <code>var2</code> is empty. </p> <p>Therefore the delayedExpansion syntax exists, it uses <code>!</code> instead of <code>%</code> and it is evaluated at execution time, not parse time.</p> <p... | 64, 2631, 7002, 19675 | batch-file, cmd, delayedvariableexpansion, windows | <h1>windows batch SET inside IF not working</h1>
<p>when I'm running this script (from a .bat file):</p>
<pre><code>set var1=true
if "%var1%"=="true" (
set var2=myvalue
echo %var2%
)
</code></pre>
<p>I always get:</p>
<pre><code>ECHO is on.
</code></pre>
<p>Meaning the <code>var2</code> variable was not really ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,882 | cmd | # windows batch SET inside IF not working
when I'm running this script (from a .bat file):
```
set var1=true
if "%var1%"=="true" (
set var2=myvalue
echo %var2%
)
```
I always get:
```
ECHO is on.
```
Meaning the `var2` variable was not really set.
Can anyone please help me understand why? | var2 is set, but the expansion in the line `echo %var2%` occurs before the block is executed.
At this time `var2` is empty.
Therefore the delayedExpansion syntax exists, it uses `!` instead of `%` and it is evaluated at execution time, not parse time.
Please note that in order to use `!`, the additional statement `... |
11010834 | How to run multiple DOS commands in parallel? | 145 | 2012-06-13 08:21:02 | <p>How to run multiple dos commands?</p>
<p>I have a <code>for</code> loop, which runs detection of server to detect which server works and is fast. And because there is more servers, I wish not to run all server detections in sequence, but in parallel. </p>
| 229,743 | 1,141,649 | 2022-12-23 06:22:16 | 11,011,212 | 251 | 2012-06-13 08:44:28 | 799,586 | 2022-12-23 06:22:16 | https://stackoverflow.com/q/11010834 | https://stackoverflow.com/a/11011212 | <p>You can execute commands in parallel with <code>start</code> like this:</p>
<pre><code>start "" ping myserver
start "" nslookup myserver
start "" morecommands
</code></pre>
<p>They will each start in their own command prompt and allow you to run multiple commands at the same time from o... | <p>You can execute commands in parallel with <code>start</code> like this:</p> <pre><code>start "" ping myserver start "" nslookup myserver start "" morecommands </code></pre> <p>They will each start in their own command prompt and allow you to run multiple commands at the same time from o... | 2631, 7002 | batch-file, cmd | <h1>How to run multiple DOS commands in parallel?</h1>
<p>How to run multiple dos commands?</p>
<p>I have a <code>for</code> loop, which runs detection of server to detect which server works and is fast. And because there is more servers, I wish not to run all server detections in sequence, but in parallel. </p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,883 | cmd | # How to run multiple DOS commands in parallel?
How to run multiple dos commands?
I have a `for` loop, which runs detection of server to detect which server works and is fast. And because there is more servers, I wish not to run all server detections in sequence, but in parallel. | You can execute commands in parallel with `start` like this:
```
start "" ping myserver
start "" nslookup myserver
start "" morecommands
```
They will each start in their own command prompt and allow you to run multiple commands at the same time from one batch file. |
1964192 | Removing double quotes from variables in batch file creates problems with CMD environment | 162 | 2009-12-26 19:48:34 | <p>Can anybody help with effective and safe way of removing quotes from batch variables?</p>
<p>I have written a batch file which successfully imports a list of parameters %1, %2, %3 etc. and places them into named variables. Some of these parameters contain multiple words, and therefor are enclosed in double quotes.<... | 235,611 | 238,932 | 2021-10-18 17:10:54 | 5,181,182 | 248 | 2011-03-03 13:15:35 | 643,034 | 2016-01-08 23:07:40 | https://stackoverflow.com/q/1964192 | https://stackoverflow.com/a/5181182 | <p>You have an extra double quote at the end, which is adding it back to the end of the string (after removing both quotes from the string).</p>
<p>Input:</p>
<pre><code>set widget="a very useful item"
set widget
set widget=%widget:"=%
set widget
</code></pre>
<p>Output:</p>
<pre><code>widget="a very useful item"
w... | <p>You have an extra double quote at the end, which is adding it back to the end of the string (after removing both quotes from the string).</p> <p>Input:</p> <pre><code>set widget="a very useful item" set widget set widget=%widget:"=% set widget </code></pre> <p>Output:</p> <pre><code>widget="a very useful item" w... | 276, 430, 2631, 7002 | batch-file, cmd, quotes, variables | <h1>Removing double quotes from variables in batch file creates problems with CMD environment</h1>
<p>Can anybody help with effective and safe way of removing quotes from batch variables?</p>
<p>I have written a batch file which successfully imports a list of parameters %1, %2, %3 etc. and places them into named variab... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,884 | cmd | # Removing double quotes from variables in batch file creates problems with CMD environment
Can anybody help with effective and safe way of removing quotes from batch variables?
I have written a batch file which successfully imports a list of parameters %1, %2, %3 etc. and places them into named variables. Some of th... | You have an extra double quote at the end, which is adding it back to the end of the string (after removing both quotes from the string).
Input:
```
set widget="a very useful item"
set widget
set widget=%widget:"=%
set widget
```
Output:
```
widget="a very useful item"
widget=a very useful item
```
Note: To replac... |
303838 | Create a new cmd.exe window from within another cmd.exe prompt | 130 | 2008-11-19 23:47:40 | <p>I am in the process of setting up CruiseControl.NET. The problem I am having is that I am running CC as a console application and when my build completes successfully and executes (using exec) it launches it within the CruiseControl DOS prompt. I am just using simple batch files to launch my app but having it run wi... | 253,755 | 25,946 | 2023-12-08 17:23:37 | 303,844 | 248 | 2008-11-19 23:48:53 | 33,686 | 2017-05-12 12:14:13 | https://stackoverflow.com/q/303838 | https://stackoverflow.com/a/303844 | <p>I think this works:</p>
<pre><code>start cmd.exe
</code></pre>
| <p>I think this works:</p> <pre><code>start cmd.exe </code></pre> | 64, 1231, 2631 | cmd, command-line, windows | <h1>Create a new cmd.exe window from within another cmd.exe prompt</h1>
<p>I am in the process of setting up CruiseControl.NET. The problem I am having is that I am running CC as a console application and when my build completes successfully and executes (using exec) it launches it within the CruiseControl DOS prompt. ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,885 | cmd | # Create a new cmd.exe window from within another cmd.exe prompt
I am in the process of setting up CruiseControl.NET. The problem I am having is that I am running CC as a console application and when my build completes successfully and executes (using exec) it launches it within the CruiseControl DOS prompt. I am just... | I think this works:
```
start cmd.exe
``` |
503846 | How do I echo and send console output to a file in a bat script? | 158 | 2009-02-02 16:38:02 | <p>I have a batch script that executes a task and sends the output to a text file. Is there a way to have the output show on the console window as well?</p>
<p>For example:</p>
<pre><code>C:
cd C:\Windows
dir > windows-dir.txt
</code></pre>
<p>Is there a way to have the output of <code>dir</code> display in the con... | 450,315 | 28,540 | 2025-07-27 12:32:31 | 4,588,136 | 245 | 2011-01-03 20:34:58 | 463,115 | 2022-12-22 10:18:58 | https://stackoverflow.com/q/503846 | https://stackoverflow.com/a/4588136 | <p>No, you can't with pure redirection.<br />
But with some tricks (like <a href="https://stackoverflow.com/a/10719322/463115">tee.bat</a>) you can.</p>
<p>I try to explain the redirection a bit.</p>
<p>You redirect one of the ten streams with <strong>> file</strong> or <strong>< file</strong><br />
It is unimpor... | <p>No, you can't with pure redirection.<br /> But with some tricks (like <a href="https://stackoverflow.com/a/10719322/463115">tee.bat</a>) you can.</p> <p>I try to explain the redirection a bit.</p> <p>You redirect one of the ten streams with <strong>> file</strong> or <strong>< file</strong><br /> It is unimpor... | 64, 2631, 7002, 22055, 26698 | batch-file, cmd, io-redirection, tee, windows | <h1>How do I echo and send console output to a file in a bat script?</h1>
<p>I have a batch script that executes a task and sends the output to a text file. Is there a way to have the output show on the console window as well?</p>
<p>For example:</p>
<pre><code>C:
cd C:\Windows
dir > windows-dir.txt
</code></pre>
<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,886 | cmd | # How do I echo and send console output to a file in a bat script?
I have a batch script that executes a task and sends the output to a text file. Is there a way to have the output show on the console window as well?
For example:
```
C:
cd C:\Windows
dir > windows-dir.txt
```
Is there a way to have the output of `d... | No, you can't with pure redirection.
But with some tricks (like [tee.bat](https://stackoverflow.com/a/10719322/463115)) you can.
I try to explain the redirection a bit.
You redirect one of the ten streams with **> file** or **< file**
It is unimportant, if the redirection is before or after the command,
so these ... |
1262708 | Suppress command line output | 143 | 2009-08-11 20:24:41 | <p>I have a simple batch file like this:</p>
<pre>
echo off
taskkill /im "test.exe" /f > nul
pause
</pre>
<p>If "test.exe" is not running, I get this message:</p>
<pre>
ERROR: The process "test.exe" not found.
</pre>
<p>Why does this error message get displayed, even though I have redirected output to NUL?</p>
<... | 224,568 | 672 | 2016-01-01 20:26:00 | 1,262,726 | 245 | 2009-08-11 20:28:13 | 68,204 | 2016-01-01 20:26:00 | https://stackoverflow.com/q/1262708 | https://stackoverflow.com/a/1262726 | <p>Because error messages often go to <code>stderr</code> not <code>stdout</code>.</p>
<p>Change the invocation to this:</p>
<pre><code>taskkill /im "test.exe" /f >nul 2>&1
</code></pre>
<p>and all will be better.</p>
<p>That works because <code>stdout</code> is file descriptor 1, and <code>stderr</code> ... | <p>Because error messages often go to <code>stderr</code> not <code>stdout</code>.</p> <p>Change the invocation to this:</p> <pre><code>taskkill /im "test.exe" /f >nul 2>&1 </code></pre> <p>and all will be better.</p> <p>That works because <code>stdout</code> is file descriptor 1, and <code>stderr</code> ... | 7002 | batch-file | <h1>Suppress command line output</h1>
<p>I have a simple batch file like this:</p>
<pre>
echo off
taskkill /im "test.exe" /f > nul
pause
</pre>
<p>If "test.exe" is not running, I get this message:</p>
<pre>
ERROR: The process "test.exe" not found.
</pre>
<p>Why does this error message get displayed, even though I... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,887 | cmd | # Suppress command line output
I have a simple batch file like this:
```
echo off
taskkill /im "test.exe" /f > nul
pause
```
If "test.exe" is not running, I get this message:
```
ERROR: The process "test.exe" not found.
```
Why does this error message get displayed, even though I have redirected output to NUL?
... | Because error messages often go to `stderr` not `stdout`.
Change the invocation to this:
```
taskkill /im "test.exe" /f >nul 2>&1
```
and all will be better.
That works because `stdout` is file descriptor 1, and `stderr` is file descriptor 2 by convention. (0 is `stdin`, incidentally.) The `2>&1` copies output file... |
8526946 | Commenting multiple lines in DOS batch file | 138 | 2011-12-15 21:36:10 | <p>I have written huge MS DOS Batch file. To test this batch file I need to execute some lines only and want to hide/comment out remaining.</p>
<p>I have some existing comment lines starting with <code>::</code> hence I cannot use <code>::</code> anymore as it will scramble all comments.</p>
<p>How can I solve this pro... | 164,734 | 219,628 | 2021-09-05 15:08:32 | 8,527,001 | 244 | 2011-12-15 21:39:54 | 821,966 | 2011-12-15 21:39:54 | https://stackoverflow.com/q/8526946 | https://stackoverflow.com/a/8527001 | <p>You can use a <code>goto</code> to skip over code.</p>
<pre><code>goto comment
...skip this...
:comment
</code></pre>
| <p>You can use a <code>goto</code> to skip over code.</p> <pre><code>goto comment ...skip this... :comment </code></pre> | 1966, 5370, 7002, 10941 | batch-file, comments, dos, multiline | <h1>Commenting multiple lines in DOS batch file</h1>
<p>I have written huge MS DOS Batch file. To test this batch file I need to execute some lines only and want to hide/comment out remaining.</p>
<p>I have some existing comment lines starting with <code>::</code> hence I cannot use <code>::</code> anymore as it will s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,888 | cmd | # Commenting multiple lines in DOS batch file
I have written huge MS DOS Batch file. To test this batch file I need to execute some lines only and want to hide/comment out remaining.
I have some existing comment lines starting with `::` hence I cannot use `::` anymore as it will scramble all comments.
How can I solv... | You can use a `goto` to skip over code.
```
goto comment
...skip this...
:comment
``` |
13257571 | CALL command vs. START with /WAIT option | 187 | 2012-11-06 19:00:41 | <p>How is the START command with a WAIT option </p>
<pre><code>START /wait notepad.exe
START /wait notepad.exe
</code></pre>
<p>...any different from using a CALL command?</p>
<pre><code>CALL notepad.exe
CALL notepad.exe
</code></pre>
<p>Is there a situation where one may behave differently that the other depe... | 693,267 | 109,676 | 2019-07-09 08:24:01 | 13,258,451 | 238 | 2012-11-06 19:59:54 | 463,115 | 2019-07-09 08:24:01 | https://stackoverflow.com/q/13257571 | https://stackoverflow.com/a/13258451 | <p>For <em>exe</em> files, I suppose the differences are nearly unimportant.<br>
But to start an <em>exe</em> you don't even need <code>CALL</code>. </p>
<p>When starting another batch it's a big difference,<br>
as <code>CALL</code> will start it in the same window and the called batch has access to the same variabl... | <p>For <em>exe</em> files, I suppose the differences are nearly unimportant.<br> But to start an <em>exe</em> you don't even need <code>CALL</code>. </p> <p>When starting another batch it's a big difference,<br> as <code>CALL</code> will start it in the same window and the called batch has access to the same variabl... | 64, 7002 | batch-file, windows | <h1>CALL command vs. START with /WAIT option</h1>
<p>How is the START command with a WAIT option </p>
<pre><code>START /wait notepad.exe
START /wait notepad.exe
</code></pre>
<p>...any different from using a CALL command?</p>
<pre><code>CALL notepad.exe
CALL notepad.exe
</code></pre>
<p>Is there a situation wh... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,889 | cmd | # CALL command vs. START with /WAIT option
How is the START command with a WAIT option
```
START /wait notepad.exe
START /wait notepad.exe
```
...any different from using a CALL command?
```
CALL notepad.exe
CALL notepad.exe
```
Is there a situation where one may behave differently that the other dependending o... | For *exe* files, I suppose the differences are nearly unimportant.
But to start an *exe* you don't even need `CALL`.
When starting another batch it's a big difference,
as `CALL` will start it in the same window and the called batch has access to the same variable context.
So it can also change variables which af... |
33822 | Any way to write a Windows .bat file to kill processes? | 148 | 2008-08-29 02:09:55 | <p>Every time I turn on my company-owned development machine, I have to kill 10+ processes using the Task Manager or any other process management app just to get decent performance out of my IDE. Yes, these are processes from programs that my company installs on my machine for security and compliance. What I'd like to... | 466,774 | 3,030 | 2020-05-30 01:28:27 | 33,831 | 236 | 2008-08-29 02:14:00 | 1,569 | 2020-05-30 01:28:27 | https://stackoverflow.com/q/33822 | https://stackoverflow.com/a/33831 | <p>You can do this with '<strong>taskkill</strong>'.
With the /IM parameter, you can specify image names. </p>
<p>Example:</p>
<pre><code>taskkill /im somecorporateprocess.exe
</code></pre>
<p>You can also do this to '<strong>force</strong>' kill:</p>
<p>Example:</p>
<pre><code>taskkill /f /im somecorporateprocess... | <p>You can do this with '<strong>taskkill</strong>'. With the /IM parameter, you can specify image names. </p> <p>Example:</p> <pre><code>taskkill /im somecorporateprocess.exe </code></pre> <p>You can also do this to '<strong>force</strong>' kill:</p> <p>Example:</p> <pre><code>taskkill /f /im somecorporateprocess... | 598, 5910, 7002 | batch-file, performance, process | <h1>Any way to write a Windows .bat file to kill processes?</h1>
<p>Every time I turn on my company-owned development machine, I have to kill 10+ processes using the Task Manager or any other process management app just to get decent performance out of my IDE. Yes, these are processes from programs that my company ins... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,890 | cmd | # Any way to write a Windows .bat file to kill processes?
Every time I turn on my company-owned development machine, I have to kill 10+ processes using the Task Manager or any other process management app just to get decent performance out of my IDE. Yes, these are processes from programs that my company installs on m... | You can do this with '**taskkill**'.
With the /IM parameter, you can specify image names.
Example:
```
taskkill /im somecorporateprocess.exe
```
You can also do this to '**force**' kill:
Example:
```
taskkill /f /im somecorporateprocess.exe
```
Just add one line per process you want to kill, save it as a .bat fil... |
4507312 | How to redirect stderr to null in cmd.exe | 171 | 2010-12-22 08:14:37 | <p>I have an application that logs a lot of noise to stderr and REALLY slows down the execution of the application. I would like to redirect that output to null. Is this possible with cmd.exe?</p>
| 176,818 | 166,452 | 2023-10-31 19:28:01 | 4,507,627 | 233 | 2010-12-22 09:06:07 | 23,252 | 2018-06-13 09:31:32 | https://stackoverflow.com/q/4507312 | https://stackoverflow.com/a/4507627 | <pre><code>Your DOS command 2> nul
</code></pre>
<p>Read page <em><a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10)" rel="noreferrer">Using command redirection operators</a></em>. Besides the "2>" construct mentioned by Tanuki Software, it lists some other... | <pre><code>Your DOS command 2> nul </code></pre> <p>Read page <em><a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10)" rel="noreferrer">Using command redirection operators</a></em>. Besides the "2>" construct mentioned by Tanuki Software, it lists some other... | 2631, 19156, 31901 | cmd, http-redirect, stderr | <h1>How to redirect stderr to null in cmd.exe</h1>
<p>I have an application that logs a lot of noise to stderr and REALLY slows down the execution of the application. I would like to redirect that output to null. Is this possible with cmd.exe?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,891 | cmd | # How to redirect stderr to null in cmd.exe
I have an application that logs a lot of noise to stderr and REALLY slows down the execution of the application. I would like to redirect that output to null. Is this possible with cmd.exe? | ```
Your DOS command 2> nul
```
Read page *[Using command redirection operators](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10))*. Besides the "2>" construct mentioned by Tanuki Software, it lists some other useful combinations. |
370030 | Why git can't remember my passphrase under Windows | 248 | 2008-12-15 23:12:26 | <p>I have just start using git and i can't get it to remember my passphrase I'm using cmd.exe elevated and my git host is github and i have create a ssh key like that guide on github</p>
<p>but i still get </p>
<pre><code>*\subnus.mvc>git push origin master
Enter passphrase for key '/c/Users/Subnus/.ssh/id_rsa':
... | 150,596 | 31,296 | 2025-04-15 14:01:29 | 4,356,869 | 228 | 2010-12-05 01:24:03 | 388,702 | 2021-03-13 18:15:56 | https://stackoverflow.com/q/370030 | https://stackoverflow.com/a/4356869 | <p>I realize that this question is coming up on two years old, but I had the same issue and several answers here did not completely answer the question for me. Here are three step-by-step solutions, depending on whether you use TortoiseGit in addition to msysgit or not.</p>
<p><strong>First solution</strong> Assumes Wi... | <p>I realize that this question is coming up on two years old, but I had the same issue and several answers here did not completely answer the question for me. Here are three step-by-step solutions, depending on whether you use TortoiseGit in addition to msysgit or not.</p> <p><strong>First solution</strong> Assumes Wi... | 64, 119, 386, 2631 | cmd, git, ssh, windows | <h1>Why git can't remember my passphrase under Windows</h1>
<p>I have just start using git and i can't get it to remember my passphrase I'm using cmd.exe elevated and my git host is github and i have create a ssh key like that guide on github</p>
<p>but i still get </p>
<pre><code>*\subnus.mvc>git push origin mas... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,892 | cmd | # Why git can't remember my passphrase under Windows
I have just start using git and i can't get it to remember my passphrase I'm using cmd.exe elevated and my git host is github and i have create a ssh key like that guide on github
but i still get
```
*\subnus.mvc>git push origin master
Enter passphrase for key '/c... | I realize that this question is coming up on two years old, but I had the same issue and several answers here did not completely answer the question for me. Here are three step-by-step solutions, depending on whether you use TortoiseGit in addition to msysgit or not.
**First solution** Assumes Windows, msysgit, and Pu... |
13314433 | Batch file to copy directories recursively | 185 | 2012-11-09 19:12:19 | <p>Is there a way to copy directories recursively inside a .bat file? Is an example of this available?</p>
| 350,371 | 57,997 | 2023-07-23 15:38:46 | 13,314,452 | 228 | 2012-11-09 19:13:41 | 44,853 | 2018-05-03 14:22:32 | https://stackoverflow.com/q/13314433 | https://stackoverflow.com/a/13314452 | <p>Look into <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy" rel="noreferrer">xcopy</a>, which will recursively copy files and subdirectories.</p>
<p>There are examples, 2/3 down the page. Of particular use is:</p>
<blockquote>
<p>To copy all the files and subdirecto... | <p>Look into <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy" rel="noreferrer">xcopy</a>, which will recursively copy files and subdirectories.</p> <p>There are examples, 2/3 down the page. Of particular use is:</p> <blockquote> <p>To copy all the files and subdirecto... | 4330, 7002 | batch-file, copy | <h1>Batch file to copy directories recursively</h1>
<p>Is there a way to copy directories recursively inside a .bat file? Is an example of this available?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,893 | cmd | # Batch file to copy directories recursively
Is there a way to copy directories recursively inside a .bat file? Is an example of this available? | Look into [xcopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy), which will recursively copy files and subdirectories.
There are examples, 2/3 down the page. Of particular use is:
> To copy all the files and subdirectories (including any empty subdirectories) from drive A to ... |
8797983 | Can a Windows batch file determine its own file name? | 173 | 2012-01-10 02:49:32 | <p>Can a Windows batch file determine its own file name?</p>
<p>For example, if I run the batch file C:\Temp\myScript.bat, is there a command within myScript.bat that can determine the string "myScript.bat"?</p>
| 152,608 | 118,228 | 2019-03-12 19:58:24 | 8,797,999 | 227 | 2012-01-10 02:51:48 | 34,397 | 2018-01-08 18:19:56 | https://stackoverflow.com/q/8797983 | https://stackoverflow.com/a/8797999 | <p>Yes. </p>
<p>Use the special <code>%0</code> variable to get the path to the current file. </p>
<p>Write <code>%~n0</code> to get just the filename without the extension.</p>
<p>Write <code>%~n0%~x0</code> to get the filename and extension.</p>
<p>Also possible to write <code>%~nx0</code> to get the filename a... | <p>Yes. </p> <p>Use the special <code>%0</code> variable to get the path to the current file. </p> <p>Write <code>%~n0</code> to get just the filename without the extension.</p> <p>Write <code>%~n0%~x0</code> to get the filename and extension.</p> <p>Also possible to write <code>%~nx0</code> to get the filename a... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Can a Windows batch file determine its own file name?</h1>
<p>Can a Windows batch file determine its own file name?</p>
<p>For example, if I run the batch file C:\Temp\myScript.bat, is there a command within myScript.bat that can determine the string "myScript.bat"?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,894 | cmd | # Can a Windows batch file determine its own file name?
Can a Windows batch file determine its own file name?
For example, if I run the batch file C:\Temp\myScript.bat, is there a command within myScript.bat that can determine the string "myScript.bat"? | Yes.
Use the special `%0` variable to get the path to the current file.
Write `%~n0` to get just the filename without the extension.
Write `%~n0%~x0` to get the filename and extension.
Also possible to write `%~nx0` to get the filename and extension. |
1794547 | How can I make an "are you sure" prompt in a Windows batch file? | 139 | 2009-11-25 04:08:46 | <p>I have a batch file that automates copying a bunch of files from one place to the other and back for me. Only thing is as much as it helps me I keep accidentally selecting that command off my command buffer and mass overwriting uncommitted changes.</p>
<p>What code would I need for my .bat file to make it output &qu... | 227,535 | 2,279,347 | 2023-06-01 06:39:13 | 1,807,318 | 227 | 2009-11-27 07:59:35 | 13,087 | 2009-11-27 07:59:35 | https://stackoverflow.com/q/1794547 | https://stackoverflow.com/a/1807318 | <p>You want something like:</p>
<pre><code>@echo off
setlocal
:PROMPT
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END
echo ... rest of file ...
:END
endlocal
</code></pre>
| <p>You want something like:</p> <pre><code>@echo off setlocal :PROMPT SET /P AREYOUSURE=Are you sure (Y/[N])? IF /I "%AREYOUSURE%" NEQ "Y" GOTO END echo ... rest of file ... :END endlocal </code></pre> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>How can I make an "are you sure" prompt in a Windows batch file?</h1>
<p>I have a batch file that automates copying a bunch of files from one place to the other and back for me. Only thing is as much as it helps me I keep accidentally selecting that command off my command buffer and mass overwriting uncommitted cha... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,895 | cmd | # How can I make an "are you sure" prompt in a Windows batch file?
I have a batch file that automates copying a bunch of files from one place to the other and back for me. Only thing is as much as it helps me I keep accidentally selecting that command off my command buffer and mass overwriting uncommitted changes.
Wh... | You want something like:
```
@echo off
setlocal
:PROMPT
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END
echo ... rest of file ...
:END
endlocal
``` |
29817447 | How to run Pip commands from CMD | 119 | 2015-04-23 08:12:49 | <p>As I understand, Python 2.7.9 comes with Pip installed, however when I try to execute a Pip command from CMD (Windows) I get the following error:</p>
<pre class="lang-none prettyprint-override"><code>'pip' is not recognized as an internal or external command, operable program or batch file.
</code></pre>
<p>When ... | 692,015 | 1,185,671 | 2024-01-18 09:55:13 | 29,817,514 | 225 | 2015-04-23 08:15:59 | 3,889,449 | 2024-01-18 09:55:13 | https://stackoverflow.com/q/29817447 | https://stackoverflow.com/a/29817514 | <p>Little side note for anyone new to Python who didn't figure it out by theirself: <a href="https://i.sstatic.net/HtYbw.png" rel="noreferrer">this should be automatic</a> when installing Python, but just in case, note that to run Python using the <code>python</code> command in Windows' CMD you must first add it to the... | <p>Little side note for anyone new to Python who didn't figure it out by theirself: <a href="https://i.sstatic.net/HtYbw.png" rel="noreferrer">this should be automatic</a> when installing Python, but just in case, note that to run Python using the <code>python</code> command in Windows' CMD you must first add it to the... | 16, 2631, 5119 | cmd, pip, python | <h1>How to run Pip commands from CMD</h1>
<p>As I understand, Python 2.7.9 comes with Pip installed, however when I try to execute a Pip command from CMD (Windows) I get the following error:</p>
<pre class="lang-none prettyprint-override"><code>'pip' is not recognized as an internal or external command, operable prog... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,896 | cmd | # How to run Pip commands from CMD
As I understand, Python 2.7.9 comes with Pip installed, however when I try to execute a Pip command from CMD (Windows) I get the following error:
```
'pip' is not recognized as an internal or external command, operable program or batch file.
```
When I type `python` I do get the fo... | Little side note for anyone new to Python who didn't figure it out by theirself: [this should be automatic](https://i.sstatic.net/HtYbw.png) when installing Python, but just in case, note that to run Python using the `python` command in Windows' CMD you must first add it to the `PATH` environment variable, as explained... |
66335300 | Cmd crashes with exit code 1 after uninstalling anaconda | 81 | 2021-02-23 14:42:32 | <h3>Problem description</h3>
<p>I got this problem in my Win10 Pro Machine. I uninstalled Anaconda because it gaves me problem with Jupyter notebook and reinstalled it. But since then I'm unable to access Command Prompt.</p>
<p>As soon as I open it it closes. I figure it out opening VSCode and reading <code>Cmd has ex... | 35,108 | 6,475,735 | 2024-07-24 07:23:09 | 66,836,989 | 223 | 2021-03-27 23:12:56 | 13,257,998 | 2021-12-25 22:41:24 | https://stackoverflow.com/q/66335300 | https://stackoverflow.com/a/66836989 | <p>The following answer was (supposedly) initially posted (but later removed) by @Mofi and I got it from the comment of @filippo-vicari. So all credits go to them, thanks for solving this issue! It took me hours to finally find their solution.</p>
<p>Enter the following command into the still working <em>powershell</em... | <p>The following answer was (supposedly) initially posted (but later removed) by @Mofi and I got it from the comment of @filippo-vicari. So all credits go to them, thanks for solving this issue! It took me hours to finally find their solution.</p> <p>Enter the following command into the still working <em>powershell</em... | 178, 2631, 14038, 92746 | anaconda, cmd, crash, uninstallation | <h1>Cmd crashes with exit code 1 after uninstalling anaconda</h1>
<h3>Problem description</h3>
<p>I got this problem in my Win10 Pro Machine. I uninstalled Anaconda because it gaves me problem with Jupyter notebook and reinstalled it. But since then I'm unable to access Command Prompt.</p>
<p>As soon as I open it it c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,897 | cmd | # Cmd crashes with exit code 1 after uninstalling anaconda
### Problem description
I got this problem in my Win10 Pro Machine. I uninstalled Anaconda because it gaves me problem with Jupyter notebook and reinstalled it. But since then I'm unable to access Command Prompt.
As soon as I open it it closes. I figure it o... | The following answer was (supposedly) initially posted (but later removed) by @Mofi and I got it from the comment of @filippo-vicari. So all credits go to them, thanks for solving this issue! It took me hours to finally find their solution.
Enter the following command into the still working *powershell* (in my case An... |
5519328 | Executing Batch File in C# | 166 | 2011-04-01 22:00:31 | <p>I'm trying to execute a batch file in C#, but I'm not getting any luck doing it.</p>
<p>I've found multiple examples on the Internet doing it, but it is not working for me.</p>
<pre><code>public void ExecuteCommand(string command)
{
int ExitCode;
ProcessStartInfo ProcessInfo;
Process Process;
Proc... | 506,156 | 615,262 | 2023-01-21 16:17:51 | 5,519,517 | 222 | 2011-04-01 22:25:59 | 282,024 | 2018-05-14 09:51:43 | https://stackoverflow.com/q/5519328 | https://stackoverflow.com/a/5519517 | <p>This should work. You could try to dump out the contents of the output and error streams in order to find out what's happening:</p>
<pre><code>static void ExecuteCommand(string command)
{
int exitCode;
ProcessStartInfo processInfo;
Process process;
processInfo = new ProcessStartInfo("cmd.exe", "/c ... | <p>This should work. You could try to dump out the contents of the output and error streams in order to find out what's happening:</p> <pre><code>static void ExecuteCommand(string command) { int exitCode; ProcessStartInfo processInfo; Process process; processInfo = new ProcessStartInfo("cmd.exe", "/c ... | 9, 5910, 7002, 9201 | batch-file, c#, process, processstartinfo | <h1>Executing Batch File in C#</h1>
<p>I'm trying to execute a batch file in C#, but I'm not getting any luck doing it.</p>
<p>I've found multiple examples on the Internet doing it, but it is not working for me.</p>
<pre><code>public void ExecuteCommand(string command)
{
int ExitCode;
ProcessStartInfo Process... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,898 | cmd | # Executing Batch File in C#
I'm trying to execute a batch file in C#, but I'm not getting any luck doing it.
I've found multiple examples on the Internet doing it, but it is not working for me.
```
public void ExecuteCommand(string command)
{
int ExitCode;
ProcessStartInfo ProcessInfo;
Process Process;
... | This should work. You could try to dump out the contents of the output and error streams in order to find out what's happening:
```
static void ExecuteCommand(string command)
{
int exitCode;
ProcessStartInfo processInfo;
Process process;
processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
... |
43767866 | SLURM `srun` vs `sbatch` and their parameters | 188 | 2017-05-03 18:49:40 | <p>I am trying to understand what the difference is between SLURM's <a href="https://slurm.schedmd.com/srun.html" rel="noreferrer"><code>srun</code></a> and <a href="https://slurm.schedmd.com/sbatch.html" rel="noreferrer"><code>sbatch</code></a> commands. I will be happy with a general explanation, rather than specific... | 123,613 | 2,593,878 | 2021-01-23 19:02:51 | 43,799,481 | 221 | 2017-05-05 07:56:23 | 1,763,614 | 2021-01-23 19:02:51 | https://stackoverflow.com/q/43767866 | https://stackoverflow.com/a/43799481 | <p>The documentation says</p>
<pre><code>srun is used to submit a job for execution in real time
</code></pre>
<p>while</p>
<pre><code>sbatch is used to submit a job script for later execution.
</code></pre>
<p>They both accept practically the same set of parameters. The main difference is that <code>srun</code> is int... | <p>The documentation says</p> <pre><code>srun is used to submit a job for execution in real time </code></pre> <p>while</p> <pre><code>sbatch is used to submit a job script for later execution. </code></pre> <p>They both accept practically the same set of parameters. The main difference is that <code>srun</code> is int... | 353, 955, 7672, 97759, 105553 | jobs, parallel-processing, sbatch, scheduler, slurm | <h1>SLURM `srun` vs `sbatch` and their parameters</h1>
<p>I am trying to understand what the difference is between SLURM's <a href="https://slurm.schedmd.com/srun.html" rel="noreferrer"><code>srun</code></a> and <a href="https://slurm.schedmd.com/sbatch.html" rel="noreferrer"><code>sbatch</code></a> commands. I will be... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,899 | cmd | # SLURM `srun` vs `sbatch` and their parameters
I am trying to understand what the difference is between SLURM's [`srun`](https://slurm.schedmd.com/srun.html) and [`sbatch`](https://slurm.schedmd.com/sbatch.html) commands. I will be happy with a general explanation, rather than specific answers to the following questi... | The documentation says
```
srun is used to submit a job for execution in real time
```
while
```
sbatch is used to submit a job script for later execution.
```
They both accept practically the same set of parameters. The main difference is that `srun` is interactive and blocking (you get the result in your terminal... |
21074863 | What is the at sign (@) in a batch file and what does it do? | 142 | 2014-01-12 12:57:27 | <p>One remotely familiar with windows/dos batch scripting will recognize this line:</p>
<pre><code>@echo off
</code></pre>
<p>For many-many days, I was happy with the sentiment that the <code>@</code> is how <code>echo off</code> is meant to be written at the top of the batch and that's it.</p>
<p>However, recently ... | 98,409 | 611,007 | 2022-02-21 16:40:45 | 21,077,142 | 211 | 2014-01-12 16:28:07 | 2,746,670 | 2016-01-15 20:59:30 | https://stackoverflow.com/q/21074863 | https://stackoverflow.com/a/21077142 | <p><strong>At symbol - @</strong></p>
<p>The <code>@ symbol</code> tells the command processor to be less verbose; to only show the output of the command without showing it being executed or any prompts associated with the execution. When used it is prepended to the beginning of the command, it is not necessary to lea... | <p><strong>At symbol - @</strong></p> <p>The <code>@ symbol</code> tells the command processor to be less verbose; to only show the output of the command without showing it being executed or any prompts associated with the execution. When used it is prepended to the beginning of the command, it is not necessary to lea... | 64, 3819, 5370, 7002, 88021 | at-sign, batch-file, dos, terminology, windows | <h1>What is the at sign (@) in a batch file and what does it do?</h1>
<p>One remotely familiar with windows/dos batch scripting will recognize this line:</p>
<pre><code>@echo off
</code></pre>
<p>For many-many days, I was happy with the sentiment that the <code>@</code> is how <code>echo off</code> is meant to be wri... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,902 | cmd | # What is the at sign (@) in a batch file and what does it do?
One remotely familiar with windows/dos batch scripting will recognize this line:
```
@echo off
```
For many-many days, I was happy with the sentiment that the `@` is how `echo off` is meant to be written at the top of the batch and that's it.
However, r... | **At symbol - @**
The `@ symbol` tells the command processor to be less verbose; to only show the output of the command without showing it being executed or any prompts associated with the execution. When used it is prepended to the beginning of the command, it is not necessary to leave a space between the "@" and the... |
51221777 | Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured | 392 | 2018-07-07 09:29:15 | <p>I am working on a <strong>Spring Boot Batch</strong> example with MongoDB and I have already started the <code>mongod</code> server.</p>
<p>When I launch my application, I am getting the error below.</p>
<p>Any pointers for this issue?</p>
<pre><code>***************************
APPLICATION FAILED TO START
*******... | 1,352,794 | 6,872,018 | 2025-12-03 21:16:15 | 52,387,470 | 210 | 2018-09-18 13:14:30 | 2,165,744 | 2023-12-21 14:46:36 | https://stackoverflow.com/q/51221777 | https://stackoverflow.com/a/52387470 | <p>check your application.properties</p>
<p>changing</p>
<pre><code>spring.datasource.driverClassName=com.mysql.jdbc.Driver
</code></pre>
<p>to</p>
<pre><code>spring.datasource.driver-class-name=com.mysql.jdbc.Driver
</code></pre>
<p>worked for me. Full config:</p>
<pre><code>spring.datasource.url=jdbc:mysql://localhos... | <p>check your application.properties</p> <p>changing</p> <pre><code>spring.datasource.driverClassName=com.mysql.jdbc.Driver </code></pre> <p>to</p> <pre><code>spring.datasource.driver-class-name=com.mysql.jdbc.Driver </code></pre> <p>worked for me. Full config:</p> <pre><code>spring.datasource.url=jdbc:mysql://localhos... | 17, 1211, 41895, 95875 | java, spring, spring-batch, spring-boot | <h1>Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured</h1>
<p>I am working on a <strong>Spring Boot Batch</strong> example with MongoDB and I have already started the <code>mongod</code> server.</p>
<p>When I launch my application, I am getting the error ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,903 | cmd | # Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured
I am working on a **Spring Boot Batch** example with MongoDB and I have already started the `mongod` server.
When I launch my application, I am getting the error below.
Any pointers for this issue?
``... | check your application.properties
changing
```
spring.datasource.driverClassName=com.mysql.jdbc.Driver
```
to
```
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
```
worked for me. Full config:
```
spring.datasource.url=jdbc:mysql://localhost:3306/db
spring.datasource.username=
spring.datasource.passwor... |
47031941 | XCOPY: Overwrite all without prompt in BATCH | 125 | 2017-10-31 09:28:41 | <p>I'm writing a batch program for copying all files <em>newer than the destination</em> from "C:\Users\ADMIN\Desktop" to "D:\Backup".</p>
<p>This code is works:</p>
<pre><code>xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H
</code></pre>
<p>However, it asks for each exi... | 355,170 | 8,376,184 | 2023-04-14 11:42:37 | 51,953,779 | 209 | 2018-08-21 17:18:59 | 8,376,184 | 2018-08-21 17:18:59 | https://stackoverflow.com/q/47031941 | https://stackoverflow.com/a/51953779 | <p>The solution is the <code>/Y</code> switch: </p>
<pre><code>xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H /Y
</code></pre>
| <p>The solution is the <code>/Y</code> switch: </p> <pre><code>xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H /Y </code></pre> | 64, 2631, 4710, 7002 | batch-file, cmd, windows, xcopy | <h1>XCOPY: Overwrite all without prompt in BATCH</h1>
<p>I'm writing a batch program for copying all files <em>newer than the destination</em> from "C:\Users\ADMIN\Desktop" to "D:\Backup".</p>
<p>This code is works:</p>
<pre><code>xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,904 | cmd | # XCOPY: Overwrite all without prompt in BATCH
I'm writing a batch program for copying all files *newer than the destination* from "C:\Users\ADMIN\Desktop" to "D:\Backup".
This code is works:
```
xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H
```
However, it asks for each existing destination file: `Overw... | The solution is the `/Y` switch:
```
xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H /Y
``` |
472692 | How to copy a directory structure but only include certain files (using windows batch files) | 132 | 2009-01-23 12:18:36 | <p>As the title says, how can I recursively copy a directory structure but only include some files. E.g given the following directory structure:</p>
<pre><code>folder1
folder2
folder3
data.zip
info.txt
abc.xyz
folder4
folder5
data.zip
somefile.exe
someotherfile.dll
</c... | 260,788 | 19,635 | 2024-11-29 01:17:12 | 472,701 | 208 | 2009-01-23 12:25:12 | 2,441 | 2013-05-22 18:04:47 | https://stackoverflow.com/q/472692 | https://stackoverflow.com/a/472701 | <p>You don't mention if it has to be batch only, but if you can use <code>ROBOCOPY</code>, try this:</p>
<pre><code>ROBOCOPY C:\Source C:\Destination data.zip info.txt /E
</code></pre>
<p>EDIT: Changed the <code>/S</code> parameter to <code>/E</code> to include empty folders.</p>
| <p>You don't mention if it has to be batch only, but if you can use <code>ROBOCOPY</code>, try this:</p> <pre><code>ROBOCOPY C:\Source C:\Destination data.zip info.txt /E </code></pre> <p>EDIT: Changed the <code>/S</code> parameter to <code>/E</code> to include empty folders.</p> | 64, 2631, 7002, 11635 | batch-file, cmd, robocopy, windows | <h1>How to copy a directory structure but only include certain files (using windows batch files)</h1>
<p>As the title says, how can I recursively copy a directory structure but only include some files. E.g given the following directory structure:</p>
<pre><code>folder1
folder2
folder3
data.zip
info.t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,905 | cmd | # How to copy a directory structure but only include certain files (using windows batch files)
As the title says, how can I recursively copy a directory structure but only include some files. E.g given the following directory structure:
```
folder1
folder2
folder3
data.zip
info.txt
abc.xyz
... | You don't mention if it has to be batch only, but if you can use `ROBOCOPY`, try this:
```
ROBOCOPY C:\Source C:\Destination data.zip info.txt /E
```
EDIT: Changed the `/S` parameter to `/E` to include empty folders. |
8922224 | Multiple commands on a single line in a Windows batch file | 121 | 2012-01-19 07:04:18 | <p>In Unix, we can put multiple commands in a single line like this:</p>
<pre><code>$ date ; ls -l ; date
</code></pre>
<p>I tried a similar thing in Windows:</p>
<pre><code> > echo %TIME% ; dir ; echo %TIME
</code></pre>
<p>But it printed the time and doesn't execute the command <code>dir</code>.</p>
<p>How ca... | 173,832 | 393,436 | 2020-11-09 23:09:15 | 8,922,307 | 200 | 2012-01-19 07:13:41 | 14,860 | 2012-01-19 07:26:05 | https://stackoverflow.com/q/8922224 | https://stackoverflow.com/a/8922307 | <p>Use:</p>
<pre><code>echo %time% & dir & echo %time%
</code></pre>
<p>This is, from memory, equivalent to the semi-colon separator in <code>bash</code> and other UNIXy shells.</p>
<p>There's also <code>&&</code> (or <code>||</code>) which only executes the second command if the first succeeded (or ... | <p>Use:</p> <pre><code>echo %time% & dir & echo %time% </code></pre> <p>This is, from memory, equivalent to the semi-colon separator in <code>bash</code> and other UNIXy shells.</p> <p>There's also <code>&&</code> (or <code>||</code>) which only executes the second command if the first succeeded (or ... | 64, 7002 | batch-file, windows | <h1>Multiple commands on a single line in a Windows batch file</h1>
<p>In Unix, we can put multiple commands in a single line like this:</p>
<pre><code>$ date ; ls -l ; date
</code></pre>
<p>I tried a similar thing in Windows:</p>
<pre><code> > echo %TIME% ; dir ; echo %TIME
</code></pre>
<p>But it printed the t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,906 | cmd | # Multiple commands on a single line in a Windows batch file
In Unix, we can put multiple commands in a single line like this:
```
$ date ; ls -l ; date
```
I tried a similar thing in Windows:
```
> echo %TIME% ; dir ; echo %TIME
```
But it printed the time and doesn't execute the command `dir`.
How can I achiev... | Use:
```
echo %time% & dir & echo %time%
```
This is, from memory, equivalent to the semi-colon separator in `bash` and other UNIXy shells.
There's also `&&` (or `||`) which only executes the second command if the first succeeded (or failed), but the single ampersand `&` is what you're looking for here.
---
That's... |
3803581 | Setting a system environment variable from a Windows batch file? | 232 | 2010-09-27 12:07:27 | <p>Is it possible to set a environment variable at the system level from a command prompt in Windows 7 (or even XP for that matter). I am running from an elevated command prompt.</p>
<p>When I use the <code>set</code> command (<code>set name=value</code>), the environment variable seems to be only valid for the sessio... | 429,674 | 184,774 | 2022-10-22 12:23:06 | 3,804,979 | 199 | 2010-09-27 14:49:07 | 15,069 | 2010-09-27 14:49:07 | https://stackoverflow.com/q/3803581 | https://stackoverflow.com/a/3804979 | <p>The XP Support Tools (which can be installed from your XP CD) come with a program called <code>setx.exe</code>:</p>
<pre><code>C:\Program Files\Support Tools>setx /?
SETX: This program is used to set values in the environment
of the machine or currently logged on user using one of three modes.
1) Command Line ... | <p>The XP Support Tools (which can be installed from your XP CD) come with a program called <code>setx.exe</code>:</p> <pre><code>C:\Program Files\Support Tools>setx /? SETX: This program is used to set values in the environment of the machine or currently logged on user using one of three modes. 1) Command Line ... | 64, 2631, 7002, 9013 | batch-file, cmd, environment-variables, windows | <h1>Setting a system environment variable from a Windows batch file?</h1>
<p>Is it possible to set a environment variable at the system level from a command prompt in Windows 7 (or even XP for that matter). I am running from an elevated command prompt.</p>
<p>When I use the <code>set</code> command (<code>set name=val... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,907 | cmd | # Setting a system environment variable from a Windows batch file?
Is it possible to set a environment variable at the system level from a command prompt in Windows 7 (or even XP for that matter). I am running from an elevated command prompt.
When I use the `set` command (`set name=value`), the environment variable s... | The XP Support Tools (which can be installed from your XP CD) come with a program called `setx.exe`:
```
C:\Program Files\Support Tools>setx /?
SETX: This program is used to set values in the environment
of the machine or currently logged on user using one of three modes.
1) Command Line Mode: setx variable value [-... |
2730643 | How to execute programs in the same directory as the windows batch file? | 99 | 2010-04-28 15:02:51 | <p>I have in the same folder a <code>.bat</code> and a <code>.exe</code> file.
I couldn't call the <code>.exe</code> file from the <code>.bat</code> unless I put the full absolute path to it.
Is there a way to don't specify the path?</p>
| 152,210 | 48,465 | 2022-12-17 14:56:17 | 2,730,717 | 199 | 2010-04-28 15:10:36 | 7,903 | 2010-04-28 15:10:36 | https://stackoverflow.com/q/2730643 | https://stackoverflow.com/a/2730717 | <p>Try calling the <code>.exe</code> with <code>%~dp0</code>, like this: <code>%~dp0MyProgram.exe</code>.</p>
<p><code>%0</code> contains the full path to the called <code>.bat</code> file.</p>
<p><code>~dp</code> says to get the drive and path, including trailing <code>\</code>.</p>
| <p>Try calling the <code>.exe</code> with <code>%~dp0</code>, like this: <code>%~dp0MyProgram.exe</code>.</p> <p><code>%0</code> contains the full path to the called <code>.bat</code> file.</p> <p><code>~dp</code> says to get the drive and path, including trailing <code>\</code>.</p> | 64, 6268, 7002, 8877 | batch-file, path, relative-path, windows | <h1>How to execute programs in the same directory as the windows batch file?</h1>
<p>I have in the same folder a <code>.bat</code> and a <code>.exe</code> file.
I couldn't call the <code>.exe</code> file from the <code>.bat</code> unless I put the full absolute path to it.
Is there a way to don't specify the path?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,908 | cmd | # How to execute programs in the same directory as the windows batch file?
I have in the same folder a `.bat` and a `.exe` file.
I couldn't call the `.exe` file from the `.bat` unless I put the full absolute path to it.
Is there a way to don't specify the path? | Try calling the `.exe` with `%~dp0`, like this: `%~dp0MyProgram.exe`.
`%0` contains the full path to the called `.bat` file.
`~dp` says to get the drive and path, including trailing `\`. |
3325081 | How to check if a service is running via batch file and start it, if it is not running? | 118 | 2010-07-24 12:28:44 | <p>I want to write a batch file that performs the following operations: </p>
<ul>
<li>Check if a service is running
<ul>
<li>If is it running, quit the batch </li>
<li>If it is not running, start the service </li>
</ul></li>
</ul>
<p>The code samples I googled so far turned out not to be working, so I decided no... | 430,674 | 225,808 | 2024-10-02 09:34:10 | 3,325,123 | 198 | 2010-07-24 12:45:45 | 44,853 | 2019-04-16 08:28:44 | https://stackoverflow.com/q/3325081 | https://stackoverflow.com/a/3325123 | <p>To check a service's state, use <code>sc query <SERVICE_NAME></code>. For if blocks in batch files, <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if" rel="noreferrer">check the documentation</a>.</p>
<p>The following code will check the status of the service <code>M... | <p>To check a service's state, use <code>sc query <SERVICE_NAME></code>. For if blocks in batch files, <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if" rel="noreferrer">check the documentation</a>.</p> <p>The following code will check the status of the service <code>M... | 64, 2596, 7002, 9299 | batch-file, scheduled-tasks, windows, windows-services | <h1>How to check if a service is running via batch file and start it, if it is not running?</h1>
<p>I want to write a batch file that performs the following operations: </p>
<ul>
<li>Check if a service is running
<ul>
<li>If is it running, quit the batch </li>
<li>If it is not running, start the service </li>
</u... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,909 | cmd | # How to check if a service is running via batch file and start it, if it is not running?
I want to write a batch file that performs the following operations:
- Check if a service is running
- If is it running, quit the batch
- If it is not running, start the service
The code samples I googled so far turned out ... | To check a service's state, use `sc query <SERVICE_NAME>`. For if blocks in batch files, [check the documentation](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if).
The following code will check the status of the service `MyServiceName` and start it if it is not running (the if bloc... |
5138507 | How to change current working directory using a batch file | 136 | 2011-02-28 05:24:06 | <p>I need some help in writing a batch file.
I have a path stored in a variable root as follows:</p>
<pre><code>set root=D:\Work\Root
</code></pre>
<p>Then I am changing my working directory to this root as follows:</p>
<pre><code>cd %root%
</code></pre>
<p>When I execute this batch file from anywhere on the D driv... | 428,755 | 600,102 | 2022-11-01 23:09:33 | 5,138,524 | 195 | 2011-02-28 05:27:10 | 297,408 | 2011-02-28 05:27:10 | https://stackoverflow.com/q/5138507 | https://stackoverflow.com/a/5138524 | <p>Specify <code>/D</code> to change the drive also.</p>
<pre><code>CD /D %root%
</code></pre>
| <p>Specify <code>/D</code> to change the drive also.</p> <pre><code>CD /D %root% </code></pre> | 218, 7002, 9056, 9938 | batch-file, command-prompt, directory, drive | <h1>How to change current working directory using a batch file</h1>
<p>I need some help in writing a batch file.
I have a path stored in a variable root as follows:</p>
<pre><code>set root=D:\Work\Root
</code></pre>
<p>Then I am changing my working directory to this root as follows:</p>
<pre><code>cd %root%
</code><... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,910 | cmd | # How to change current working directory using a batch file
I need some help in writing a batch file.
I have a path stored in a variable root as follows:
```
set root=D:\Work\Root
```
Then I am changing my working directory to this root as follows:
```
cd %root%
```
When I execute this batch file from anywhere on... | Specify `/D` to change the drive also.
```
CD /D %root%
``` |
830565 | How can I check if an argument is defined when starting/calling a batch file? | 122 | 2009-05-06 16:45:11 | <p>I'm trying to use the following validation logic in a batch file but the "usage" block never executes even when no parameter is supplied to the batch file.</p>
<pre><code>if ("%1"=="") goto usage
@echo This should not execute
@echo Done.
goto :eof
:usage
@echo Usage: %0 <EnvironmentName>
exit 1
</code></pr... | 159,512 | 5,975 | 2023-08-24 14:40:23 | 830,566 | 194 | 2009-05-06 16:45:37 | 5,993 | 2017-11-05 16:46:55 | https://stackoverflow.com/q/830565 | https://stackoverflow.com/a/830566 | <p>The check for whether a commandline argument has been set can be <code>[%1]==[]</code>, but, as <a href="https://stackoverflow.com/users/6568/dave-costa">Dave Costa</a> <a href="https://stackoverflow.com/questions/830565/how-do-i-check-that-a-parameter-is-defined-when-calling-a-batch-file/830593#830593">points out</... | <p>The check for whether a commandline argument has been set can be <code>[%1]==[]</code>, but, as <a href="https://stackoverflow.com/users/6568/dave-costa">Dave Costa</a> <a href="https://stackoverflow.com/questions/830565/how-do-i-check-that-a-parameter-is-defined-when-calling-a-batch-file/830593#830593">points out</... | 2313, 7002 | arguments, batch-file | <h1>How can I check if an argument is defined when starting/calling a batch file?</h1>
<p>I'm trying to use the following validation logic in a batch file but the "usage" block never executes even when no parameter is supplied to the batch file.</p>
<pre><code>if ("%1"=="") goto usage
@echo This should not execute
@... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,911 | cmd | # How can I check if an argument is defined when starting/calling a batch file?
I'm trying to use the following validation logic in a batch file but the "usage" block never executes even when no parameter is supplied to the batch file.
```
if ("%1"=="") goto usage
@echo This should not execute
@echo Done.
goto :eof... | The check for whether a commandline argument has been set can be `[%1]==[]`, but, as [Dave Costa](https://stackoverflow.com/users/6568/dave-costa) [points out](https://stackoverflow.com/questions/830565/how-do-i-check-that-a-parameter-is-defined-when-calling-a-batch-file/830593#830593), `"%1"==""` will also work.
I al... |
34286515 | How to install Visual Studio Code extensions from Command line | 121 | 2015-12-15 10:18:34 | <p>How to install Visual Studio Code Extensions from Command Prompt while Code Instance is open.
I want to install extension from Visual Studio Code gallery.</p>
<p>Following is the extension data i want to install.</p>
<p><a href="https://i.sstatic.net/CrSqV.png" rel="noreferrer"><img src="https://i.sstatic.net/CrSqV.... | 133,816 | 1,931,605 | 2025-03-17 14:48:40 | 34,339,780 | 194 | 2015-12-17 16:36:50 | 1,931,605 | 2023-09-15 09:27:12 | https://stackoverflow.com/q/34286515 | https://stackoverflow.com/a/34339780 | <blockquote>
<p>To make it easier to automate and configure VS Code, it is possible to list, install, and uninstall extensions from the command line. When identifying an extension, provide the full name of the form publisher.extension, for example donjayamanne.python.</p>
</blockquote>
<pre><code>code --list-extensions... | <blockquote> <p>To make it easier to automate and configure VS Code, it is possible to list, install, and uninstall extensions from the command line. When identifying an extension, provide the full name of the form publisher.extension, for example donjayamanne.python.</p> </blockquote> <pre><code>code --list-extensions... | 2631, 111608 | cmd, visual-studio-code | <h1>How to install Visual Studio Code extensions from Command line</h1>
<p>How to install Visual Studio Code Extensions from Command Prompt while Code Instance is open.
I want to install extension from Visual Studio Code gallery.</p>
<p>Following is the extension data i want to install.</p>
<p><a href="https://i.sstati... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,912 | cmd | # How to install Visual Studio Code extensions from Command line
How to install Visual Studio Code Extensions from Command Prompt while Code Instance is open.
I want to install extension from Visual Studio Code gallery.
Following is the extension data i want to install.
[.
... | 344,430 | 37,804 | 2024-06-13 19:58:33 | 616,014 | 194 | 2009-03-05 18:35:47 | 33,857 | 2017-08-07 22:53:05 | https://stackoverflow.com/q/615948 | https://stackoverflow.com/a/616014 | <p>Batch files are not an executable. They need an application to run them (i.e. cmd).</p>
<p>On UNIX, the script file has shebang (#!) at the start of a file to specify the program that executes it. Double-clicking in Windows is performed by Windows Explorer. <code>CreateProcess</code> does not know anything about... | <p>Batch files are not an executable. They need an application to run them (i.e. cmd).</p> <p>On UNIX, the script file has shebang (#!) at the start of a file to specify the program that executes it. Double-clicking in Windows is performed by Windows Explorer. <code>CreateProcess</code> does not know anything about... | 17, 7002, 9077 | batch-file, java, runtime.exec | <h1>How do I run a batch file from my Java Application?</h1>
<p>In my Java application, I want to run a batch file that calls "<code>scons -Q implicit-deps-changed build\file_load_type export\file_load_type</code>"</p>
<p>It seems that I can't even get my batch file to execute. I'm out of ideas. </p>
<p>This is what ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,913 | cmd | # How do I run a batch file from my Java Application?
In my Java application, I want to run a batch file that calls "`scons -Q implicit-deps-changed build\file_load_type export\file_load_type`"
It seems that I can't even get my batch file to execute. I'm out of ideas.
This is what I have in Java:
```
Runtime.
ge... | Batch files are not an executable. They need an application to run them (i.e. cmd).
On UNIX, the script file has shebang (#!) at the start of a file to specify the program that executes it. Double-clicking in Windows is performed by Windows Explorer. `CreateProcess` does not know anything about that.
```
Runtime.
... |
4355046 | Java: Insert multiple rows into MySQL with PreparedStatement | 96 | 2010-12-04 18:20:16 | <p>I want to insert multiple rows into a MySQL table at once using Java. The number of rows is dynamic. In the past I was doing...</p>
<pre><code>for (String element : array) {
myStatement.setString(1, element[0]);
myStatement.setString(2, element[1]);
myStatement.executeUpdate();
}
</code></pre>
<p>I'd ... | 195,286 | 450,164 | 2021-12-02 18:17:37 | 4,355,097 | 194 | 2010-12-04 18:30:44 | 157,882 | 2015-06-09 20:00:31 | https://stackoverflow.com/q/4355046 | https://stackoverflow.com/a/4355097 | <p>You can create a batch by <a href="http://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html#addBatch--" rel="noreferrer"><code>PreparedStatement#addBatch()</code></a> and execute it by <a href="http://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#executeBatch--" rel="noreferrer"><code>Pre... | <p>You can create a batch by <a href="http://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html#addBatch--" rel="noreferrer"><code>PreparedStatement#addBatch()</code></a> and execute it by <a href="http://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#executeBatch--" rel="noreferrer"><code>Pre... | 17, 21, 5617, 10898, 58566 | batch-insert, java, jdbc, mysql, prepared-statement | <h1>Java: Insert multiple rows into MySQL with PreparedStatement</h1>
<p>I want to insert multiple rows into a MySQL table at once using Java. The number of rows is dynamic. In the past I was doing...</p>
<pre><code>for (String element : array) {
myStatement.setString(1, element[0]);
myStatement.setString(2, e... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,914 | cmd | # Java: Insert multiple rows into MySQL with PreparedStatement
I want to insert multiple rows into a MySQL table at once using Java. The number of rows is dynamic. In the past I was doing...
```
for (String element : array) {
myStatement.setString(1, element[0]);
myStatement.setString(2, element[1]);
myS... | You can create a batch by [`PreparedStatement#addBatch()`](http://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html#addBatch--) and execute it by [`PreparedStatement#executeBatch()`](http://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#executeBatch--).
Here's a kickoff example:
```
public ... |
16945780 | Decoding base64 in batch | 99 | 2013-06-05 17:02:18 | <p>I am trying to make an installer using batch. Of course, an installer needs to consist of files that will be installed, so I'm thinking of encoding the files in base64, and simply decode them and write them to their destination.</p>
<p>Of course, my work would be very easy if Windows had something like the <code>ba... | 159,465 | null | 2019-05-16 13:46:20 | 16,946,681 | 193 | 2013-06-05 17:55:02 | 1,012,053 | 2019-05-16 13:46:20 | https://stackoverflow.com/q/16945780 | https://stackoverflow.com/a/16946681 | <p>Actually Windows does have a utility that encodes and decodes base64 - CERTUTIL</p>
<p>I'm not sure what version of Windows introduced this command.</p>
<p>To encode a file:</p>
<pre><code>certutil -encode inputFileName encodedOutputFileName
</code></pre>
<p>To decode a file:</p>
<pre><code>certutil -decode encodedI... | <p>Actually Windows does have a utility that encodes and decodes base64 - CERTUTIL</p> <p>I'm not sure what version of Windows introduced this command.</p> <p>To encode a file:</p> <pre><code>certutil -encode inputFileName encodedOutputFileName </code></pre> <p>To decode a file:</p> <pre><code>certutil -decode encodedI... | 64, 1011, 7002 | base64, batch-file, windows | <h1>Decoding base64 in batch</h1>
<p>I am trying to make an installer using batch. Of course, an installer needs to consist of files that will be installed, so I'm thinking of encoding the files in base64, and simply decode them and write them to their destination.</p>
<p>Of course, my work would be very easy if Windo... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,915 | cmd | # Decoding base64 in batch
I am trying to make an installer using batch. Of course, an installer needs to consist of files that will be installed, so I'm thinking of encoding the files in base64, and simply decode them and write them to their destination.
Of course, my work would be very easy if Windows had something... | Actually Windows does have a utility that encodes and decodes base64 - CERTUTIL
I'm not sure what version of Windows introduced this command.
To encode a file:
```
certutil -encode inputFileName encodedOutputFileName
```
To decode a file:
```
certutil -decode encodedInputFileName decodedOutputFileName
```
There a... |
14509652 | What is the difference between % and %% in a cmd file? | 117 | 2013-01-24 19:57:46 | <p>I recently included a line similar to this in a .cmd file:</p>
<pre><code>for /f %%f in ('dir /b .\directory\*.sql') DO sqlcmd -b -o ".\directory\output\%%f.txt" -i ".\directory\%%f"
</code></pre>
<p>Originally I had only used %f, and it would work fine when run on the command line, but not when run through the fi... | 192,769 | 1,854,699 | 2019-09-05 10:41:35 | 14,510,117 | 191 | 2013-01-24 20:27:24 | 63,733 | 2018-05-16 08:22:17 | https://stackoverflow.com/q/14509652 | https://stackoverflow.com/a/14510117 | <p><em>(Explanation in more details can be found in <a href="https://jeffpar.github.io/kbarchive/kb/075/Q75634/" rel="noreferrer">an archived Microsoft KB article</a>.)</em></p>
<p>Three things to know:</p>
<ol>
<li>The percent sign is used in batch files to represent command line parameters: <code>%1</code>, <code>%... | <p><em>(Explanation in more details can be found in <a href="https://jeffpar.github.io/kbarchive/kb/075/Q75634/" rel="noreferrer">an archived Microsoft KB article</a>.)</em></p> <p>Three things to know:</p> <ol> <li>The percent sign is used in batch files to represent command line parameters: <code>%1</code>, <code>%... | 2631, 7002 | batch-file, cmd | <h1>What is the difference between % and %% in a cmd file?</h1>
<p>I recently included a line similar to this in a .cmd file:</p>
<pre><code>for /f %%f in ('dir /b .\directory\*.sql') DO sqlcmd -b -o ".\directory\output\%%f.txt" -i ".\directory\%%f"
</code></pre>
<p>Originally I had only used %f, and it would work fi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,916 | cmd | # What is the difference between % and %% in a cmd file?
I recently included a line similar to this in a .cmd file:
```
for /f %%f in ('dir /b .\directory\*.sql') DO sqlcmd -b -o ".\directory\output\%%f.txt" -i ".\directory\%%f"
```
Originally I had only used %f, and it would work fine when run on the command line, ... | *(Explanation in more details can be found in [an archived Microsoft KB article](https://jeffpar.github.io/kbarchive/kb/075/Q75634/).)*
Three things to know:
1. The percent sign is used in batch files to represent command line parameters: `%1`, `%2`, ...
2. Two percent signs with any characters in between them are in... |
13719174 | How to execute multiple commands in a single line | 91 | 2012-12-05 08:40:49 | <p>I know Unix has the following command which can execute multiple commands in a single line, how can I do this in DOS?</p>
<pre><code>command1 ; command2 ; command3 ...
</code></pre>
| 118,115 | 1,487,475 | 2016-08-03 14:03:48 | 13,719,223 | 191 | 2012-12-05 08:44:29 | 1,841,627 | 2013-06-16 16:57:18 | https://stackoverflow.com/q/13719174 | https://stackoverflow.com/a/13719223 | <p>Googling gives me this: </p>
<hr>
<p><strong><code>Command A & Command B</code></strong> </p>
<p>Execute <em>Command A</em>, then execute <em>Command B</em> (no evaluation of anything)</p>
<hr>
<p><strong><code>Command A | Command B</code></strong> </p>
<p>Execute <em>Command A</em>, and redirect all its ... | <p>Googling gives me this: </p> <hr> <p><strong><code>Command A & Command B</code></strong> </p> <p>Execute <em>Command A</em>, then execute <em>Command B</em> (no evaluation of anything)</p> <hr> <p><strong><code>Command A | Command B</code></strong> </p> <p>Execute <em>Command A</em>, and redirect all its ... | 64, 2631 | cmd, windows | <h1>How to execute multiple commands in a single line</h1>
<p>I know Unix has the following command which can execute multiple commands in a single line, how can I do this in DOS?</p>
<pre><code>command1 ; command2 ; command3 ...
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,917 | cmd | # How to execute multiple commands in a single line
I know Unix has the following command which can execute multiple commands in a single line, how can I do this in DOS?
```
command1 ; command2 ; command3 ...
``` | Googling gives me this:
---
**`Command A & Command B`**
Execute *Command A*, then execute *Command B* (no evaluation of anything)
---
**`Command A | Command B`**
Execute *Command A*, and redirect all its output into the input of *Command B*
---
**`Command A && Command B`**
Execute *Command A*, evaluate the err... |
251557 | Escape angle brackets in a Windows command prompt | 115 | 2008-10-30 20:03:34 | <p>I need to echo a string containing angle brackets (< and >) to a file on a Windows machine. Basically what I want to do is the following:<br>
<code>echo some string < with angle > brackets >>myfile.txt</code></p>
<p>This doesn't work since the command interpreter gets confused with the angle bracket... | 54,182 | 26,302 | 2020-06-17 18:57:11 | 251,573 | 189 | 2008-10-30 20:10:40 | 32,133 | 2008-10-30 20:10:40 | https://stackoverflow.com/q/251557 | https://stackoverflow.com/a/251573 | <p>The Windows escape character is ^, for some reason.</p>
<pre><code>echo some string ^< with angle ^> brackets >>myfile.txt
</code></pre>
| <p>The Windows escape character is ^, for some reason.</p> <pre><code>echo some string ^< with angle ^> brackets >>myfile.txt </code></pre> | 64, 2631, 4804 | cmd, escaping, windows | <h1>Escape angle brackets in a Windows command prompt</h1>
<p>I need to echo a string containing angle brackets (< and >) to a file on a Windows machine. Basically what I want to do is the following:<br>
<code>echo some string < with angle > brackets >>myfile.txt</code></p>
<p>This doesn't work since t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,918 | cmd | # Escape angle brackets in a Windows command prompt
I need to echo a string containing angle brackets (< and >) to a file on a Windows machine. Basically what I want to do is the following:
`echo some string < with angle > brackets >>myfile.txt`
This doesn't work since the command interpreter gets confused with the... | The Windows escape character is ^, for some reason.
```
echo some string ^< with angle ^> brackets >>myfile.txt
``` |
14498539 | How to overlay/downmix two audio files using ffmpeg | 109 | 2013-01-24 10:02:36 | <p>Can I overlay/downmix two audio mp3 files into one mp3 output file using ffmpeg?</p>
| 98,253 | 2,007,013 | 2020-01-07 15:00:43 | 14,528,482 | 189 | 2013-01-25 18:52:16 | 1,109,017 | 2019-06-12 20:13:37 | https://stackoverflow.com/q/14498539 | https://stackoverflow.com/a/14528482 | <h1>stereo + stereo → stereo</h1>
<h3>Normal downmix</h3>
<p><a href="https://i.sstatic.net/99nCo.png" rel="noreferrer"><img src="https://i.sstatic.net/99nCo.png" alt="Normal downmix"></a></p>
<p>Use the <a href="https://ffmpeg.org/ffmpeg-filters.html#amix" rel="noreferrer">amix</a> filter:</p>
<pre><code>ffmpeg -i... | <h1>stereo + stereo → stereo</h1> <h3>Normal downmix</h3> <p><a href="https://i.sstatic.net/99nCo.png" rel="noreferrer"><img src="https://i.sstatic.net/99nCo.png" alt="Normal downmix"></a></p> <p>Use the <a href="https://ffmpeg.org/ffmpeg-filters.html#amix" rel="noreferrer">amix</a> filter:</p> <pre><code>ffmpeg -i... | 348, 1033, 2631, 3847 | audio, cmd, ffmpeg, mp3 | <h1>How to overlay/downmix two audio files using ffmpeg</h1>
<p>Can I overlay/downmix two audio mp3 files into one mp3 output file using ffmpeg?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,919 | cmd | # How to overlay/downmix two audio files using ffmpeg
Can I overlay/downmix two audio mp3 files into one mp3 output file using ffmpeg? | # stereo + stereo → stereo
### Normal downmix
[](https://i.sstatic.net/99nCo.png)
Use the [amix](https://ffmpeg.org/ffmpeg-filters.html#amix) filter:
```
ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amix=inputs=2:duration=longest output.mp3
```
Or the [amerge... |
17302977 | How To Launch Git Bash from Windows Command Line? | 170 | 2013-06-25 16:44:07 | <p>I've got what I'm hoping is a simple question, but I haven't been able to find the answer yet. I would like to launch Git Bash from a Windows batch file. Here is what I tried so far:</p>
<ol>
<li><p>Launched Git Bash from Win 7 Start button</p>
</li>
<li><p>Used CTRL+ALT+DEL to identify the process as "sh.exe... | 353,106 | 1,316,396 | 2025-02-18 03:23:36 | 17,306,604 | 188 | 2013-06-25 20:11:06 | 2,098,699 | 2023-05-05 22:13:27 | https://stackoverflow.com/q/17302977 | https://stackoverflow.com/a/17306604 |
<p>If you want to launch from a batch file:</p>
<ul>
<li><p>for x86</p>
<pre class="lang-bash prettyprint-override"><code> start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login
</code></pre>
</li>
<li><p>for x64</p>
<pre class="lang-bash prettyprint-override"><code> start "&quo... | <p>If you want to launch from a batch file:</p> <ul> <li><p>for x86</p> <pre class="lang-bash prettyprint-override"><code> start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login </code></pre> </li> <li><p>for x64</p> <pre class="lang-bash prettyprint-override"><code> start "&quo... | 64, 119, 1796, 2631, 7002 | batch-file, cmd, command, git, windows | <h1>How To Launch Git Bash from Windows Command Line?</h1>
<p>I've got what I'm hoping is a simple question, but I haven't been able to find the answer yet. I would like to launch Git Bash from a Windows batch file. Here is what I tried so far:</p>
<ol>
<li><p>Launched Git Bash from Win 7 Start button</p>
</li>
<li><... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,920 | cmd | # How To Launch Git Bash from Windows Command Line?
I've got what I'm hoping is a simple question, but I haven't been able to find the answer yet. I would like to launch Git Bash from a Windows batch file. Here is what I tried so far:
1. Launched Git Bash from Win 7 Start button
2. Used CTRL+ALT+DEL to identify the p... | If you want to launch from a batch file:
- for x86
```
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login
```
- for x64
```
start "" "%PROGRAMFILES%\Git\bin\sh.exe" --login
``` |
8759433 | Windows batch command to ignore case sensitivity in variables | 90 | 2012-01-06 14:36:03 | <p>I have a set of variables I allow some people I work with to edit. These are True (<code>T</code>) and False (<code>F</code>) values, but I have some people that insist on putting <code>t</code> and <code>f</code> instead of the upper case values respectively. </p>
<p>I use the following workaround code to properly... | 91,130 | 1,010,904 | 2017-08-13 07:29:13 | 8,759,981 | 187 | 2012-01-06 15:14:41 | 30,447 | 2017-08-13 07:29:13 | https://stackoverflow.com/q/8759433 | https://stackoverflow.com/a/8759981 | <p>Read <code>HELP IF</code> : <em>the <code>/I</code> switch, if specified, says to do case insensitive string compares. The <code>/I</code> switch can also be used on the string1==string2 form
of IF.</em></p>
<p>So try <code>IF /I %SSL%==F ...</code></p>
| <p>Read <code>HELP IF</code> : <em>the <code>/I</code> switch, if specified, says to do case insensitive string compares. The <code>/I</code> switch can also be used on the string1==string2 form of IF.</em></p> <p>So try <code>IF /I %SSL%==F ...</code></p> | 276, 4162, 7002, 9708 | batch-file, case-sensitive, code-formatting, variables | <h1>Windows batch command to ignore case sensitivity in variables</h1>
<p>I have a set of variables I allow some people I work with to edit. These are True (<code>T</code>) and False (<code>F</code>) values, but I have some people that insist on putting <code>t</code> and <code>f</code> instead of the upper case values... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,921 | cmd | # Windows batch command to ignore case sensitivity in variables
I have a set of variables I allow some people I work with to edit. These are True (`T`) and False (`F`) values, but I have some people that insist on putting `t` and `f` instead of the upper case values respectively.
I use the following workaround code t... | Read `HELP IF` : *the `/I` switch, if specified, says to do case insensitive string compares. The `/I` switch can also be used on the string1==string2 form
of IF.*
So try `IF /I %SSL%==F ...` |
4953170 | How to check command line parameter in ".bat" file? | 136 | 2011-02-10 03:52:26 | <p>My OS is Windows Vista. I need to have a ".bat" file where I need to check if user enters any command-line parameter or not. If does then if the parameter equals to <code>-b</code> then I will do something otherwise I will flag "Invalid input". If user does not enter any command-line parameter then I will do some... | 274,338 | 476,235 | 2023-02-13 11:42:32 | 4,953,224 | 186 | 2011-02-10 04:01:29 | 320,333 | 2017-10-26 17:12:38 | https://stackoverflow.com/q/4953170 | https://stackoverflow.com/a/4953224 | <p>You need to check for the parameter being blank: <code>if "%~1"=="" goto blank</code></p>
<p>Once you've done that, then do an if/else switch on -b: <code>if "%~1"=="-b" (goto specific) else goto unknown</code></p>
<p>Surrounding the parameters with quotes makes checking for things like blank/empty/missing parame... | <p>You need to check for the parameter being blank: <code>if "%~1"=="" goto blank</code></p> <p>Once you've done that, then do an if/else switch on -b: <code>if "%~1"=="-b" (goto specific) else goto unknown</code></p> <p>Surrounding the parameters with quotes makes checking for things like blank/empty/missing parame... | 64, 2631, 5310, 7002 | batch-file, cmd, file, windows | <h1>How to check command line parameter in ".bat" file?</h1>
<p>My OS is Windows Vista. I need to have a ".bat" file where I need to check if user enters any command-line parameter or not. If does then if the parameter equals to <code>-b</code> then I will do something otherwise I will flag "Invalid input". If user ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,922 | cmd | # How to check command line parameter in ".bat" file?
My OS is Windows Vista. I need to have a ".bat" file where I need to check if user enters any command-line parameter or not. If does then if the parameter equals to `-b` then I will do something otherwise I will flag "Invalid input". If user does not enter any comm... | You need to check for the parameter being blank: `if "%~1"=="" goto blank`
Once you've done that, then do an if/else switch on -b: `if "%~1"=="-b" (goto specific) else goto unknown`
Surrounding the parameters with quotes makes checking for things like blank/empty/missing parameters easier. "~" ensures double quotes a... |
245395 | Hidden features of Windows batch files | 232 | 2008-10-29 00:34:22 | <p>What are some of the lesser know, but important and useful features of Windows batch files?</p>
<p>Guidelines:</p>
<ul>
<li>One feature per answer</li>
<li>Give both a short <strong>description</strong> of the feature and an <strong>example</strong>, not just a link to documentation</li>
<li>Limit answers to <stro... | 229,316 | 14,749 | 2023-05-04 02:11:56 | 245,434 | 185 | 2008-10-29 00:50:52 | 14,749 | 2010-08-07 18:00:54 | https://stackoverflow.com/q/245395 | https://stackoverflow.com/a/245434 | <p>Line continuation:</p>
<pre><code>call C:\WINDOWS\system32\ntbackup.exe ^
backup ^
/V:yes ^
/R:no ^
/RS:no ^
/HC:off ^
/M normal ^
/L:s ^
@daily.bks ^
/F daily.bkf
</code></pre>
| <p>Line continuation:</p> <pre><code>call C:\WINDOWS\system32\ntbackup.exe ^ backup ^ /V:yes ^ /R:no ^ /RS:no ^ /HC:off ^ /M normal ^ /L:s ^ @daily.bks ^ /F daily.bkf </code></pre> | 64, 5073, 7002 | batch-file, hidden-features, windows | <h1>Hidden features of Windows batch files</h1>
<p>What are some of the lesser know, but important and useful features of Windows batch files?</p>
<p>Guidelines:</p>
<ul>
<li>One feature per answer</li>
<li>Give both a short <strong>description</strong> of the feature and an <strong>example</strong>, not just a link ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,923 | cmd | # Hidden features of Windows batch files
What are some of the lesser know, but important and useful features of Windows batch files?
Guidelines:
- One feature per answer
- Give both a short **description** of the feature and an **example**, not just a link to documentation
- Limit answers to **native funtionality**,... | Line continuation:
```
call C:\WINDOWS\system32\ntbackup.exe ^
backup ^
/V:yes ^
/R:no ^
/RS:no ^
/HC:off ^
/M normal ^
/L:s ^
@daily.bks ^
/F daily.bkf
``` |
10945572 | Windows batch: formatted date into variable | 127 | 2012-06-08 08:40:14 | <p>How do I save the current date in YYYY-MM-DD format into some variable in a Windows .bat file?</p>
<p>Unix shell analogue:</p>
<pre><code>today=`date +%F`
echo $today
</code></pre>
| 295,424 | 1,308,194 | 2020-05-18 04:04:09 | 10,945,887 | 185 | 2012-06-08 09:02:34 | 73,070 | 2014-10-29 13:31:35 | https://stackoverflow.com/q/10945572 | https://stackoverflow.com/a/10945887 | <p>You can get the current date in a locale-agnostic way using</p>
<pre><code>for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate=%%x
</code></pre>
<p>Then you can extract the individual parts using substrings:</p>
<pre><code>set today=%MyDate:~0,4%-%MyDate:~4,2%-%MyDate:~6,2%
</... | <p>You can get the current date in a locale-agnostic way using</p> <pre><code>for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate=%%x </code></pre> <p>Then you can extract the individual parts using substrings:</p> <pre><code>set today=%MyDate:~0,4%-%MyDate:~4,2%-%MyDate:~6,2% </... | 64, 7002 | batch-file, windows | <h1>Windows batch: formatted date into variable</h1>
<p>How do I save the current date in YYYY-MM-DD format into some variable in a Windows .bat file?</p>
<p>Unix shell analogue:</p>
<pre><code>today=`date +%F`
echo $today
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,924 | cmd | # Windows batch: formatted date into variable
How do I save the current date in YYYY-MM-DD format into some variable in a Windows .bat file?
Unix shell analogue:
```
today=`date +%F`
echo $today
``` | You can get the current date in a locale-agnostic way using
```
for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate=%%x
```
Then you can extract the individual parts using substrings:
```
set today=%MyDate:~0,4%-%MyDate:~4,2%-%MyDate:~6,2%
```
Another way, where you get variable... |
1645843 | Resolve absolute path from relative path and/or file name | 186 | 2009-10-29 18:58:56 | <p>Is there a way in a Windows batch script to return an absolute path from a value containing a filename and/or relative path?</p>
<p><strong>Given:</strong></p>
<pre><code>"..\"
"..\somefile.txt"
</code></pre>
<p>I need the absolute path relative to the batch file.</p>
<p><strong>Example:</strong></p>
<ul>
<li>"... | 305,799 | 143,327 | 2020-07-24 02:34:32 | 1,645,992 | 184 | 2009-10-29 19:25:33 | 195,823 | 2019-07-19 11:16:13 | https://stackoverflow.com/q/1645843 | https://stackoverflow.com/a/1645992 | <p>In batch files, as in standard C programs, argument 0 contains the path to the currently executing script. You can use <code>%~dp0</code> to get only the path portion of the 0th argument (which is the current script) - this path is always a fully qualified path.</p>
<p>You can also get the fully qualified path of y... | <p>In batch files, as in standard C programs, argument 0 contains the path to the currently executing script. You can use <code>%~dp0</code> to get only the path portion of the 0th argument (which is the current script) - this path is always a fully qualified path.</p> <p>You can also get the fully qualified path of y... | 64, 7002, 8877, 14371 | absolute-path, batch-file, relative-path, windows | <h1>Resolve absolute path from relative path and/or file name</h1>
<p>Is there a way in a Windows batch script to return an absolute path from a value containing a filename and/or relative path?</p>
<p><strong>Given:</strong></p>
<pre><code>"..\"
"..\somefile.txt"
</code></pre>
<p>I need the absolute path relative t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,925 | cmd | # Resolve absolute path from relative path and/or file name
Is there a way in a Windows batch script to return an absolute path from a value containing a filename and/or relative path?
**Given:**
```
"..\"
"..\somefile.txt"
```
I need the absolute path relative to the batch file.
**Example:**
- "somefile.txt" is ... | In batch files, as in standard C programs, argument 0 contains the path to the currently executing script. You can use `%~dp0` to get only the path portion of the 0th argument (which is the current script) - this path is always a fully qualified path.
You can also get the fully qualified path of your first argument by... |
21709305 | How to directly execute SQL query in C#? | 98 | 2014-02-11 17:50:22 | <p>Ok, I have an old batch file that does exactly what I need. However, with out new administration we can't run the batch file anymore so I need to start up with C#.</p>
<p>I'm using Visual Studio C# and already have the forms set up for the application I need to build. (I'm learning as I go)</p>
<p>Here is what I ... | 484,127 | 3,191,919 | 2019-01-18 14:59:18 | 21,709,663 | 184 | 2014-02-11 18:06:46 | 86,860 | 2014-03-28 14:21:15 | https://stackoverflow.com/q/21709305 | https://stackoverflow.com/a/21709663 | <p>To execute your command directly from within C#, you would use the <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand%28v=vs.110%29.aspx">SqlCommand</a> class.</p>
<p>Quick sample code using paramaterized SQL (to avoid injection attacks) might look like this:</p>
<pre><code>string qu... | <p>To execute your command directly from within C#, you would use the <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand%28v=vs.110%29.aspx">SqlCommand</a> class.</p> <p>Quick sample code using paramaterized SQL (to avoid injection attacks) might look like this:</p> <pre><code>string qu... | 1, 9, 72, 7002 | .net, batch-file, c#, sql-server | <h1>How to directly execute SQL query in C#?</h1>
<p>Ok, I have an old batch file that does exactly what I need. However, with out new administration we can't run the batch file anymore so I need to start up with C#.</p>
<p>I'm using Visual Studio C# and already have the forms set up for the application I need to bui... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,927 | cmd | # How to directly execute SQL query in C#?
Ok, I have an old batch file that does exactly what I need. However, with out new administration we can't run the batch file anymore so I need to start up with C#.
I'm using Visual Studio C# and already have the forms set up for the application I need to build. (I'm learning... | To execute your command directly from within C#, you would use the [SqlCommand](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand%28v=vs.110%29.aspx) class.
Quick sample code using paramaterized SQL (to avoid injection attacks) might look like this:
```
string queryString = "SELECT tPatCulIntPa... |
14697739 | How to automatically close cmd window after batch file execution? | 133 | 2013-02-04 23:37:14 | <p>I'm running a batch file that has these two lines: </p>
<pre><code>start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1"
"C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow
</code></pre>
<p>This batch file is used to run the Xming application and then the PuTTY app so I can SSH into m... | 601,813 | 1,470,257 | 2024-10-14 09:10:57 | 14,701,655 | 183 | 2013-02-05 06:45:41 | 736,172 | 2013-02-10 04:12:22 | https://stackoverflow.com/q/14697739 | https://stackoverflow.com/a/14701655 | <p>Modify the batch file to <code>START</code> both programs, instead of <code>START</code>ing one and <code>CALL</code>ing another</p>
<pre><code>start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1"
start "" "C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow
</code></pre>
<p>If you ru... | <p>Modify the batch file to <code>START</code> both programs, instead of <code>START</code>ing one and <code>CALL</code>ing another</p> <pre><code>start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1" start "" "C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow </code></pre> <p>If you ru... | 2631, 7002 | batch-file, cmd | <h1>How to automatically close cmd window after batch file execution?</h1>
<p>I'm running a batch file that has these two lines: </p>
<pre><code>start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1"
"C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow
</code></pre>
<p>This batch file is u... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,929 | cmd | # How to automatically close cmd window after batch file execution?
I'm running a batch file that has these two lines:
```
start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1"
"C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow
```
This batch file is used to run the Xming application a... | Modify the batch file to `START` both programs, instead of `START`ing one and `CALL`ing another
```
start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1"
start "" "C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow
```
If you run it like this, no CMD window will stay open after starting ... |
1192476 | Format date and time in a Windows batch script | 264 | 2009-07-28 07:46:34 | <p>In a Windows (Windows XP) batch script I need to format the current date and time for later use in files names, etc.</p>
<p>It is similar to Stack Overflow question <em><a href="https://stackoverflow.com/questions/864718/how-to-append-a-date-in-batch-files">How to append a date in batch files</a></em>, but wit... | 1,178,988 | 5,835 | 2022-01-22 13:52:09 | 1,194,991 | 179 | 2009-07-28 15:43:48 | 5,835 | 2016-05-22 20:37:09 | https://stackoverflow.com/q/1192476 | https://stackoverflow.com/a/1194991 | <p>I ended up with this script:</p>
<pre><code>set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
echo hour=%hour%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
echo min=%min%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
echo secs=%secs%
set year=%date:~-4%
echo ... | <p>I ended up with this script:</p> <pre><code>set hour=%time:~0,2% if "%hour:~0,1%" == " " set hour=0%hour:~1,1% echo hour=%hour% set min=%time:~3,2% if "%min:~0,1%" == " " set min=0%min:~1,1% echo min=%min% set secs=%time:~6,2% if "%secs:~0,1%" == " " set secs=0%secs:~1,1% echo secs=%secs% set year=%date:~-4% echo ... | 64, 555, 1263, 7002 | batch-file, datetime, formatting, windows | <h1>Format date and time in a Windows batch script</h1>
<p>In a Windows (Windows XP) batch script I need to format the current date and time for later use in files names, etc.</p>
<p>It is similar to Stack Overflow question <em><a href="https://stackoverflow.com/questions/864718/how-to-append-a-date-in-batch-file... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,930 | cmd | # Format date and time in a Windows batch script
In a Windows (Windows XP) batch script I need to format the current date and time for later use in files names, etc.
It is similar to Stack Overflow question *[How to append a date in batch files](https://stackoverflow.com/questions/864718/how-to-append-a-date-in-batch... | I ended up with this script:
```
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
echo hour=%hour%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
echo min=%min%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
echo secs=%secs%
set year=%date:~-4%
echo year=%year%
``... |
324539 | How can I run a program from a batch file without leaving the console open after the program starts? | 212 | 2008-11-27 19:42:20 | <p>For the moment my batch file look like this:</p>
<pre><code>myprogram.exe param1
</code></pre>
<p>The program starts but the DOS Window remains open. How can I close it?</p>
| 959,005 | 14,441 | 2024-05-08 15:49:48 | 324,540 | 179 | 2008-11-27 19:43:39 | 13,913 | 2014-04-17 20:39:58 | https://stackoverflow.com/q/324539 | https://stackoverflow.com/a/324540 | <p>You can use the exit keyword. Here is an example from one of my batch files:</p>
<pre><code>start myProgram.exe param1
exit
</code></pre>
| <p>You can use the exit keyword. Here is an example from one of my batch files:</p> <pre><code>start myProgram.exe param1 exit </code></pre> | 64, 7002 | batch-file, windows | <h1>How can I run a program from a batch file without leaving the console open after the program starts?</h1>
<p>For the moment my batch file look like this:</p>
<pre><code>myprogram.exe param1
</code></pre>
<p>The program starts but the DOS Window remains open. How can I close it?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,931 | cmd | # How can I run a program from a batch file without leaving the console open after the program starts?
For the moment my batch file look like this:
```
myprogram.exe param1
```
The program starts but the DOS Window remains open. How can I close it? | You can use the exit keyword. Here is an example from one of my batch files:
```
start myProgram.exe param1
exit
``` |
7879791 | How to read input from console in a batch file? | 108 | 2011-10-24 18:02:06 | <p>How do I read input from the console in a batch file? What I am trying to achieve is the functionality of scanf in C. How can I do the same in a batch file?</p>
| 265,245 | 530,993 | 2020-01-09 00:24:14 | 7,880,263 | 178 | 2011-10-24 18:43:07 | 902,497 | 2016-01-28 16:13:49 | https://stackoverflow.com/q/7879791 | https://stackoverflow.com/a/7880263 | <p>The code snippet in the linked proposed duplicate reads user input.</p>
<pre><code>ECHO A current build of Test Harness exists.
set /p delBuild=Delete preexisting build [y/n]?:
</code></pre>
<p>The user can type as many letters as they want, and it will go into the delBuild variable.</p>
| <p>The code snippet in the linked proposed duplicate reads user input.</p> <pre><code>ECHO A current build of Test Harness exists. set /p delBuild=Delete preexisting build [y/n]?: </code></pre> <p>The user can type as many letters as they want, and it will go into the delBuild variable.</p> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>How to read input from console in a batch file?</h1>
<p>How do I read input from the console in a batch file? What I am trying to achieve is the functionality of scanf in C. How can I do the same in a 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 | 11,932 | cmd | # How to read input from console in a batch file?
How do I read input from the console in a batch file? What I am trying to achieve is the functionality of scanf in C. How can I do the same in a batch file? | The code snippet in the linked proposed duplicate reads user input.
```
ECHO A current build of Test Harness exists.
set /p delBuild=Delete preexisting build [y/n]?:
```
The user can type as many letters as they want, and it will go into the delBuild variable. |
3097044 | Batch - Echo or Variable Not Working | 83 | 2010-06-22 20:49:49 | <p>I have this little batch script:</p>
<pre><code>SET @var = "GREG"
ECHO %@var%
PAUSE
</code></pre>
<p>When I run it, it prints:</p>
<pre><code>H:\Dynamics>SET @var = "GREG"
H:\Dynamics>ECHO
ECHO is on.
H:\Dynamics>PAUSE
Press any key to continue . . .
</code></pre>
<p>Why won't it print the contents of... | 285,364 | 13,009 | 2023-04-04 17:17:31 | 3,097,080 | 176 | 2010-06-22 20:56:39 | 368,772 | 2010-06-22 20:56:39 | https://stackoverflow.com/q/3097044 | https://stackoverflow.com/a/3097080 | <p>Dont use spaces:</p>
<pre><code>SET @var="GREG"
::instead of SET @var = "GREG"
ECHO %@var%
PAUSE
</code></pre>
| <p>Dont use spaces:</p> <pre><code>SET @var="GREG" ::instead of SET @var = "GREG" ECHO %@var% PAUSE </code></pre> | 64, 7002 | batch-file, windows | <h1>Batch - Echo or Variable Not Working</h1>
<p>I have this little batch script:</p>
<pre><code>SET @var = "GREG"
ECHO %@var%
PAUSE
</code></pre>
<p>When I run it, it prints:</p>
<pre><code>H:\Dynamics>SET @var = "GREG"
H:\Dynamics>ECHO
ECHO is on.
H:\Dynamics>PAUSE
Press any key to continue . . .
</code... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,934 | cmd | # Batch - Echo or Variable Not Working
I have this little batch script:
```
SET @var = "GREG"
ECHO %@var%
PAUSE
```
When I run it, it prints:
```
H:\Dynamics>SET @var = "GREG"
H:\Dynamics>ECHO
ECHO is on.
H:\Dynamics>PAUSE
Press any key to continue . . .
```
Why won't it print the contents of @var? How do I know... | Dont use spaces:
```
SET @var="GREG"
::instead of SET @var = "GREG"
ECHO %@var%
PAUSE
``` |
2583517 | Run all SQL files in a directory | 146 | 2010-04-06 08:28:03 | <p>I have a number of .sql files which I have to run in order to apply changes made by other developers on an SQL Server 2005 database.
The files are named according to the following pattern:</p>
<pre><code>0001 - abc.sql
0002 - abcef.sql
0003 - abc.sql
...
</code></pre>
<p>Is there a way to run all of them in one go... | 240,123 | 116,987 | 2024-11-15 09:15:10 | 6,504,317 | 175 | 2011-06-28 09:24:43 | 818,851 | 2020-03-06 13:32:49 | https://stackoverflow.com/q/2583517 | https://stackoverflow.com/a/6504317 | <p>Create a .BAT file with the following command:</p>
<pre><code>for %%G in (*.sql) do sqlcmd /S servername /d databaseName -E -i"%%G"
pause
</code></pre>
<p>If you need to provide username and passsword </p>
<pre><code>for %%G in (*.sql) do sqlcmd /S servername /d databaseName -U username -P
password -i"%%G"
</cod... | <p>Create a .BAT file with the following command:</p> <pre><code>for %%G in (*.sql) do sqlcmd /S servername /d databaseName -E -i"%%G" pause </code></pre> <p>If you need to provide username and passsword </p> <pre><code>for %%G in (*.sql) do sqlcmd /S servername /d databaseName -U username -P password -i"%%G" </cod... | 22, 72, 30645 | batch-processing, sql, sql-server | <h1>Run all SQL files in a directory</h1>
<p>I have a number of .sql files which I have to run in order to apply changes made by other developers on an SQL Server 2005 database.
The files are named according to the following pattern:</p>
<pre><code>0001 - abc.sql
0002 - abcef.sql
0003 - abc.sql
...
</code></pre>
<p>I... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,935 | cmd | # Run all SQL files in a directory
I have a number of .sql files which I have to run in order to apply changes made by other developers on an SQL Server 2005 database.
The files are named according to the following pattern:
```
0001 - abc.sql
0002 - abcef.sql
0003 - abc.sql
...
```
Is there a way to run all of them ... | Create a .BAT file with the following command:
```
for %%G in (*.sql) do sqlcmd /S servername /d databaseName -E -i"%%G"
pause
```
If you need to provide username and passsword
```
for %%G in (*.sql) do sqlcmd /S servername /d databaseName -U username -P
password -i"%%G"
```
Note that the "-E" is not needed when u... |
127318 | Is there any sed like utility for cmd.exe? | 201 | 2008-09-24 14:01:42 | <p>I want to programmatically edit file content using windows command line (<a href="http://en.wikipedia.org/wiki/Windows_command_line" rel="noreferrer">cmd.exe</a>). In *nix there is <a href="http://en.wikipedia.org/wiki/Sed" rel="noreferrer">sed</a> for this tasks. Are there any useful native equivalents (cmd or ps) ... | 338,605 | 2,361 | 2023-08-21 15:25:04 | 6,028,937 | 174 | 2011-05-17 09:35:12 | 2,361 | 2021-04-07 16:16:43 | https://stackoverflow.com/q/127318 | https://stackoverflow.com/a/6028937 | <p>Today powershell saved me.</p>
<p>For <code>grep</code> there is:</p>
<pre><code>get-content somefile.txt | where { $_ -match "expression"}
</code></pre>
<p>or</p>
<pre><code>select-string somefile.txt -pattern "expression"
</code></pre>
<p>and for <code>sed</code> there is:</p>
<pre><code>get-co... | <p>Today powershell saved me.</p> <p>For <code>grep</code> there is:</p> <pre><code>get-content somefile.txt | where { $_ -match "expression"} </code></pre> <p>or</p> <pre><code>select-string somefile.txt -pattern "expression" </code></pre> <p>and for <code>sed</code> there is:</p> <pre><code>get-co... | 64, 2631, 5282 | cmd, sed, windows | <h1>Is there any sed like utility for cmd.exe?</h1>
<p>I want to programmatically edit file content using windows command line (<a href="http://en.wikipedia.org/wiki/Windows_command_line" rel="noreferrer">cmd.exe</a>). In *nix there is <a href="http://en.wikipedia.org/wiki/Sed" rel="noreferrer">sed</a> for this tasks. ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,936 | cmd | # Is there any sed like utility for cmd.exe?
I want to programmatically edit file content using windows command line ([cmd.exe](http://en.wikipedia.org/wiki/Windows_command_line)). In *nix there is [sed](http://en.wikipedia.org/wiki/Sed) for this tasks. Are there any useful native equivalents (cmd or ps) in windows? | Today powershell saved me.
For `grep` there is:
```
get-content somefile.txt | where { $_ -match "expression"}
```
or
```
select-string somefile.txt -pattern "expression"
```
and for `sed` there is:
```
get-content somefile.txt | %{$_ -replace "expression","replace"}
```
For more detail about replace PowerShell ... |
15567809 | Batch Extract path and filename from a variable | 107 | 2013-03-22 10:15:52 | <p>How can I extract path and filename from a variable?</p>
<pre><code>Setlocal EnableDelayedExpansion
set file=C:\Users\l72rugschiri\Desktop\fs.cfg
</code></pre>
<p>I want to do that without using any function or any GOTO.
is it possible?</p>
| 278,539 | 1,157,530 | 2020-06-29 09:05:16 | 15,568,164 | 174 | 2013-03-22 10:32:41 | 2,128,947 | 2018-05-04 15:59:36 | https://stackoverflow.com/q/15567809 | https://stackoverflow.com/a/15568164 | <pre><code>@ECHO OFF
SETLOCAL
set file=C:\Users\l72rugschiri\Desktop\fs.cfg
FOR %%i IN ("%file%") DO (
ECHO filedrive=%%~di
ECHO filepath=%%~pi
ECHO filename=%%~ni
ECHO fileextension=%%~xi
)
</code></pre>
<p>Not <strong>really</strong> sure what you mean by no "function"</p>
<p>Obviously, change <code>ECHO</code> to ... | <pre><code>@ECHO OFF SETLOCAL set file=C:\Users\l72rugschiri\Desktop\fs.cfg FOR %%i IN ("%file%") DO ( ECHO filedrive=%%~di ECHO filepath=%%~pi ECHO filename=%%~ni ECHO fileextension=%%~xi ) </code></pre> <p>Not <strong>really</strong> sure what you mean by no "function"</p> <p>Obviously, change <code>ECHO</code> to ... | 6268, 7002 | batch-file, path | <h1>Batch Extract path and filename from a variable</h1>
<p>How can I extract path and filename from a variable?</p>
<pre><code>Setlocal EnableDelayedExpansion
set file=C:\Users\l72rugschiri\Desktop\fs.cfg
</code></pre>
<p>I want to do that without using any function or any GOTO.
is it possible?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,937 | cmd | # Batch Extract path and filename from a variable
How can I extract path and filename from a variable?
```
Setlocal EnableDelayedExpansion
set file=C:\Users\l72rugschiri\Desktop\fs.cfg
```
I want to do that without using any function or any GOTO.
is it possible? | ```
@ECHO OFF
SETLOCAL
set file=C:\Users\l72rugschiri\Desktop\fs.cfg
FOR %%i IN ("%file%") DO (
ECHO filedrive=%%~di
ECHO filepath=%%~pi
ECHO filename=%%~ni
ECHO fileextension=%%~xi
)
```
Not **really** sure what you mean by no "function"
Obviously, change `ECHO` to `SET` to set the variables rather thon ECHOing them... |
4666045 | Batch file command PAUSE does not work | 71 | 2011-01-12 06:46:32 | <p>I am creating a simple batch file to assist in a few things, and I have some instructions that it prints out as well that I want the user to see before exit. Currently, the window closes very quickly. So I added <code>PAUSE</code> at the end of the file, but it does not want to work. </p>
<p>I looked at other quest... | 76,703 | 368,599 | 2023-11-21 06:30:38 | 9,596,267 | 173 | 2012-03-07 05:24:00 | 247,316 | 2023-11-21 06:30:38 | https://stackoverflow.com/q/4666045 | https://stackoverflow.com/a/9596267 | <p>If the last command fails pause won't work.</p>
<p>You can fix it by putting "call" in front of the command you are running (whatever command is before the pause) then the pause will work.</p>
<p>So for example I had a phpunit batch file that looked like this:</p>
<pre><code>phpunit tests/sometests.php
pau... | <p>If the last command fails pause won't work.</p> <p>You can fix it by putting "call" in front of the command you are running (whatever command is before the pause) then the pause will work.</p> <p>So for example I had a phpunit batch file that looked like this:</p> <pre><code>phpunit tests/sometests.php pau... | 7002, 34595 | batch-file, windows-7 | <h1>Batch file command PAUSE does not work</h1>
<p>I am creating a simple batch file to assist in a few things, and I have some instructions that it prints out as well that I want the user to see before exit. Currently, the window closes very quickly. So I added <code>PAUSE</code> at the end of the file, but it does no... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,938 | cmd | # Batch file command PAUSE does not work
I am creating a simple batch file to assist in a few things, and I have some instructions that it prints out as well that I want the user to see before exit. Currently, the window closes very quickly. So I added `PAUSE` at the end of the file, but it does not want to work.
I l... | If the last command fails pause won't work.
You can fix it by putting "call" in front of the command you are running (whatever command is before the pause) then the pause will work.
So for example I had a phpunit batch file that looked like this:
```
phpunit tests/sometests.php
pause
```
When phpunit failed it just... |
4252176 | /exclude in xcopy just for a file type | 82 | 2010-11-23 02:23:07 | <p>I have a batch file to copy over files from Visual Studio to my Web folder. I want to copy all files in my web project, EXCEPT for *.cs files. I can't seem to get this to work:</p>
<pre><code>xcopy /r /d /i /s /y /exclude:".cs" C:\dev\apan C:\web\apan
</code></pre>
<p>Any tips? I just get exit code 4 when I try... | 186,119 | 55,900 | 2023-02-02 02:32:49 | 4,252,213 | 172 | 2010-11-23 02:30:34 | 406,712 | 2021-10-19 06:30:00 | https://stackoverflow.com/q/4252176 | https://stackoverflow.com/a/4252213 | <p>The <code>/EXCLUDE:</code> argument expects a file containing a list of excluded files.</p>
<p>So create a file called <code>excludedfileslist.txt</code> containing:</p>
<pre><code>.cs\
</code></pre>
<p>Then a command like this:</p>
<pre><code>xcopy /r /d /i /s /y /exclude:excludedfileslist.txt C:\dev\apan C:\web\ap... | <p>The <code>/EXCLUDE:</code> argument expects a file containing a list of excluded files.</p> <p>So create a file called <code>excludedfileslist.txt</code> containing:</p> <pre><code>.cs\ </code></pre> <p>Then a command like this:</p> <pre><code>xcopy /r /d /i /s /y /exclude:excludedfileslist.txt C:\dev\apan C:\web\ap... | 4710, 7002 | batch-file, xcopy | <h1>/exclude in xcopy just for a file type</h1>
<p>I have a batch file to copy over files from Visual Studio to my Web folder. I want to copy all files in my web project, EXCEPT for *.cs files. I can't seem to get this to work:</p>
<pre><code>xcopy /r /d /i /s /y /exclude:".cs" C:\dev\apan C:\web\apan
</code></pre>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,939 | cmd | # /exclude in xcopy just for a file type
I have a batch file to copy over files from Visual Studio to my Web folder. I want to copy all files in my web project, EXCEPT for *.cs files. I can't seem to get this to work:
```
xcopy /r /d /i /s /y /exclude:".cs" C:\dev\apan C:\web\apan
```
Any tips? I just get exit code ... | The `/EXCLUDE:` argument expects a file containing a list of excluded files.
So create a file called `excludedfileslist.txt` containing:
```
.cs\
```
Then a command like this:
```
xcopy /r /d /i /s /y /exclude:excludedfileslist.txt C:\dev\apan C:\web\apan
```
Alternatively you could use [Robocopy](http://technet.m... |
4983508 | Can I have an IF block in DOS batch file? | 121 | 2011-02-13 09:51:44 | <p>In a DOS batch file we can only have 1 line if statement body? I think I found somewhere that I could use <code>()</code> for an if block just like the <code>{}</code> used in C-like programming languages, but it is not executing the statements when I try this. No error message either. This my code:</p>
<pre><code>... | 286,969 | 474,323 | 2019-05-06 08:01:54 | 4,983,613 | 170 | 2011-02-13 10:21:17 | 366,904 | 2011-02-13 10:32:11 | https://stackoverflow.com/q/4983508 | https://stackoverflow.com/a/4983613 | <p>You can indeed place create a block of statements to execute after a conditional. But you have the syntax wrong. The parentheses must be used exactly as shown:</p>
<pre><code>if <statement> (
do something
) else (
do something else
)
</code></pre>
<p>However, I do not believe that there is any built-... | <p>You can indeed place create a block of statements to execute after a conditional. But you have the syntax wrong. The parentheses must be used exactly as shown:</p> <pre><code>if <statement> ( do something ) else ( do something else ) </code></pre> <p>However, I do not believe that there is any built-... | 2773, 7002 | batch-file, if-statement | <h1>Can I have an IF block in DOS batch file?</h1>
<p>In a DOS batch file we can only have 1 line if statement body? I think I found somewhere that I could use <code>()</code> for an if block just like the <code>{}</code> used in C-like programming languages, but it is not executing the statements when I try this. No e... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,940 | cmd | # Can I have an IF block in DOS batch file?
In a DOS batch file we can only have 1 line if statement body? I think I found somewhere that I could use `()` for an if block just like the `{}` used in C-like programming languages, but it is not executing the statements when I try this. No error message either. This my co... | You can indeed place create a block of statements to execute after a conditional. But you have the syntax wrong. The parentheses must be used exactly as shown:
```
if <statement> (
do something
) else (
do something else
)
```
However, I do not believe that there is any built-in syntax for `else-if` statement... |
14348840 | Opening Chrome From Command Line | 81 | 2013-01-15 23:27:58 | <p>I have the following batch file:</p>
<pre><code>@echo off
REM Starts a chrome browser with multiple tabbed sites
C:\Users\UserName\AppData\Local\Google\Chrome\Application\chrome.exe "site1.com" "site2.com"
</code></pre>
<p>But when I run it, it causes the prompt to hang and renders it unusable until Chrome is clos... | 287,387 | 1,473,784 | 2022-09-07 03:24:44 | 14,348,866 | 170 | 2013-01-15 23:30:03 | 301,377 | 2013-01-15 23:30:03 | https://stackoverflow.com/q/14348840 | https://stackoverflow.com/a/14348866 | <p>Have a look into the <code>start</code> command. It should do what you're trying to achieve.</p>
<p>Also, you might be able to leave out path to chrome. The following works on Windows 7:</p>
<p><code>start chrome "site1.com" "site2.com"</code></p>
| <p>Have a look into the <code>start</code> command. It should do what you're trying to achieve.</p> <p>Also, you might be able to leave out path to chrome. The following works on Windows 7:</p> <p><code>start chrome "site1.com" "site2.com"</code></p> | 64, 3600, 7002, 9938 | batch-file, command-prompt, google-chrome, windows | <h1>Opening Chrome From Command Line</h1>
<p>I have the following batch file:</p>
<pre><code>@echo off
REM Starts a chrome browser with multiple tabbed sites
C:\Users\UserName\AppData\Local\Google\Chrome\Application\chrome.exe "site1.com" "site2.com"
</code></pre>
<p>But when I run it, it causes the prompt to hang an... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,941 | cmd | # Opening Chrome From Command Line
I have the following batch file:
```
@echo off
REM Starts a chrome browser with multiple tabbed sites
C:\Users\UserName\AppData\Local\Google\Chrome\Application\chrome.exe "site1.com" "site2.com"
```
But when I run it, it causes the prompt to hang and renders it unusable until Chrom... | Have a look into the `start` command. It should do what you're trying to achieve.
Also, you might be able to leave out path to chrome. The following works on Windows 7:
`start chrome "site1.com" "site2.com"` |
1502913 | How to delete all files and folders in a folder by cmd call | 112 | 2009-10-01 09:32:54 | <p>I use Windows.</p>
<p>I want to delete all files and folders in a folder by system call.</p>
<p>I may call like that:</p>
<pre><code>>rd /s /q c:\destination
>md c:\destination
</code></pre>
<p>Do you know an easier way?</p>
| 479,470 | 136,135 | 2022-11-25 13:29:25 | 1,502,935 | 169 | 2009-10-01 09:41:15 | 73,070 | 2016-06-22 15:26:51 | https://stackoverflow.com/q/1502913 | https://stackoverflow.com/a/1502935 | <p>No, I don't know one.</p>
<p>If you want to retain the original directory for some reason (ACLs, &c.), and instead really want to empty it, then you can do the following:</p>
<pre><code>del /q destination\*
for /d %x in (destination\*) do @rd /s /q "%x"
</code></pre>
<p>This first removes all files from the d... | <p>No, I don't know one.</p> <p>If you want to retain the original directory for some reason (ACLs, &c.), and instead really want to empty it, then you can do the following:</p> <pre><code>del /q destination\* for /d %x in (destination\*) do @rd /s /q "%x" </code></pre> <p>This first removes all files from the d... | 64, 7002 | batch-file, windows | <h1>How to delete all files and folders in a folder by cmd call</h1>
<p>I use Windows.</p>
<p>I want to delete all files and folders in a folder by system call.</p>
<p>I may call like that:</p>
<pre><code>>rd /s /q c:\destination
>md c:\destination
</code></pre>
<p>Do you know an easier way?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,942 | cmd | # How to delete all files and folders in a folder by cmd call
I use Windows.
I want to delete all files and folders in a folder by system call.
I may call like that:
```
>rd /s /q c:\destination
>md c:\destination
```
Do you know an easier way? | No, I don't know one.
If you want to retain the original directory for some reason (ACLs, &c.), and instead really want to empty it, then you can do the following:
```
del /q destination\*
for /d %x in (destination\*) do @rd /s /q "%x"
```
This first removes all files from the directory, and then recursively removes... |
72671 | How to create batch file in Windows using "start" with a path and command with spaces | 79 | 2008-09-16 14:09:28 | <p>I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command.</p>
<p>However, the command has a path in it. I also need to pass paramaters which have spaces as well. How to do this?</p>
<p>E.g. batch file</p>
<pre><code>start "c:\path... | 174,819 | null | 2018-05-28 05:16:27 | 72,796 | 168 | 2008-09-16 14:18:17 | 3,857 | 2008-09-16 14:18:17 | https://stackoverflow.com/q/72671 | https://stackoverflow.com/a/72796 | <p>Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "... | <p>Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "... | 64, 531, 7002 | batch-file, scripting, windows | <h1>How to create batch file in Windows using "start" with a path and command with spaces</h1>
<p>I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command.</p>
<p>However, the command has a path in it. I also need to pass paramaters whi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,943 | cmd | # How to create batch file in Windows using "start" with a path and command with spaces
I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command.
However, the command has a path in it. I also need to pass paramaters which have spaces as ... | Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "" b... |
20691060 | Echo a blank (empty) line to the console from a Windows batch file | 221 | 2013-12-19 20:27:46 | <p>When outputting status messages to the console from a Windows batch file, I want to output <strong>blank lines</strong> to break up the output. How do I do this?</p>
| 316,123 | 1,497,596 | 2017-04-23 01:42:49 | 20,691,061 | 167 | 2013-12-19 20:27:46 | 1,497,596 | 2017-04-23 01:35:21 | https://stackoverflow.com/q/20691060 | https://stackoverflow.com/a/20691061 |
<p><em><sup>Note: Though my original answer attracted several upvotes, I decided that I could do much better. You can find my original (simplistic and misguided) answer in the edit history.</sup></em></p>
<p>If Microsoft had the intent of providing a means of outputting a blank line from <code>cmd.exe</code>, Micros... | <p><em><sup>Note: Though my original answer attracted several upvotes, I decided that I could do much better. You can find my original (simplistic and misguided) answer in the edit history.</sup></em></p> <p>If Microsoft had the intent of providing a means of outputting a blank line from <code>cmd.exe</code>, Micros... | 64, 7002, 13824 | batch-file, echo, windows | <h1>Echo a blank (empty) line to the console from a Windows batch file</h1>
<p>When outputting status messages to the console from a Windows batch file, I want to output <strong>blank lines</strong> to break up the output. How do I do this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,944 | cmd | # Echo a blank (empty) line to the console from a Windows batch file
When outputting status messages to the console from a Windows batch file, I want to output **blank lines** to break up the output. How do I do this? | *Note: Though my original answer attracted several upvotes, I decided that I could do much better. You can find my original (simplistic and misguided) answer in the edit history.*
If Microsoft had the intent of providing a means of outputting a blank line from `cmd.exe`, Microsoft surely would have documented such a s... |
16078421 | How do I get a list of folders and sub folders without the files? | 91 | 2013-04-18 08:49:59 | <p>I am trying to print a list of the <strong><em>folders</em></strong> and <strong><em>sub folders</em></strong> of a directory to a file.</p>
<p>When I run <strong><code>dir /s/b/o:n > f.txt</code></strong>, I get a list of the files also. I only need the folders and sub folders.</p>
<p>Anyone know is this poss... | 435,950 | 599,956 | 2020-12-14 14:12:39 | 16,079,895 | 167 | 2013-04-18 09:59:45 | 2,098,699 | 2013-04-18 09:59:45 | https://stackoverflow.com/q/16078421 | https://stackoverflow.com/a/16079895 | <p>Try this:</p>
<pre><code>dir /s /b /o:n /ad > f.txt
</code></pre>
| <p>Try this:</p> <pre><code>dir /s /b /o:n /ad > f.txt </code></pre> | 218, 2631, 34708 | cmd, directory, subdirectory | <h1>How do I get a list of folders and sub folders without the files?</h1>
<p>I am trying to print a list of the <strong><em>folders</em></strong> and <strong><em>sub folders</em></strong> of a directory to a file.</p>
<p>When I run <strong><code>dir /s/b/o:n > f.txt</code></strong>, I get a list of the files also.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,945 | cmd | # How do I get a list of folders and sub folders without the files?
I am trying to print a list of the ***folders*** and ***sub folders*** of a directory to a file.
When I run **`dir /s/b/o:n > f.txt`**, I get a list of the files also. I only need the folders and sub folders.
Anyone know is this possible to do this ... | Try this:
```
dir /s /b /o:n /ad > f.txt
``` |
15464111 | Run cmd commands through Java | 86 | 2013-03-17 17:51:56 | <p>I found several code snippets for running cmd commands through a Java class, but I wasn't able to understand it.</p>
<p>This is code for opening the cmd </p>
<pre><code>public void excCommand(String new_dir){
Runtime rt = Runtime.getRuntime();
try {
rt.exec(new String[]{"cmd.exe","/c","start"});
... | 428,963 | 1,086,247 | 2023-05-07 10:18:16 | 15,464,449 | 166 | 2013-03-17 18:23:25 | 48,503 | 2013-03-17 18:23:25 | https://stackoverflow.com/q/15464111 | https://stackoverflow.com/a/15464449 | <p>One way to run a process from a different directory to the working directory of your Java program is to change directory and then run the process in the same command line. You can do this by getting <code>cmd.exe</code> to run a command line such as <code>cd some_directory && some_program</code>.</p>
<p>T... | <p>One way to run a process from a different directory to the working directory of your Java program is to change directory and then run the process in the same command line. You can do this by getting <code>cmd.exe</code> to run a command line such as <code>cd some_directory && some_program</code>.</p> <p>T... | 17, 2631, 3718 | cd, cmd, java | <h1>Run cmd commands through Java</h1>
<p>I found several code snippets for running cmd commands through a Java class, but I wasn't able to understand it.</p>
<p>This is code for opening the cmd </p>
<pre><code>public void excCommand(String new_dir){
Runtime rt = Runtime.getRuntime();
try {
rt.exec(ne... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,946 | cmd | # Run cmd commands through Java
I found several code snippets for running cmd commands through a Java class, but I wasn't able to understand it.
This is code for opening the cmd
```
public void excCommand(String new_dir){
Runtime rt = Runtime.getRuntime();
try {
rt.exec(new String[]{"cmd.exe","/c","s... | One way to run a process from a different directory to the working directory of your Java program is to change directory and then run the process in the same command line. You can do this by getting `cmd.exe` to run a command line such as `cd some_directory && some_program`.
The following example changes to a differen... |
2952401 | Remove Trailing Slash From Batch File Input | 88 | 2010-06-01 18:49:58 | <p>I have a batch file that I want to improve. Instead of requiring a user to provide a folder path without a trailing slash, is there an easy way for me to just remove the last character from the path if there is a slash on the end?</p>
<pre><code>:START
@echo What folder do you want to process? (Provide a path witho... | 50,554 | 355,762 | 2023-12-12 06:21:35 | 2,952,637 | 163 | 2010-06-01 19:26:27 | 103,043 | 2010-06-01 19:26:27 | https://stackoverflow.com/q/2952401 | https://stackoverflow.com/a/2952637 | <p>you can use syntax similar your evaluation:</p>
<pre><code>::Does string have a trailing slash? if so remove it
IF %datapath:~-1%==\ SET datapath=%datapath:~0,-1%
</code></pre>
| <p>you can use syntax similar your evaluation:</p> <pre><code>::Does string have a trailing slash? if so remove it IF %datapath:~-1%==\ SET datapath=%datapath:~0,-1% </code></pre> | 2631, 4371, 7002 | batch-file, cmd, substring | <h1>Remove Trailing Slash From Batch File Input</h1>
<p>I have a batch file that I want to improve. Instead of requiring a user to provide a folder path without a trailing slash, is there an easy way for me to just remove the last character from the path if there is a slash on the end?</p>
<pre><code>:START
@echo What... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,948 | cmd | # Remove Trailing Slash From Batch File Input
I have a batch file that I want to improve. Instead of requiring a user to provide a folder path without a trailing slash, is there an easy way for me to just remove the last character from the path if there is a slash on the end?
```
:START
@echo What folder do you want ... | you can use syntax similar your evaluation:
```
::Does string have a trailing slash? if so remove it
IF %datapath:~-1%==\ SET datapath=%datapath:~0,-1%
``` |
30466408 | Windows batch - concatenate multiple text files into one | 97 | 2015-05-26 18:41:28 | <p>I need to create a script, which concatenates multiple text files into one.
I know it's simple to use</p>
<pre><code>type *.txt > merged.txt
</code></pre>
<p>But the requirement is to "concatenate files from same day into file day_YYYY-DD-MM.txt" I am a Linux user and Windows batch is hell for me. It's ... | 315,789 | 2,300,789 | 2025-11-06 17:25:22 | 53,079,166 | 157 | 2018-10-31 08:29:36 | 7,739,087 | 2025-11-06 17:25:22 | https://stackoverflow.com/q/30466408 | https://stackoverflow.com/a/53079166 | <p>Windows <code>type</code> command works similarly to UNIX' <code>cat</code>.</p>
<ul>
<li><p><strong>Example 1:</strong> Merge with file names - this will merge <code>file1.csv</code> and <code>file2.csv</code> to create <code>concat.csv</code>:</p>
<pre><code>type file1.csv file2.csv > concat.csv
</code></pre>
<... | <p>Windows <code>type</code> command works similarly to UNIX' <code>cat</code>.</p> <ul> <li><p><strong>Example 1:</strong> Merge with file names - this will merge <code>file1.csv</code> and <code>file2.csv</code> to create <code>concat.csv</code>:</p> <pre><code>type file1.csv file2.csv > concat.csv </code></pre> <... | 64, 531, 7002 | batch-file, scripting, windows | <h1>Windows batch - concatenate multiple text files into one</h1>
<p>I need to create a script, which concatenates multiple text files into one.
I know it's simple to use</p>
<pre><code>type *.txt > merged.txt
</code></pre>
<p>But the requirement is to "concatenate files from same day into file day_YYYY-DD-MM.t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,949 | cmd | # Windows batch - concatenate multiple text files into one
I need to create a script, which concatenates multiple text files into one.
I know it's simple to use
```
type *.txt > merged.txt
```
But the requirement is to "concatenate files from same day into file day_YYYY-DD-MM.txt" I am a Linux user and Windows batch... | Windows `type` command works similarly to UNIX' `cat`.
- **Example 1:** Merge with file names - this will merge `file1.csv` and `file2.csv` to create `concat.csv`:
```
type file1.csv file2.csv > concat.csv
```
- **Example 2:** Merge files with wildcards - this will merge all files with the `.csv` extension and ... |
171588 | Is there a command to refresh environment variables from the command prompt in Windows? | 724 | 2008-10-05 06:49:38 | <p>If I modify or add an environment variable I have to restart the command prompt. Is there a command I could execute that would do this without restarting CMD?</p>
| 948,731 | 3,957 | 2026-01-17 02:04:29 | 171,737 | 155 | 2008-10-05 09:10:28 | 7,581 | 2018-04-29 17:54:18 | https://stackoverflow.com/q/171588 | https://stackoverflow.com/a/171737 | <p>You can capture the system environment variables with a vbs script, but you need a bat script to actually change the current environment variables, so this is a combined solution.</p>
<p>Create a file named <code>resetvars.vbs</code> containing this code, and save it on the path:</p>
<pre class="lang-vb prettypr... | <p>You can capture the system environment variables with a vbs script, but you need a bat script to actually change the current environment variables, so this is a combined solution.</p> <p>Create a file named <code>resetvars.vbs</code> containing this code, and save it on the path:</p> <pre class="lang-vb prettypr... | 64, 2631, 9013 | cmd, environment-variables, windows | <h1>Is there a command to refresh environment variables from the command prompt in Windows?</h1>
<p>If I modify or add an environment variable I have to restart the command prompt. Is there a command I could execute that would do this without restarting CMD?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,951 | cmd | # Is there a command to refresh environment variables from the command prompt in Windows?
If I modify or add an environment variable I have to restart the command prompt. Is there a command I could execute that would do this without restarting CMD? | You can capture the system environment variables with a vbs script, but you need a bat script to actually change the current environment variables, so this is a combined solution.
Create a file named `resetvars.vbs` containing this code, and save it on the path:
```
Set oShell = WScript.CreateObject("WScript.Shell")
... |
6204003 | Kill a Process by Looking up the Port being used by it from a .BAT | 136 | 2011-06-01 15:51:30 | <p>In Windows what can look for port 8080 and try to kill the process it is using through a .BAT file?</p>
| 364,193 | 280,602 | 2022-02-01 19:07:49 | 6,204,329 | 155 | 2011-06-01 16:13:30 | 232,593 | 2011-12-01 03:01:44 | https://stackoverflow.com/q/6204003 | https://stackoverflow.com/a/6204329 | <p>Here's a command to get you started:</p>
<pre><code>FOR /F "tokens=4 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080') DO @ECHO TaskKill.exe /PID %%P
</code></pre>
<p>When you're confident in your batch file, remove <code>@ECHO</code>.</p>
<pre><code>FOR /F "tokens=4 delims= " %%P IN ('netstat -a -n -o ^| fi... | <p>Here's a command to get you started:</p> <pre><code>FOR /F "tokens=4 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080') DO @ECHO TaskKill.exe /PID %%P </code></pre> <p>When you're confident in your batch file, remove <code>@ECHO</code>.</p> <pre><code>FOR /F "tokens=4 delims= " %%P IN ('netstat -a -n -o ^| fi... | 64, 5910, 7002, 23014 | batch-file, kill-process, process, windows | <h1>Kill a Process by Looking up the Port being used by it from a .BAT</h1>
<p>In Windows what can look for port 8080 and try to kill the process it is using through a .BAT file?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,952 | cmd | # Kill a Process by Looking up the Port being used by it from a .BAT
In Windows what can look for port 8080 and try to kill the process it is using through a .BAT file? | Here's a command to get you started:
```
FOR /F "tokens=4 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080') DO @ECHO TaskKill.exe /PID %%P
```
When you're confident in your batch file, remove `@ECHO`.
```
FOR /F "tokens=4 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080') DO TaskKill.exe /PID %%P
```
Note ... |
5777400 | How to use random in BATCH script? | 131 | 2011-04-25 10:18:58 | <p>How to use random in BATCH script?</p>
| 289,910 | 30,453 | 2018-09-17 20:55:56 | 5,777,608 | 155 | 2011-04-25 10:46:14 | 653,295 | 2011-04-25 10:46:14 | https://stackoverflow.com/q/5777400 | https://stackoverflow.com/a/5777608 | <p><code>%RANDOM%</code> gives you a random number between 0 and 32767.</p>
<p>Using an expression like <code>SET /A test=%RANDOM% * 100 / 32768 + 1</code>, you can change the range to anything you like (here the range is [1…100] instead of [0…32767]).</p>
| <p><code>%RANDOM%</code> gives you a random number between 0 and 32767.</p> <p>Using an expression like <code>SET /A test=%RANDOM% * 100 / 32768 + 1</code>, you can change the range to anything you like (here the range is [1…100] instead of [0…32767]).</p> | 64, 197, 2216, 7002 | batch-file, random, windows, windows-xp | <h1>How to use random in BATCH script?</h1>
<p>How to use random in BATCH script?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,953 | cmd | # How to use random in BATCH script?
How to use random in BATCH script? | `%RANDOM%` gives you a random number between 0 and 32767.
Using an expression like `SET /A test=%RANDOM% * 100 / 32768 + 1`, you can change the range to anything you like (here the range is [1…100] instead of [0…32767]). |
2763875 | Batch file include external file for variables | 112 | 2010-05-04 08:41:25 | <p>I have a batch file and I want to include an external file containing some variables (say configuration variables). Is it possible?</p>
| 161,672 | 315,427 | 2020-11-09 23:29:05 | 2,763,907 | 154 | 2010-05-04 08:47:23 | 73,070 | 2016-08-21 20:52:11 | https://stackoverflow.com/q/2763875 | https://stackoverflow.com/a/2763907 | <p><strong>Note:</strong> I'm assuming Windows batch files as most people seem to be unaware that there are significant differences and just blindly call everything with grey text on black background DOS. Nevertheless, the first variant should work in DOS as well.</p>
<h3>Executable configuration</h3>
<p>The easiest wa... | <p><strong>Note:</strong> I'm assuming Windows batch files as most people seem to be unaware that there are significant differences and just blindly call everything with grey text on black background DOS. Nevertheless, the first variant should work in DOS as well.</p> <h3>Executable configuration</h3> <p>The easiest wa... | 7002, 87541 | batch-file, transclusion | <h1>Batch file include external file for variables</h1>
<p>I have a batch file and I want to include an external file containing some variables (say configuration variables). Is it possible?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,954 | cmd | # Batch file include external file for variables
I have a batch file and I want to include an external file containing some variables (say configuration variables). Is it possible? | **Note:** I'm assuming Windows batch files as most people seem to be unaware that there are significant differences and just blindly call everything with grey text on black background DOS. Nevertheless, the first variant should work in DOS as well.
### Executable configuration
The easiest way to do this is to just pu... |
7308586 | using batch echo with special characters | 98 | 2011-09-05 13:10:39 | <p>This maybe really easy but there were no answers for it over the net. I want to echo a XML line via batch into a file but it misunderstands the XML closing tag for redirection ">". The line is as follows:</p>
<pre><code>echo <?xml version="1.0" encoding="utf-8" ?> > myfile.xml
</code></pre>
<p>is there an... | 258,250 | 2,308,801 | 2021-02-19 09:38:01 | 7,308,614 | 152 | 2011-09-05 13:13:07 | 73,070 | 2011-09-06 07:08:54 | https://stackoverflow.com/q/7308586 | https://stackoverflow.com/a/7308614 | <p>You can escape shell metacharacters with <code>^</code>:</p>
<pre><code>echo ^<?xml version="1.0" encoding="utf-8" ?^> > myfile.xml
</code></pre>
<p>Note that since <code>echo</code> is a shell built-in it doesn't follow the usual conventions regarding quoting, so just quoting the argument will output the... | <p>You can escape shell metacharacters with <code>^</code>:</p> <pre><code>echo ^<?xml version="1.0" encoding="utf-8" ?^> > myfile.xml </code></pre> <p>Note that since <code>echo</code> is a shell built-in it doesn't follow the usual conventions regarding quoting, so just quoting the argument will output the... | 2631, 4804, 7002, 13824 | batch-file, cmd, echo, escaping | <h1>using batch echo with special characters</h1>
<p>This maybe really easy but there were no answers for it over the net. I want to echo a XML line via batch into a file but it misunderstands the XML closing tag for redirection ">". The line is as follows:</p>
<pre><code>echo <?xml version="1.0" encoding="utf-8" ?... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,956 | cmd | # using batch echo with special characters
This maybe really easy but there were no answers for it over the net. I want to echo a XML line via batch into a file but it misunderstands the XML closing tag for redirection ">". The line is as follows:
```
echo <?xml version="1.0" encoding="utf-8" ?> > myfile.xml
```
is ... | You can escape shell metacharacters with `^`:
```
echo ^<?xml version="1.0" encoding="utf-8" ?^> > myfile.xml
```
Note that since `echo` is a shell built-in it doesn't follow the usual conventions regarding quoting, so just quoting the argument will output the quotes instead of removing them. |
16727941 | How do I execute cmd commands through a batch file? | 140 | 2013-05-24 05:01:55 | <p>I want to write a batch file that will do following things in given order:</p>
<ol>
<li>Open cmd</li>
<li>Run cmd command <code>cd c:\Program files\IIS Express</code></li>
<li>Run cmd command <code>iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0</code></li>
<li>Open <a href="http://en.wikipedia.org/wiki/... | 1,046,370 | 692,292 | 2021-07-05 15:36:56 | 16,728,012 | 151 | 2013-05-24 05:09:13 | 369 | 2013-05-24 05:32:04 | https://stackoverflow.com/q/16727941 | https://stackoverflow.com/a/16728012 | <p>So, make an actual batch file: open up notepad, type the commands you want to run, and save as a <code>.bat</code> file. Then double click the .bat file to run it.</p>
<p>Try something like this for a start:</p>
<pre><code>c:\
cd c:\Program files\IIS Express
start iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /... | <p>So, make an actual batch file: open up notepad, type the commands you want to run, and save as a <code>.bat</code> file. Then double click the .bat file to run it.</p> <p>Try something like this for a start:</p> <pre><code>c:\ cd c:\Program files\IIS Express start iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /... | 2631, 7002, 25844 | batch-file, cmd, windows-scripting | <h1>How do I execute cmd commands through a batch file?</h1>
<p>I want to write a batch file that will do following things in given order:</p>
<ol>
<li>Open cmd</li>
<li>Run cmd command <code>cd c:\Program files\IIS Express</code></li>
<li>Run cmd command <code>iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,957 | cmd | # How do I execute cmd commands through a batch file?
I want to write a batch file that will do following things in given order:
1. Open cmd
2. Run cmd command `cd c:\Program files\IIS Express`
3. Run cmd command `iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0`
4. Open [Internet Explorer 8](http://en.wiki... | So, make an actual batch file: open up notepad, type the commands you want to run, and save as a `.bat` file. Then double click the .bat file to run it.
Try something like this for a start:
```
c:\
cd c:\Program files\IIS Express
start iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
start http://localhost:... |
8606664 | How are environment variables used in Jenkins with Windows Batch Command? | 80 | 2011-12-22 16:14:21 | <p>I'm trying to use <strong>Jenkins (Global) environment variables</strong> in my xcopy script. </p>
<pre><code>${WORKSPACE} doesn't work
"${WORKSPACE}" doesn't work
'${WORKSPACE}' doesn't work
</code></pre>
| 121,632 | 609,058 | 2020-04-25 06:20:03 | 8,607,291 | 150 | 2011-12-22 16:59:00 | 1,012,053 | 2020-03-26 13:36:27 | https://stackoverflow.com/q/8606664 | https://stackoverflow.com/a/8607291 | <p>I know nothing about Jenkins, but it looks like you are trying to access environment variables using some form of unix syntax - that won't work.</p>
<p>If the name of the variable is WORKSPACE, then the value is expanded in Windows batch using<br>
<code>%WORKSPACE%</code>. That form of expansion is performed at par... | <p>I know nothing about Jenkins, but it looks like you are trying to access environment variables using some form of unix syntax - that won't work.</p> <p>If the name of the variable is WORKSPACE, then the value is expanded in Windows batch using<br> <code>%WORKSPACE%</code>. That form of expansion is performed at par... | 64, 3858, 7002, 64999 | batch-file, hudson, jenkins, windows | <h1>How are environment variables used in Jenkins with Windows Batch Command?</h1>
<p>I'm trying to use <strong>Jenkins (Global) environment variables</strong> in my xcopy script. </p>
<pre><code>${WORKSPACE} doesn't work
"${WORKSPACE}" doesn't work
'${WORKSPACE}' doesn't work
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,958 | cmd | # How are environment variables used in Jenkins with Windows Batch Command?
I'm trying to use **Jenkins (Global) environment variables** in my xcopy script.
```
${WORKSPACE} doesn't work
"${WORKSPACE}" doesn't work
'${WORKSPACE}' doesn't work
``` | I know nothing about Jenkins, but it looks like you are trying to access environment variables using some form of unix syntax - that won't work.
If the name of the variable is WORKSPACE, then the value is expanded in Windows batch using
`%WORKSPACE%`. That form of expansion is performed at parse time. For example, t... |
12703645 | How to resolve "'installutil' is not recognized as an internal or external command, operable program or batch file."? | 71 | 2012-10-03 07:20:02 | <p>Just tried to run an application via the following:</p>
<p><img src="https://i.sstatic.net/4jOEK.png" alt="enter image description here"></p>
<p>I have browsed to the directory with an app <code>WindowsService1.exe</code> in it, then tried the command <code>Installutil WindowsService1.exe</code> but got the follow... | 134,259 | 1,179,880 | 2022-05-03 17:13:33 | 12,703,878 | 146 | 2012-10-03 07:35:18 | 547,640 | 2020-01-10 07:34:20 | https://stackoverflow.com/q/12703645 | https://stackoverflow.com/a/12703878 | <p>This is a tiny bit off-topic but I've stopped using InstallUtil to install my services. It's is really easy to just add it to the service itself. Add a reference to <code>System.Configuration.Install</code> (not available in the Client Profile editions if I remember right) and then update your Main()-function in Pro... | <p>This is a tiny bit off-topic but I've stopped using InstallUtil to install my services. It's is really easy to just add it to the service itself. Add a reference to <code>System.Configuration.Install</code> (not available in the Client Profile editions if I remember right) and then update your Main()-function in Pro... | 9, 2631, 33953, 80825 | c#, cmd, visual-studio, visual-studio-2012 | <h1>How to resolve "'installutil' is not recognized as an internal or external command, operable program or batch file."?</h1>
<p>Just tried to run an application via the following:</p>
<p><img src="https://i.sstatic.net/4jOEK.png" alt="enter image description here"></p>
<p>I have browsed to the directory with an app... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,961 | cmd | # How to resolve "'installutil' is not recognized as an internal or external command, operable program or batch file."?
Just tried to run an application via the following:

I have browsed to the directory with an app `WindowsService1.exe` in it, then tr... | This is a tiny bit off-topic but I've stopped using InstallUtil to install my services. It's is really easy to just add it to the service itself. Add a reference to `System.Configuration.Install` (not available in the Client Profile editions if I remember right) and then update your Main()-function in Program.cs like t... |
197976 | Executing multiple commands from a Windows cmd script | 141 | 2008-10-13 15:23:54 | <p>I'm trying to write a Windows cmd script to perform several tasks in series.
However, it always stops after the first command in the script.</p>
<p>The command it stops after is a maven build (not sure if that's relevant).</p>
<p>How do I make it carry on and run each task in turn please?</p>
<p>Installing any so... | 293,287 | 151 | 2017-09-23 22:57:16 | 197,997 | 145 | 2008-10-13 15:31:36 | 3,937 | 2008-10-13 15:53:05 | https://stackoverflow.com/q/197976 | https://stackoverflow.com/a/197997 | <p>When you call another .bat file, I think you need "call" in front of the call:</p>
<pre><code>call otherCommand.bat
</code></pre>
| <p>When you call another .bat file, I think you need "call" in front of the call:</p> <pre><code>call otherCommand.bat </code></pre> | 64, 531, 2631, 7002 | batch-file, cmd, scripting, windows | <h1>Executing multiple commands from a Windows cmd script</h1>
<p>I'm trying to write a Windows cmd script to perform several tasks in series.
However, it always stops after the first command in the script.</p>
<p>The command it stops after is a maven build (not sure if that's relevant).</p>
<p>How do I make it carry... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,962 | cmd | # Executing multiple commands from a Windows cmd script
I'm trying to write a Windows cmd script to perform several tasks in series.
However, it always stops after the first command in the script.
The command it stops after is a maven build (not sure if that's relevant).
How do I make it carry on and run each task i... | When you call another .bat file, I think you need "call" in front of the call:
```
call otherCommand.bat
``` |
11081735 | How to use if - else structure in a batch file? | 182 | 2012-06-18 11:21:22 | <p>I have a question about if - else structure in a batch file. Each command runs individually, but I couldn't use "if - else" blocks safely so these parts of my programme doesn't work. How can I do make these parts run? Thank you.</p>
<pre class="lang-dos prettyprint-override"><code>IF %F%==1 IF %C%==1 (
... | 1,049,637 | 1,453,231 | 2025-09-14 10:39:00 | 11,081,861 | 144 | 2012-06-18 11:29:10 | 763,246 | 2024-03-17 22:02:13 | https://stackoverflow.com/q/11081735 | https://stackoverflow.com/a/11081861 | <p>Your syntax is incorrect. You can't use <code>ELSE IF</code>. It appears that you don't really need it anyway. Simply use multiple <code>IF</code> statements:</p>
<pre class="lang-dos prettyprint-override"><code>IF %F%==1 IF %C%==1 (
::copying the file c to d
copy "%sourceFile%" "%destinationF... | <p>Your syntax is incorrect. You can't use <code>ELSE IF</code>. It appears that you don't really need it anyway. Simply use multiple <code>IF</code> statements:</p> <pre class="lang-dos prettyprint-override"><code>IF %F%==1 IF %C%==1 ( ::copying the file c to d copy "%sourceFile%" "%destinationF... | 2773, 7002 | batch-file, if-statement | <h1>How to use if - else structure in a batch file?</h1>
<p>I have a question about if - else structure in a batch file. Each command runs individually, but I couldn't use "if - else" blocks safely so these parts of my programme doesn't work. How can I do make these parts run? Thank you.</p>
<pre class="lang-... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,963 | cmd | # How to use if - else structure in a batch file?
I have a question about if - else structure in a batch file. Each command runs individually, but I couldn't use "if - else" blocks safely so these parts of my programme doesn't work. How can I do make these parts run? Thank you.
```
IF %F%==1 IF %C%==1 (
::copying... | Your syntax is incorrect. You can't use `ELSE IF`. It appears that you don't really need it anyway. Simply use multiple `IF` statements:
```
IF %F%==1 IF %C%==1 (
::copying the file c to d
copy "%sourceFile%" "%destinationFile%"
)
IF %F%==1 IF %C%==0 (
::moving the file c to d
move "%sourceFile%" "%de... |
40873165 | Use docker run command to pass arguments to CMD in Dockerfile | 96 | 2016-11-29 18:29:02 | <p>I have a nodejs app can take two parameters when started. For example, I can use</p>
<pre><code>node server.js 0 dev
</code></pre>
<p>or</p>
<pre><code>node server.js 1 prod
</code></pre>
<p>to switch between production mode and dev mode and determine if it should turn the cluster on. Now I want to create docker ima... | 213,296 | 4,922,307 | 2024-04-17 17:25:14 | 40,873,331 | 143 | 2016-11-29 18:39:53 | 6,309 | 2023-04-04 11:32:51 | https://stackoverflow.com/q/40873165 | https://stackoverflow.com/a/40873331 | <p>Make sure your Dockerfile declares an environment variable <a href="https://docs.docker.com/engine/reference/builder/#env" rel="noreferrer">with <code>ENV</code></a>:</p>
<pre><code>ENV environment default_env_value
ENV cluster default_cluster_value
</code></pre>
<p>The <code>ENV <key> <value></code> for... | <p>Make sure your Dockerfile declares an environment variable <a href="https://docs.docker.com/engine/reference/builder/#env" rel="noreferrer">with <code>ENV</code></a>:</p> <pre><code>ENV environment default_env_value ENV cluster default_cluster_value </code></pre> <p>The <code>ENV <key> <value></code> for... | 46426, 90304, 108477, 164539 | docker, docker-cmd, dockerfile, node.js | <h1>Use docker run command to pass arguments to CMD in Dockerfile</h1>
<p>I have a nodejs app can take two parameters when started. For example, I can use</p>
<pre><code>node server.js 0 dev
</code></pre>
<p>or</p>
<pre><code>node server.js 1 prod
</code></pre>
<p>to switch between production mode and dev mode and dete... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,964 | cmd | # Use docker run command to pass arguments to CMD in Dockerfile
I have a nodejs app can take two parameters when started. For example, I can use
```
node server.js 0 dev
```
or
```
node server.js 1 prod
```
to switch between production mode and dev mode and determine if it should turn the cluster on. Now I want to... | Make sure your Dockerfile declares an environment variable [with `ENV`](https://docs.docker.com/engine/reference/builder/#env):
```
ENV environment default_env_value
ENV cluster default_cluster_value
```
The `ENV <key> <value>` form can be [replaced inline](https://docs.docker.com/engine/reference/builder/#environmen... |
14122732 | Unzip files (7-zip) via cmd command | 95 | 2013-01-02 13:14:15 | <p>I try to unzip a file via CMD.</p>
<p>So I install winzip (and its plugin to cmd), winrar and 7-zip.</p>
<p>But when I try to <a href="http://www.dotnetperls.com/7-zip-examples" rel="noreferrer">execute a command</a> via the CMD:</p>
<pre><code>7z e myzip.zip
</code></pre>
<p>It gives the next error:</p>
<pre><code>... | 303,437 | 1,029,733 | 2022-04-12 21:00:36 | 14,122,808 | 143 | 2013-01-02 13:19:12 | 207,511 | 2013-01-02 13:19:12 | https://stackoverflow.com/q/14122732 | https://stackoverflow.com/a/14122808 | <p>Doing the following in a command prompt works for me, also adding to my User environment variables worked fine as well:</p>
<pre><code>set PATH=%PATH%;C:\Program Files\7-Zip\
echo %PATH%
7z
</code></pre>
<p>You should see as output (or something similar - as this is on my laptop running Windows 7):</p>
<pre><code... | <p>Doing the following in a command prompt works for me, also adding to my User environment variables worked fine as well:</p> <pre><code>set PATH=%PATH%;C:\Program Files\7-Zip\ echo %PATH% 7z </code></pre> <p>You should see as output (or something similar - as this is on my laptop running Windows 7):</p> <pre><code... | 2631, 5680, 29470 | 7zip, cmd, winzip | <h1>Unzip files (7-zip) via cmd command</h1>
<p>I try to unzip a file via CMD.</p>
<p>So I install winzip (and its plugin to cmd), winrar and 7-zip.</p>
<p>But when I try to <a href="http://www.dotnetperls.com/7-zip-examples" rel="noreferrer">execute a command</a> via the CMD:</p>
<pre><code>7z e myzip.zip
</code></pre... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,965 | cmd | # Unzip files (7-zip) via cmd command
I try to unzip a file via CMD.
So I install winzip (and its plugin to cmd), winrar and 7-zip.
But when I try to [execute a command](http://www.dotnetperls.com/7-zip-examples) via the CMD:
```
7z e myzip.zip
```
It gives the next error:
```
7z is not recognized as an internal ... | Doing the following in a command prompt works for me, also adding to my User environment variables worked fine as well:
```
set PATH=%PATH%;C:\Program Files\7-Zip\
echo %PATH%
7z
```
You should see as output (or something similar - as this is on my laptop running Windows 7):
```
C:\Users\Phillip>set PATH=%PATH%;C:\P... |
20202880 | Open a folder with File explorer using .bat | 77 | 2013-11-25 20:42:22 | <p>What command should I use to open a specified path at the end of program.</p>
<pre><code>start "c:\Yaya\yoyo\"
</code></pre>
<p>Is not working</p>
| 190,402 | 3,019,006 | 2022-01-17 11:23:32 | 20,202,906 | 141 | 2013-11-25 20:43:40 | 1,501,794 | 2019-10-22 13:36:27 | https://stackoverflow.com/q/20202880 | https://stackoverflow.com/a/20202906 | <p>You can try like this:</p>
<pre class="lang-sh prettyprint-override"><code>%SystemRoot%\explorer.exe "c:\Yaya\yoyo\"
</code></pre>
| <p>You can try like this:</p> <pre class="lang-sh prettyprint-override"><code>%SystemRoot%\explorer.exe "c:\Yaya\yoyo\" </code></pre> | 7002 | batch-file | <h1>Open a folder with File explorer using .bat</h1>
<p>What command should I use to open a specified path at the end of program.</p>
<pre><code>start "c:\Yaya\yoyo\"
</code></pre>
<p>Is not working</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,966 | cmd | # Open a folder with File explorer using .bat
What command should I use to open a specified path at the end of program.
```
start "c:\Yaya\yoyo\"
```
Is not working | You can try like this:
```
%SystemRoot%\explorer.exe "c:\Yaya\yoyo\"
``` |
1355791 | How do you loop in a Windows batch file? | 195 | 2009-08-31 04:32:11 | <p>What is the syntax for a FOR loop in a Windows batch file?</p>
| 749,087 | 153,541 | 2022-06-29 06:45:53 | 1,355,800 | 140 | 2009-08-31 04:35:00 | 47,738 | 2018-09-22 22:06:27 | https://stackoverflow.com/q/1355791 | https://stackoverflow.com/a/1355800 | <pre><code>FOR %%A IN (list) DO command parameters
</code></pre>
<p><strong>list</strong> is a list of any elements, separated by either spaces, commas or semicolons.</p>
<p><strong>command</strong> can be any internal or external command, batch file or even - in OS/2 and NT - a list of commands</p>
<p><stron... | <pre><code>FOR %%A IN (list) DO command parameters </code></pre> <p><strong>list</strong> is a list of any elements, separated by either spaces, commas or semicolons.</p> <p><strong>command</strong> can be any internal or external command, batch file or even - in OS/2 and NT - a list of commands</p> <p><stron... | 7002 | batch-file | <h1>How do you loop in a Windows batch file?</h1>
<p>What is the syntax for a FOR loop in a Windows 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 | 11,967 | cmd | # How do you loop in a Windows batch file?
What is the syntax for a FOR loop in a Windows batch file? | ```
FOR %%A IN (list) DO command parameters
```
**list** is a list of any elements, separated by either spaces, commas or semicolons.
**command** can be any internal or external command, batch file or even - in OS/2 and NT - a list of commands
**parameters** contains the command line parameters for command.
In this ... |
27211427 | Find Process Name by its Process ID | 100 | 2014-11-30 08:29:17 | <p>Suppose I know the process ID. I want to find the process name by its ID, using windows batch script. How can I do this?</p>
| 225,526 | 625,265 | 2017-04-16 07:52:32 | 27,212,015 | 136 | 2014-11-30 09:56:23 | 2,861,476 | 2017-04-16 07:52:32 | https://stackoverflow.com/q/27211427 | https://stackoverflow.com/a/27212015 | <p>The basic one, ask tasklist to filter its output and only show the indicated process id information</p>
<pre><code>tasklist /fi "pid eq 4444"
</code></pre>
<p>To only get the process name, the line must be splitted</p>
<pre><code>for /f "delims=," %%a in ('
tasklist /fi "pid eq 4444" /nh /fo:csv
') do echo %... | <p>The basic one, ask tasklist to filter its output and only show the indicated process id information</p> <pre><code>tasklist /fi "pid eq 4444" </code></pre> <p>To only get the process name, the line must be splitted</p> <pre><code>for /f "delims=," %%a in (' tasklist /fi "pid eq 4444" /nh /fo:csv ') do echo %... | 64, 1231, 1987, 2631, 7002 | batch-file, cmd, command-line, operating-system, windows | <h1>Find Process Name by its Process ID</h1>
<p>Suppose I know the process ID. I want to find the process name by its ID, using windows batch script. How can I do this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,969 | cmd | # Find Process Name by its Process ID
Suppose I know the process ID. I want to find the process name by its ID, using windows batch script. How can I do this? | The basic one, ask tasklist to filter its output and only show the indicated process id information
```
tasklist /fi "pid eq 4444"
```
To only get the process name, the line must be splitted
```
for /f "delims=," %%a in ('
tasklist /fi "pid eq 4444" /nh /fo:csv
') do echo %%~a
```
In this case, the list of proc... |
1327431 | How do I escape ampersands in batch files? | 186 | 2009-08-25 10:39:10 | <p>How do I escape ampersands in a batch file (or from the
Windows command line) in order to use the <code>start</code> command to
open web pages with ampersands in the URL?</p>
<p>Double quotes will not work with <code>start</code>; this starts a new
command-line window instead.</p>
<p><strong>Update 1</strong>: ... | 156,497 | 63,550 | 2021-02-19 09:50:56 | 27,960,888 | 135 | 2015-01-15 09:59:31 | 700,926 | 2015-01-16 07:57:43 | https://stackoverflow.com/q/1327431 | https://stackoverflow.com/a/27960888 | <p><strong>From a cmd</strong>:</p>
<ul>
<li><code>&</code> is escaped like this: <code>^&</code> (based on @Wael Dalloul's <a href="https://stackoverflow.com/a/1327476/700926">answer</a>)</li>
<li><code>%</code> does not need to be escaped</li>
</ul>
<p>An example:</p>
<pre><code>start http://www.google.com... | <p><strong>From a cmd</strong>:</p> <ul> <li><code>&</code> is escaped like this: <code>^&</code> (based on @Wael Dalloul's <a href="https://stackoverflow.com/a/1327476/700926">answer</a>)</li> <li><code>%</code> does not need to be escaped</li> </ul> <p>An example:</p> <pre><code>start http://www.google.com... | 64, 2631, 4804, 7002, 32232 | ampersand, batch-file, cmd, escaping, windows | <h1>How do I escape ampersands in batch files?</h1>
<p>How do I escape ampersands in a batch file (or from the
Windows command line) in order to use the <code>start</code> command to
open web pages with ampersands in the URL?</p>
<p>Double quotes will not work with <code>start</code>; this starts a new
command-line... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,970 | cmd | # How do I escape ampersands in batch files?
How do I escape ampersands in a batch file (or from the
Windows command line) in order to use the `start` command to
open web pages with ampersands in the URL?
Double quotes will not work with `start`; this starts a new
command-line window instead.
**Update 1**: Wael Dall... | **From a cmd**:
- `&` is escaped like this: `^&` (based on @Wael Dalloul's [answer](https://stackoverflow.com/a/1327476/700926))
- `%` does not need to be escaped
An example:
```
start http://www.google.com/search?client=opera^&rls=en^&q=escape+ampersand%20and%20percentage+in+cmd^&sourceid=opera^&ie=utf-8^&oe=utf-8
... |
1458016 | Get user's non-truncated Active Directory groups from command line | 113 | 2009-09-22 03:45:27 | <p>I often use the <code>net user</code> command to have a look at AD groups for a user:</p>
<pre><code>net user /DOMAIN <username>
</code></pre>
<p>This works well, however the group names are truncated to around 20 characters. And in my organization, most group names are much longer than this.</p>
<p>Does a... | 277,682 | 26,633 | 2024-05-23 09:32:11 | 22,329,737 | 135 | 2014-03-11 15:10:47 | 87,796 | 2014-03-11 15:10:47 | https://stackoverflow.com/q/1458016 | https://stackoverflow.com/a/22329737 | <p><code>GPRESULT</code> is the right command, but it cannot be run without parameters. <code>/v</code> or verbose option is difficult to manage without also outputting to a text file. E.G. I recommend using</p>
<p><code>gpresult /user myAccount /v > C:\dev\me.txt</code>--Ensure C:\Dev\me.txt exists</p>
<p>Anoth... | <p><code>GPRESULT</code> is the right command, but it cannot be run without parameters. <code>/v</code> or verbose option is difficult to manage without also outputting to a text file. E.G. I recommend using</p> <p><code>gpresult /user myAccount /v > C:\dev\me.txt</code>--Ensure C:\Dev\me.txt exists</p> <p>Anoth... | 64, 2631, 10401 | active-directory, cmd, windows | <h1>Get user's non-truncated Active Directory groups from command line</h1>
<p>I often use the <code>net user</code> command to have a look at AD groups for a user:</p>
<pre><code>net user /DOMAIN <username>
</code></pre>
<p>This works well, however the group names are truncated to around 20 characters. And in... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,971 | cmd | # Get user's non-truncated Active Directory groups from command line
I often use the `net user` command to have a look at AD groups for a user:
```
net user /DOMAIN <username>
```
This works well, however the group names are truncated to around 20 characters. And in my organization, most group names are much longer ... | `GPRESULT` is the right command, but it cannot be run without parameters. `/v` or verbose option is difficult to manage without also outputting to a text file. E.G. I recommend using
`gpresult /user myAccount /v > C:\dev\me.txt`--Ensure C:\Dev\me.txt exists
Another option is to display summary information only which ... |
13713318 | Ping all addresses in network, windows | 63 | 2012-12-04 22:44:24 | <p>Is it possible in windows cmd line to check all of the network addresses (with ping or similar) to see which ones are taken/ have active devices:</p>
<p>ie. something that does something like the following:</p>
<pre><code>for i = 0 to 255
ping 192.168.1.i //Print this
end
</code></pre>
<p>This is psuedo code ... | 436,354 | 1,294,207 | 2022-12-24 01:55:10 | 13,713,380 | 135 | 2012-12-04 22:50:03 | 1,840,181 | 2022-12-24 01:55:10 | https://stackoverflow.com/q/13713318 | https://stackoverflow.com/a/13713380 | <p>Open the Command Prompt and type in the following:</p>
<pre><code>FOR /L %i IN (1,1,254) DO ping -n 1 192.168.10.%i | FIND /i "Reply">>c:\ipaddresses.txt
</code></pre>
<p>Change 192.168.10 to match you own network.</p>
<p>By using -n 1 you are asking for only 1 packet to be sent to each computer inst... | <p>Open the Command Prompt and type in the following:</p> <pre><code>FOR /L %i IN (1,1,254) DO ping -n 1 192.168.10.%i | FIND /i "Reply">>c:\ipaddresses.txt </code></pre> <p>Change 192.168.10 to match you own network.</p> <p>By using -n 1 you are asking for only 1 packet to be sent to each computer inst... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Ping all addresses in network, windows</h1>
<p>Is it possible in windows cmd line to check all of the network addresses (with ping or similar) to see which ones are taken/ have active devices:</p>
<p>ie. something that does something like the following:</p>
<pre><code>for i = 0 to 255
ping 192.168.1.i //Print... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,972 | cmd | # Ping all addresses in network, windows
Is it possible in windows cmd line to check all of the network addresses (with ping or similar) to see which ones are taken/ have active devices:
ie. something that does something like the following:
```
for i = 0 to 255
ping 192.168.1.i //Print this
end
```
This is psue... | Open the Command Prompt and type in the following:
```
FOR /L %i IN (1,1,254) DO ping -n 1 192.168.10.%i | FIND /i "Reply">>c:\ipaddresses.txt
```
Change 192.168.10 to match you own network.
By using -n 1 you are asking for only 1 packet to be sent to each computer instead of the usual 4 packets.
The above command ... |
2252979 | Windows batch: call more than one command in a FOR loop? | 148 | 2010-02-12 15:46:49 | <p>Is it possible in Windows batch file to call more than one command in a <strong>single</strong> <code>FOR</code> loop? Let's say for example I want to print the file name and after delete it:</p>
<pre><code>@ECHO OFF
FOR /r %%X IN (*.txt) DO (ECHO %%X DEL %%X)
REM the line above is invalid syntax.
</code></pre>
<p... | 253,312 | 260,080 | 2017-09-15 16:16:49 | 2,253,029 | 134 | 2010-02-12 15:52:16 | 177,058 | 2014-01-21 10:08:56 | https://stackoverflow.com/q/2252979 | https://stackoverflow.com/a/2253029 | <pre><code>FOR /r %%X IN (*) DO (ECHO %%X & DEL %%X)
</code></pre>
| <pre><code>FOR /r %%X IN (*) DO (ECHO %%X & DEL %%X) </code></pre> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Windows batch: call more than one command in a FOR loop?</h1>
<p>Is it possible in Windows batch file to call more than one command in a <strong>single</strong> <code>FOR</code> loop? Let's say for example I want to print the file name and after delete it:</p>
<pre><code>@ECHO OFF
FOR /r %%X IN (*.txt) DO (ECHO %%... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,973 | cmd | # Windows batch: call more than one command in a FOR loop?
Is it possible in Windows batch file to call more than one command in a **single** `FOR` loop? Let's say for example I want to print the file name and after delete it:
```
@ECHO OFF
FOR /r %%X IN (*.txt) DO (ECHO %%X DEL %%X)
REM the line above is invalid syn... | ```
FOR /r %%X IN (*) DO (ECHO %%X & DEL %%X)
``` |
672693 | Windows batch file starting directory when 'run as admin' | 106 | 2009-03-23 09:35:01 | <p>I have a batch file which is in a directory and must be run from there as well because it updates files within this directory.<br />
This works perfectly fine, except when the user runs the batch file as administrator (required on Vista). Then the starting directory is C:\Windows\System32.<br /><br />
Is there any w... | 80,226 | 34,022 | 2020-06-22 11:39:20 | 672,721 | 134 | 2009-03-23 09:42:36 | 25,782 | 2011-02-08 12:55:40 | https://stackoverflow.com/q/672693 | https://stackoverflow.com/a/672721 | <p>Try to access the batch files path like this:</p>
<pre><code>echo %~dp0
</code></pre>
<p>For more information see the following quote from the command <code>for /?</code> that describes how the above command works:</p>
<pre>
You can now use the following optional syntax:
%~I - expands %I removing any... | <p>Try to access the batch files path like this:</p> <pre><code>echo %~dp0 </code></pre> <p>For more information see the following quote from the command <code>for /?</code> that describes how the above command works:</p> <pre> You can now use the following optional syntax: %~I - expands %I removing any... | 64, 218, 1980, 7002, 28223 | batch-file, directory, uac, windows, windows-vista | <h1>Windows batch file starting directory when 'run as admin'</h1>
<p>I have a batch file which is in a directory and must be run from there as well because it updates files within this directory.<br />
This works perfectly fine, except when the user runs the batch file as administrator (required on Vista). Then the st... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,974 | cmd | # Windows batch file starting directory when 'run as admin'
I have a batch file which is in a directory and must be run from there as well because it updates files within this directory.
This works perfectly fine, except when the user runs the batch file as administrator (required on Vista). Then the starting direct... | Try to access the batch files path like this:
```
echo %~dp0
```
For more information see the following quote from the command `for /?` that describes how the above command works:
```
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - ex... |
13746177 | Batch files : How to leave the console window open | 113 | 2012-12-06 14:52:41 | <p>I have two batch files, one of them executes another, i.e.</p>
<ol>
<li>"My Batch File" > 2. "Some Other Batch File"</li>
</ol>
<p>I've created a shortcut of the first batch file and edited its properties to call its in following way.</p>
<pre><code>cmd.exe /k "<SomePath>\<My Batch File>.bat" & pa... | 267,460 | 426,305 | 2023-09-17 16:50:42 | 13,746,246 | 133 | 2012-12-06 14:56:00 | 2,441 | 2017-08-01 01:45:21 | https://stackoverflow.com/q/13746177 | https://stackoverflow.com/a/13746246 | <p>If that is really all the batch file is doing, remove the <code>cmd /K</code> and add <code>PAUSE</code>.</p>
<pre><code>start /B /LOW /WAIT make package
PAUSE
</code></pre>
<p>Then, just point your shortcut to <code>"My Batch File.bat"</code>...no need to run it with <code>CMD /K</code>.</p>
<h1>UPDATE</h1>
<p>... | <p>If that is really all the batch file is doing, remove the <code>cmd /K</code> and add <code>PAUSE</code>.</p> <pre><code>start /B /LOW /WAIT make package PAUSE </code></pre> <p>Then, just point your shortcut to <code>"My Batch File.bat"</code>...no need to run it with <code>CMD /K</code>.</p> <h1>UPDATE</h1> <p>... | 64, 7002 | batch-file, windows | <h1>Batch files : How to leave the console window open</h1>
<p>I have two batch files, one of them executes another, i.e.</p>
<ol>
<li>"My Batch File" > 2. "Some Other Batch File"</li>
</ol>
<p>I've created a shortcut of the first batch file and edited its properties to call its in following way.</p>
<pre><code>cmd.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,976 | cmd | # Batch files : How to leave the console window open
I have two batch files, one of them executes another, i.e.
1. "My Batch File" > 2. "Some Other Batch File"
I've created a shortcut of the first batch file and edited its properties to call its in following way.
```
cmd.exe /k "<SomePath>\<My Batch File>.bat" & pa... | If that is really all the batch file is doing, remove the `cmd /K` and add `PAUSE`.
```
start /B /LOW /WAIT make package
PAUSE
```
Then, just point your shortcut to `"My Batch File.bat"`...no need to run it with `CMD /K`.
# UPDATE
Ah, some new info...you're trying to do it from a pinned shortcut on the taskbar.
I ... |
3973824 | Windows Bat file optional argument parsing | 105 | 2010-10-20 00:05:04 | <p>I need my bat file to accept multiple optional named arguments.</p>
<pre><code>mycmd.bat man1 man2 -username alice -otheroption
</code></pre>
<p>For example my command has 2 mandatory parameters, and two optional parameters (-username) that has an argument value of alice, and -otheroption:</p>
<p>I'd like to be a... | 151,894 | 3,966 | 2024-09-06 06:09:47 | 3,981,086 | 133 | 2010-10-20 18:31:33 | 147,320 | 2016-12-29 21:30:11 | https://stackoverflow.com/q/3973824 | https://stackoverflow.com/a/3981086 | <p>Though I tend to agree with <a href="https://stackoverflow.com/questions/3973824/windows-bat-file-optional-argument-parsing#comment4250214_3973824">@AlekDavis' comment</a>, there are nonetheless several ways to do this in the NT shell.</p>
<p>The approach I would take advantage of the <a href="http://ss64.com/nt/sh... | <p>Though I tend to agree with <a href="https://stackoverflow.com/questions/3973824/windows-bat-file-optional-argument-parsing#comment4250214_3973824">@AlekDavis' comment</a>, there are nonetheless several ways to do this in the NT shell.</p> <p>The approach I would take advantage of the <a href="http://ss64.com/nt/sh... | 7002 | batch-file | <h1>Windows Bat file optional argument parsing</h1>
<p>I need my bat file to accept multiple optional named arguments.</p>
<pre><code>mycmd.bat man1 man2 -username alice -otheroption
</code></pre>
<p>For example my command has 2 mandatory parameters, and two optional parameters (-username) that has an argument value ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,977 | cmd | # Windows Bat file optional argument parsing
I need my bat file to accept multiple optional named arguments.
```
mycmd.bat man1 man2 -username alice -otheroption
```
For example my command has 2 mandatory parameters, and two optional parameters (-username) that has an argument value of alice, and -otheroption:
I'd ... | Though I tend to agree with [@AlekDavis' comment](https://stackoverflow.com/questions/3973824/windows-bat-file-optional-argument-parsing#comment4250214_3973824), there are nonetheless several ways to do this in the NT shell.
The approach I would take advantage of the [SHIFT](http://ss64.com/nt/shift.html) command and ... |
774175 | Show a popup/message box from a Windows batch file | 175 | 2009-04-21 19:21:54 | <p>Is there a way to display a message box from a batch file (similar to how <code>xmessage</code> can be used from bash-scripts in Linux)?</p>
| 751,545 | 93,896 | 2025-09-06 04:51:40 | 774,197 | 132 | 2009-04-21 19:26:00 | 55,153 | 2014-09-18 15:09:50 | https://stackoverflow.com/q/774175 | https://stackoverflow.com/a/774197 | <p>I would make a very simple VBScript file and call it using CScript to parse the command line parameters.</p>
<p>Something like the following saved in <code>MessageBox.vbs</code>:</p>
<pre><code>Set objArgs = WScript.Arguments
messageText = objArgs(0)
MsgBox messageText
</code></pre>
<p>Which you would call like:<... | <p>I would make a very simple VBScript file and call it using CScript to parse the command line parameters.</p> <p>Something like the following saved in <code>MessageBox.vbs</code>:</p> <pre><code>Set objArgs = WScript.Arguments messageText = objArgs(0) MsgBox messageText </code></pre> <p>Which you would call like:<... | 64, 1231, 7002, 7050 | batch-file, command-line, messagebox, windows | <h1>Show a popup/message box from a Windows batch file</h1>
<p>Is there a way to display a message box from a batch file (similar to how <code>xmessage</code> can be used from bash-scripts in Linux)?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,978 | cmd | # Show a popup/message box from a Windows batch file
Is there a way to display a message box from a batch file (similar to how `xmessage` can be used from bash-scripts in Linux)? | I would make a very simple VBScript file and call it using CScript to parse the command line parameters.
Something like the following saved in `MessageBox.vbs`:
```
Set objArgs = WScript.Arguments
messageText = objArgs(0)
MsgBox messageText
```
Which you would call like:
```
cscript MessageBox.vbs "This will be sho... |
12891383 | Correct quoting for cmd.exe for multiple arguments | 60 | 2012-10-15 07:54:19 | <p>I want to call</p>
<pre class="lang-sh prettyprint-override"><code>cmd /c "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" mysolution.sln /build "release|win32"
</code></pre>
<p>Unfortunately this does not work, because I get the error:</p>
<blockquote>
<p>'C:\Program' is not... | 118,157 | 181,874 | 2021-12-10 11:27:04 | 12,892,791 | 132 | 2012-10-15 09:29:56 | 1,322,642 | 2013-12-30 09:01:43 | https://stackoverflow.com/q/12891383 | https://stackoverflow.com/a/12892791 | <p>Note the <code>""</code> at the beginning and at the end!</p>
<p>Run a program and pass a Long Filename</p>
<pre><code>cmd /c write.exe "c:\sample documents\sample.txt"
</code></pre>
<hr>
<p>Spaces in Program Path</p>
<pre><code>cmd /c ""c:\Program Files\Microsoft Office\Office\Winword.exe""
</code></pre>
<hr>... | <p>Note the <code>""</code> at the beginning and at the end!</p> <p>Run a program and pass a Long Filename</p> <pre><code>cmd /c write.exe "c:\sample documents\sample.txt" </code></pre> <hr> <p>Spaces in Program Path</p> <pre><code>cmd /c ""c:\Program Files\Microsoft Office\Office\Winword.exe"" </code></pre> <hr>... | 2631 | cmd | <h1>Correct quoting for cmd.exe for multiple arguments</h1>
<p>I want to call</p>
<pre class="lang-sh prettyprint-override"><code>cmd /c "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" mysolution.sln /build "release|win32"
</code></pre>
<p>Unfortunately this does not work, beca... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,979 | cmd | # Correct quoting for cmd.exe for multiple arguments
I want to call
```
cmd /c "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" mysolution.sln /build "release|win32"
```
Unfortunately this does not work, because I get the error:
> 'C:\Program' is not recognized as an internal or external comman... | Note the `""` at the beginning and at the end!
Run a program and pass a Long Filename
```
cmd /c write.exe "c:\sample documents\sample.txt"
```
---
Spaces in Program Path
```
cmd /c ""c:\Program Files\Microsoft Office\Office\Winword.exe""
```
---
Spaces in Program Path + parameters
```
cmd /c ""c:\Program Files... |
55311842 | Windows Kill Process By PORT Number | 44 | 2019-03-23 08:05:41 | <p>I'm using embedded Tomcat server in Spring Tool Suite IDE. My problem is when I run my project there is an error as follows,</p>
<pre><code>***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The p... | 214,168 | 8,134,164 | 2019-07-05 04:46:53 | 55,312,303 | 132 | 2019-03-23 09:23:03 | 10,961,238 | 2019-07-05 04:46:53 | https://stackoverflow.com/q/55311842 | https://stackoverflow.com/a/55312303 | <blockquote>
<p>Solution 1: Kill Process</p>
</blockquote>
<p><em>Run command-line as an Administrator</em></p>
<pre><code>netstat -ano | findstr :<yourPortNumber>
taskkill /PID <typeyourPIDhere> /F
</code></pre>
<hr>
<blockquote>
<p>Solution 2: Change Port </p>
</blockquote>
<p><em>Please Make sur... | <blockquote> <p>Solution 1: Kill Process</p> </blockquote> <p><em>Run command-line as an Administrator</em></p> <pre><code>netstat -ano | findstr :<yourPortNumber> taskkill /PID <typeyourPIDhere> /F </code></pre> <hr> <blockquote> <p>Solution 2: Change Port </p> </blockquote> <p><em>Please Make sur... | 64, 700, 2631, 23014, 95875 | cmd, kill-process, port, spring-boot, windows | <h1>Windows Kill Process By PORT Number</h1>
<p>I'm using embedded Tomcat server in Spring Tool Suite IDE. My problem is when I run my project there is an error as follows,</p>
<pre><code>***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,980 | cmd | # Windows Kill Process By PORT Number
I'm using embedded Tomcat server in Spring Tool Suite IDE. My problem is when I run my project there is an error as follows,
```
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 80... | > Solution 1: Kill Process
*Run command-line as an Administrator*
```
netstat -ano | findstr :<yourPortNumber>
taskkill /PID <typeyourPIDhere> /F
```
---
> Solution 2: Change Port
*Please Make sure that new port you are going to set for your Application doesn't listen to any other process*
```
Change the port
se... |
49032646 | 'ls' is not recognized as an internal or external command, operable program or batch file | 68 | 2018-02-28 15:04:58 | <p>'ls' is not recognized as an internal or external command, operable program or batch file.
I get this error when I try to glance at the files of my folder.</p>
<ul>
<li>cmd opened regularly(not as an admin).</li>
<li><p>I've recently downloaded anaconda for python.During the installation process, there was a time w... | 375,277 | 7,904,302 | 2024-03-14 08:15:58 | 49,032,775 | 130 | 2018-02-28 15:11:58 | 7,908,770 | 2018-08-13 11:24:59 | https://stackoverflow.com/q/49032646 | https://stackoverflow.com/a/49032775 | <p>I'm fairly certain that the <code>ls</code> command is for Linux, not Windows (I'm assuming you're using Windows as you referred to <code>cmd</code>, which is the command line for the Windows OS).</p>
<p>You should use <code>dir</code> instead, which is the Windows equivalent of <code>ls</code>.</p>
<p><strong>Edi... | <p>I'm fairly certain that the <code>ls</code> command is for Linux, not Windows (I'm assuming you're using Windows as you referred to <code>cmd</code>, which is the command line for the Windows OS).</p> <p>You should use <code>dir</code> instead, which is the Windows equivalent of <code>ls</code>.</p> <p><strong>Edi... | 1796, 2631, 3589, 7002 | batch-file, cmd, command, ls | <h1>'ls' is not recognized as an internal or external command, operable program or batch file</h1>
<p>'ls' is not recognized as an internal or external command, operable program or batch file.
I get this error when I try to glance at the files of my folder.</p>
<ul>
<li>cmd opened regularly(not as an admin).</li>
<li>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 11,982 | cmd | # 'ls' is not recognized as an internal or external command, operable program or batch file
'ls' is not recognized as an internal or external command, operable program or batch file.
I get this error when I try to glance at the files of my folder.
- cmd opened regularly(not as an admin).
- I've recently downloaded an... | I'm fairly certain that the `ls` command is for Linux, not Windows (I'm assuming you're using Windows as you referred to `cmd`, which is the command line for the Windows OS).
You should use `dir` instead, which is the Windows equivalent of `ls`.
**Edit (since this post seems to be getting so many views :) ):**
You c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.