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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2144165 | Execute with parameters | 14 | 2010-01-27 02:20:09 | <p>I'm having difficulty executing a batch file in Java that expects parameters. These parameters may contain spaces so I need to wrap them in quotes. I will also need to do the same thing for Linux because some of the parameters may contain special characters such as <code>!</code>.</p>
<p>Non-functional Windows code... | 28,496 | 43,365 | 2010-01-27 02:52:42 | 2,144,201 | 17 | 2010-01-27 02:30:31 | 251,708 | 2010-01-27 02:43:51 | https://stackoverflow.com/q/2144165 | https://stackoverflow.com/a/2144201 | <p><strong>Windows:</strong></p>
<pre><code>ProcessBuilder pb = new ProcessBuilder(
"cmd", "/c", "mybat.bat",
"param 1", "param 2", "param 3");
</code></pre>
<p><strong>Unix:</strong></p>
<pre><code>ProcessBuilder pb = new ProcessBuilder(
"sh", "mybat.sh",
"param 1", "param 2", "par... | <p><strong>Windows:</strong></p> <pre><code>ProcessBuilder pb = new ProcessBuilder( "cmd", "/c", "mybat.bat", "param 1", "param 2", "param 3"); </code></pre> <p><strong>Unix:</strong></p> <pre><code>ProcessBuilder pb = new ProcessBuilder( "sh", "mybat.sh", "param 1", "param 2", "par... | 17, 7002 | batch-file, java | <h1>Execute with parameters</h1>
<p>I'm having difficulty executing a batch file in Java that expects parameters. These parameters may contain spaces so I need to wrap them in quotes. I will also need to do the same thing for Linux because some of the parameters may contain special characters such as <code>!</code>.</p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,080 | cmd | # Execute with parameters
I'm having difficulty executing a batch file in Java that expects parameters. These parameters may contain spaces so I need to wrap them in quotes. I will also need to do the same thing for Linux because some of the parameters may contain special characters such as `!`.
Non-functional Window... | **Windows:**
```
ProcessBuilder pb = new ProcessBuilder(
"cmd", "/c", "mybat.bat",
"param 1", "param 2", "param 3");
```
**Unix:**
```
ProcessBuilder pb = new ProcessBuilder(
"sh", "mybat.sh",
"param 1", "param 2", "param 3");
``` |
43497386 | curl xput windows Couldn't read data from file | 13 | 2017-04-19 13:37:31 | <p>I am using cURL in windows using command propmpt. When I am executing this command:</p>
<pre><code>curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@/path/myFeatures.json" -H "Content-type:application/json"
</code></pre>
<p>I am getting following error:</p>
<blockquote>
<pre><code... | 30,844 | 7,098,486 | 2020-01-25 20:54:31 | 43,505,752 | 17 | 2017-04-19 20:47:20 | 336,827 | 2017-04-19 20:47:20 | https://stackoverflow.com/q/43497386 | https://stackoverflow.com/a/43505752 | <p>If you really have a file named <code>myFeatures.json</code> into a folder named <code>path</code> in the current folder where you're trying to submit <code>curl</code>, just remove the leading slash from the path.</p>
<pre><code>curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@pat... | <p>If you really have a file named <code>myFeatures.json</code> into a folder named <code>path</code> in the current folder where you're trying to submit <code>curl</code>, just remove the leading slash from the path.</p> <pre><code>curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@pat... | 1508, 1554, 1866, 2631 | cmd, curl, json, solr | <h1>curl xput windows Couldn't read data from file</h1>
<p>I am using cURL in windows using command propmpt. When I am executing this command:</p>
<pre><code>curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@/path/myFeatures.json" -H "Content-type:application/json"
</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 | 13,081 | cmd | # curl xput windows Couldn't read data from file
I am using cURL in windows using command propmpt. When I am executing this command:
```
curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@/path/myFeatures.json" -H "Content-type:application/json"
```
I am getting following error:
> ``... | If you really have a file named `myFeatures.json` into a folder named `path` in the current folder where you're trying to submit `curl`, just remove the leading slash from the path.
```
curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@path/myFeatures.json" -H "Content-type:application... |
23923840 | How to set an integer as a environment variable? | 13 | 2014-05-29 00:14:54 | <p>I am trying to set an environment variable as below ,however row has an integer variable and running into following error,how to fix this?or is there a better way to set the environment variable using python</p>
<pre><code>row = 399
os.environ['BUILD_VER'] = row
</code></pre>
<p>ERROR:-</p>
<pre><code> os.envi... | 40,349 | 3,654,069 | 2014-05-29 01:38:58 | 23,923,867 | 17 | 2014-05-29 00:18:57 | 310,574 | 2014-05-29 01:38:58 | https://stackoverflow.com/q/23923840 | https://stackoverflow.com/a/23923867 | <p>Environment variables can only contain string values. You must do something like this:</p>
<pre><code>os.environ['BUILD_VER'] = str(row)
</code></pre>
<p>However, you have to understand that any environment variable you set will <em>only</em> take effect for the Python process and any process that it spawns after ... | <p>Environment variables can only contain string values. You must do something like this:</p> <pre><code>os.environ['BUILD_VER'] = str(row) </code></pre> <p>However, you have to understand that any environment variable you set will <em>only</em> take effect for the Python process and any process that it spawns after ... | 16, 64, 7002 | batch-file, python, windows | <h1>How to set an integer as a environment variable?</h1>
<p>I am trying to set an environment variable as below ,however row has an integer variable and running into following error,how to fix this?or is there a better way to set the environment variable using python</p>
<pre><code>row = 399
os.environ['BUILD_VER'] =... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,082 | cmd | # How to set an integer as a environment variable?
I am trying to set an environment variable as below ,however row has an integer variable and running into following error,how to fix this?or is there a better way to set the environment variable using python
```
row = 399
os.environ['BUILD_VER'] = row
```
ERROR:-
`... | Environment variables can only contain string values. You must do something like this:
```
os.environ['BUILD_VER'] = str(row)
```
However, you have to understand that any environment variable you set will *only* take effect for the Python process and any process that it spawns after setting it.
You can **not** use P... |
17241184 | Windows batch shift not working in if block | 13 | 2013-06-21 17:36:58 | <p>When I try to use <code>SHIFT</code> inside of an <code>IF</code> block I'm seeing some unexpected results. Using this:</p>
<pre><code>@echo off
if "%1"=="/p" (
echo %1
shift
echo "shifted"
echo %1
)
</code></pre>
<p>I get the following:</p>
<pre><code>C:\>ex.bat /p HAI
/p
"shifted"
/p
</code>... | 5,046 | 1,059,895 | 2020-11-09 14:59:21 | 17,241,649 | 17 | 2013-06-21 18:06:24 | 1,012,053 | 2016-07-15 22:52:50 | https://stackoverflow.com/q/17241184 | https://stackoverflow.com/a/17241649 | <p>That is the expected behavior because <code>%1</code> is expanded when the line is parsed, and the entire parenthesized IF construct is parsed all in one pass. So you cannot see the result of the SHIFT until a new line is parsed, which won't happen until after you have left your parenthesized block.</p>
<p>The same... | <p>That is the expected behavior because <code>%1</code> is expanded when the line is parsed, and the entire parenthesized IF construct is parsed all in one pass. So you cannot see the result of the SHIFT until a new line is parsed, which won't happen until after you have left your parenthesized block.</p> <p>The same... | 64, 7002 | batch-file, windows | <h1>Windows batch shift not working in if block</h1>
<p>When I try to use <code>SHIFT</code> inside of an <code>IF</code> block I'm seeing some unexpected results. Using this:</p>
<pre><code>@echo off
if "%1"=="/p" (
echo %1
shift
echo "shifted"
echo %1
)
</code></pre>
<p>I get the following:</p>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,083 | cmd | # Windows batch shift not working in if block
When I try to use `SHIFT` inside of an `IF` block I'm seeing some unexpected results. Using this:
```
@echo off
if "%1"=="/p" (
echo %1
shift
echo "shifted"
echo %1
)
```
I get the following:
```
C:\>ex.bat /p HAI
/p
"shifted"
/p
```
However, when I us... | That is the expected behavior because `%1` is expanded when the line is parsed, and the entire parenthesized IF construct is parsed all in one pass. So you cannot see the result of the SHIFT until a new line is parsed, which won't happen until after you have left your parenthesized block.
The same problem happens when... |
13150676 | using errorlevel in a batch file to know if a program exited normally | 13 | 2012-10-31 03:01:31 | <p>We have a program that is occasionally crashing. The customer runs the program from a scheduled task. When the program is run with a certain parameter, the program runs as an interface engine, creating a file and then ftp'ing the file to another server for import by another program. </p>
<p>I was wondering if I mig... | 40,149 | 1,787,319 | 2016-03-21 10:42:25 | 17,076,252 | 17 | 2013-06-12 22:10:35 | 118,228 | 2014-02-28 23:23:53 | https://stackoverflow.com/q/13150676 | https://stackoverflow.com/a/17076252 | <p>I would write it like so:</p>
<pre><code>:start
myPgm.exe intfc
IF %errorlevel% NEQ 0 GOTO :error
GOTO :end
:error
echo There was an error.
EXIT 1
:end
echo End.
EXIT 0
</code></pre>
| <p>I would write it like so:</p> <pre><code>:start myPgm.exe intfc IF %errorlevel% NEQ 0 GOTO :error GOTO :end :error echo There was an error. EXIT 1 :end echo End. EXIT 0 </code></pre> | 7002 | batch-file | <h1>using errorlevel in a batch file to know if a program exited normally</h1>
<p>We have a program that is occasionally crashing. The customer runs the program from a scheduled task. When the program is run with a certain parameter, the program runs as an interface engine, creating a file and then ftp'ing the file to ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,084 | cmd | # using errorlevel in a batch file to know if a program exited normally
We have a program that is occasionally crashing. The customer runs the program from a scheduled task. When the program is run with a certain parameter, the program runs as an interface engine, creating a file and then ftp'ing the file to another s... | I would write it like so:
```
:start
myPgm.exe intfc
IF %errorlevel% NEQ 0 GOTO :error
GOTO :end
:error
echo There was an error.
EXIT 1
:end
echo End.
EXIT 0
``` |
59648509 | Batch normalization when batch size=1 | 12 | 2020-01-08 14:57:55 | <p>What will happen when I use batch normalization but set <code>batch_size = 1</code>?</p>
<p>Because I am using 3D medical images as training dataset, the batch size can only be set to 1 because of GPU limitation. Normally, I know, when <code>batch_size = 1</code>, variance will be 0. And <code>(x-mean)/variance</co... | 18,740 | 9,229,923 | 2021-12-26 14:16:32 | 59,699,724 | 17 | 2020-01-11 23:47:12 | 10,133,797 | 2021-12-26 14:16:32 | https://stackoverflow.com/q/59648509 | https://stackoverflow.com/a/59699724 | <blockquote>
<p>variance will be 0</p>
</blockquote>
<p>No, it won't; <code>BatchNormalization</code> computes statistics only with respect to a <em>single axis</em> (usually the channels axis, <code>=-1</code> (last) by default); every other axis is <em>collapsed</em>, i.e. summed over for averaging; details below.</p... | <blockquote> <p>variance will be 0</p> </blockquote> <p>No, it won't; <code>BatchNormalization</code> computes statistics only with respect to a <em>single axis</em> (usually the channels axis, <code>=-1</code> (last) by default); every other axis is <em>collapsed</em>, i.e. summed over for averaging; details below.</p... | 16, 100570, 112144, 115813, 124994 | batch-normalization, deep-learning, keras, python, tensorflow | <h1>Batch normalization when batch size=1</h1>
<p>What will happen when I use batch normalization but set <code>batch_size = 1</code>?</p>
<p>Because I am using 3D medical images as training dataset, the batch size can only be set to 1 because of GPU limitation. Normally, I know, when <code>batch_size = 1</code>, vari... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,085 | cmd | # Batch normalization when batch size=1
What will happen when I use batch normalization but set `batch_size = 1`?
Because I am using 3D medical images as training dataset, the batch size can only be set to 1 because of GPU limitation. Normally, I know, when `batch_size = 1`, variance will be 0. And `(x-mean)/variance... | > variance will be 0
No, it won't; `BatchNormalization` computes statistics only with respect to a *single axis* (usually the channels axis, `=-1` (last) by default); every other axis is *collapsed*, i.e. summed over for averaging; details below.
More importantly, however, unless you can explicitly justify it, I advi... |
42618277 | How to set a run/debug configuration in IntelliJ IDEA using a Jar file? | 12 | 2017-03-06 05:38:15 | <p>Thanks for welcoming me to the community!</p>
<p>I'd like to get some help regarding Run/Debug configuration in IntelliJ IDEA. We use a .jar file and I need to setup a run configuration in my IDE. I go to <strong>Run>Edit Configurations>JAR Application</strong> and then the various options pop up.
I have the .... | 14,531 | 7,664,445 | 2022-01-07 07:03:53 | 42,618,393 | 17 | 2017-03-06 05:47:33 | 5,797,593 | 2017-03-06 06:28:00 | https://stackoverflow.com/q/42618277 | https://stackoverflow.com/a/42618393 | <p>Welcome Manan! You should be able to create a target for the jar application in IntelliJ by following these steps.</p>
<blockquote>
<p>EDIT: Upon initially reading your question I didn't see you already
had the steps for creating a new jar configuration, but I'll leave the
images here for future readers.</p>... | <p>Welcome Manan! You should be able to create a target for the jar application in IntelliJ by following these steps.</p> <blockquote> <p>EDIT: Upon initially reading your question I didn't see you already had the steps for creating a new jar configuration, but I'll leave the images here for future readers.</p>... | 17, 4841, 7002, 8945, 41127 | batch-file, intellij-idea, jar, java, maven | <h1>How to set a run/debug configuration in IntelliJ IDEA using a Jar file?</h1>
<p>Thanks for welcoming me to the community!</p>
<p>I'd like to get some help regarding Run/Debug configuration in IntelliJ IDEA. We use a .jar file and I need to setup a run configuration in my IDE. I go to <strong>Run>Edit Configurati... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,086 | cmd | # How to set a run/debug configuration in IntelliJ IDEA using a Jar file?
Thanks for welcoming me to the community!
I'd like to get some help regarding Run/Debug configuration in IntelliJ IDEA. We use a .jar file and I need to setup a run configuration in my IDE. I go to **Run>Edit Configurations>JAR Application** an... | Welcome Manan! You should be able to create a target for the jar application in IntelliJ by following these steps.
> EDIT: Upon initially reading your question I didn't see you already
> had the steps for creating a new jar configuration, but I'll leave the
> images here for future readers.
First, open your run/debug... |
23552267 | Square bracket notation around variable in cmd / DOS batch scripts | 12 | 2014-05-08 20:50:16 | <p>I've seen cmd batch scripts using square notation to surround a variable. For example:</p>
<pre><code>@echo off
if [%1]==[] (
echo no parameter entered
) else (
echo param1 is %1
)
</code></pre>
<p>What is the purpose of this?</p>
| 8,389 | 651,934 | 2019-06-06 11:29:13 | 23,553,042 | 17 | 2014-05-08 21:40:14 | 2,152,082 | 2019-06-06 11:29:13 | https://stackoverflow.com/q/23552267 | https://stackoverflow.com/a/23553042 | <p>it is used for proper syntax. Just imagine, you want to check, if a variable is empty:</p>
<pre><code>if %var%== echo bla
</code></pre>
<p>obviously will fail. (wrong syntax)</p>
<p>Instead:</p>
<pre><code>if "%var%"=="" echo bla
</code></pre>
<p>works fine.</p>
<p>Another "bad thing": you want to check a vari... | <p>it is used for proper syntax. Just imagine, you want to check, if a variable is empty:</p> <pre><code>if %var%== echo bla </code></pre> <p>obviously will fail. (wrong syntax)</p> <p>Instead:</p> <pre><code>if "%var%"=="" echo bla </code></pre> <p>works fine.</p> <p>Another "bad thing": you want to check a vari... | 2631, 7002 | batch-file, cmd | <h1>Square bracket notation around variable in cmd / DOS batch scripts</h1>
<p>I've seen cmd batch scripts using square notation to surround a variable. For example:</p>
<pre><code>@echo off
if [%1]==[] (
echo no parameter entered
) else (
echo param1 is %1
)
</code></pre>
<p>What is the purpose of this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,087 | cmd | # Square bracket notation around variable in cmd / DOS batch scripts
I've seen cmd batch scripts using square notation to surround a variable. For example:
```
@echo off
if [%1]==[] (
echo no parameter entered
) else (
echo param1 is %1
)
```
What is the purpose of this? | it is used for proper syntax. Just imagine, you want to check, if a variable is empty:
```
if %var%== echo bla
```
obviously will fail. (wrong syntax)
Instead:
```
if "%var%"=="" echo bla
```
works fine.
Another "bad thing": you want to check a variable, but it may be empty:
```
if %var%==bla echo bla
```
works... |
19912941 | Convert all CR to CRLF in text file using CMD | 12 | 2013-11-11 18:08:35 | <p>Is there a way to convert all CRs to CRLFs in a text file?</p>
<p>When I open a text file from Linux server on Windows, all text is displayed in one line, but actually it's a multi line one.</p>
<p>I'd like to perform the conversion in a batch file. </p>
<p>Can anyone advice, please?</p>
| 54,630 | 2,980,060 | 2019-12-13 10:27:21 | 19,914,445 | 17 | 2013-11-11 19:38:55 | 68,204 | 2013-11-11 19:38:55 | https://stackoverflow.com/q/19912941 | https://stackoverflow.com/a/19914445 | <p>Line separators and line terminators have been a source of compatibility friction between systems as long as there has been more than one kind of system and an urge to exchange data. The <a href="http://en.wikipedia.org/wiki/Newline">Wikipedia article on the Newline</a> has a decent overview of the historical contex... | <p>Line separators and line terminators have been a source of compatibility friction between systems as long as there has been more than one kind of system and an urge to exchange data. The <a href="http://en.wikipedia.org/wiki/Newline">Wikipedia article on the Newline</a> has a decent overview of the historical contex... | 2631, 3705, 7002 | batch-file, cmd, newline | <h1>Convert all CR to CRLF in text file using CMD</h1>
<p>Is there a way to convert all CRs to CRLFs in a text file?</p>
<p>When I open a text file from Linux server on Windows, all text is displayed in one line, but actually it's a multi line one.</p>
<p>I'd like to perform the conversion in a batch file. </p>
<p>C... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,088 | cmd | # Convert all CR to CRLF in text file using CMD
Is there a way to convert all CRs to CRLFs in a text file?
When I open a text file from Linux server on Windows, all text is displayed in one line, but actually it's a multi line one.
I'd like to perform the conversion in a batch file.
Can anyone advice, please? | Line separators and line terminators have been a source of compatibility friction between systems as long as there has been more than one kind of system and an urge to exchange data. The [Wikipedia article on the Newline](http://en.wikipedia.org/wiki/Newline) has a decent overview of the historical context. And, it sug... |
3008567 | Windows batch script to delete everything in a folder except one | 12 | 2010-06-09 18:09:17 | <p>I have a script to delete all subfolders and files in a folder:</p>
<pre><code>FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" & DEL /Q "D:\myfolder\*.*"
</code></pre>
<p>And it works great!
Only problem is that I would like to exclude one or more folders, like the XCOPY exclude feature.</p>
<p>I just cant... | 20,586 | 41,461 | 2016-09-02 12:38:34 | 3,009,151 | 17 | 2010-06-09 19:23:01 | 163,551 | 2010-06-09 19:23:01 | https://stackoverflow.com/q/3008567 | https://stackoverflow.com/a/3009151 | <p>You could try to hide the folders before the for-loop, and unhide them afterwards, like this:</p>
<pre><code>ATTRIB +H D:\myfolder\keepit
FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" DEL /Q "D:\myfolder\*.*"
ATTRIB -H D:\myfolder\keepit
</code></pre>
| <p>You could try to hide the folders before the for-loop, and unhide them afterwards, like this:</p> <pre><code>ATTRIB +H D:\myfolder\keepit FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" DEL /Q "D:\myfolder\*.*" ATTRIB -H D:\myfolder\keepit </code></pre> | 64, 1231, 7002 | batch-file, command-line, windows | <h1>Windows batch script to delete everything in a folder except one</h1>
<p>I have a script to delete all subfolders and files in a folder:</p>
<pre><code>FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" & DEL /Q "D:\myfolder\*.*"
</code></pre>
<p>And it works great!
Only problem is that I would like to exclud... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,090 | cmd | # Windows batch script to delete everything in a folder except one
I have a script to delete all subfolders and files in a folder:
```
FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" & DEL /Q "D:\myfolder\*.*"
```
And it works great!
Only problem is that I would like to exclude one or more folders, like the XCOPY ... | You could try to hide the folders before the for-loop, and unhide them afterwards, like this:
```
ATTRIB +H D:\myfolder\keepit
FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" DEL /Q "D:\myfolder\*.*"
ATTRIB -H D:\myfolder\keepit
``` |
57108602 | Batch delete all files and directories except specified file and directory | 11 | 2019-07-19 08:36:28 | <p>I'm trying to delete all files and directories in a specific directory using a bat file in said directory. I've seen this done on Linux without problem, but in Windows command environment it seems to be a chore.</p>
<p>Example: \temp\1.bat (keep) \temp\special folder (keep) </p>
<p>Inside \temp\ contains all the f... | 35,175 | 10,784,289 | 2022-06-05 17:41:19 | 57,110,620 | 17 | 2019-07-19 10:36:37 | 2,128,947 | 2019-07-19 10:36:37 | https://stackoverflow.com/q/57108602 | https://stackoverflow.com/a/57110620 | <pre class="lang-dos prettyprint-override"><code>@ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
SET "keepfile=1.bat"
SET "keepdir=keep me"
FOR /d %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="%keepdir%" RD /S /Q "%%a"
FOR %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="%keepfile%" DEL "%%a"
GOTO :EOF
</code></pr... | <pre class="lang-dos prettyprint-override"><code>@ECHO OFF SETLOCAL SET "sourcedir=U:\sourcedir" SET "keepfile=1.bat" SET "keepdir=keep me" FOR /d %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="%keepdir%" RD /S /Q "%%a" FOR %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="%keepfile%" DEL "%%a" GOTO :EOF </code></pr... | 2631, 7002 | batch-file, cmd | <h1>Batch delete all files and directories except specified file and directory</h1>
<p>I'm trying to delete all files and directories in a specific directory using a bat file in said directory. I've seen this done on Linux without problem, but in Windows command environment it seems to be a chore.</p>
<p>Example: \tem... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,091 | cmd | # Batch delete all files and directories except specified file and directory
I'm trying to delete all files and directories in a specific directory using a bat file in said directory. I've seen this done on Linux without problem, but in Windows command environment it seems to be a chore.
Example: \temp\1.bat (keep) \... | ```
@ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
SET "keepfile=1.bat"
SET "keepdir=keep me"
FOR /d %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="%keepdir%" RD /S /Q "%%a"
FOR %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="%keepfile%" DEL "%%a"
GOTO :EOF
```
You would need to change the setting of `sourcedir`... |
54266324 | installing packages with pip returns error | 11 | 2019-01-19 10:53:09 | <p>a while ago i downloaded pip from <a href="https://pip.pypa.io/en/stable/installing/" rel="noreferrer">https://pip.pypa.io/en/stable/installing/</a>
before i realised my version of python allready comes with pip. i succesfully used it to download pygame but now i am trying to download numpy and no matter what i try ... | 33,081 | 10,800,169 | 2019-01-19 13:58:21 | 54,267,769 | 17 | 2019-01-19 13:50:22 | 5,386,668 | 2019-01-19 13:58:21 | https://stackoverflow.com/q/54266324 | https://stackoverflow.com/a/54267769 | <p>Try this:</p>
<p><code>C:\Users\riley> pip install --trusted-host pypi.org numpy</code></p>
<p>More info <a href="https://stackoverflow.com/a/29751768/5386668">here</a>.</p>
| <p>Try this:</p> <p><code>C:\Users\riley> pip install --trusted-host pypi.org numpy</code></p> <p>More info <a href="https://stackoverflow.com/a/29751768/5386668">here</a>.</p> | 16, 2631, 5119, 13613 | cmd, package, pip, python | <h1>installing packages with pip returns error</h1>
<p>a while ago i downloaded pip from <a href="https://pip.pypa.io/en/stable/installing/" rel="noreferrer">https://pip.pypa.io/en/stable/installing/</a>
before i realised my version of python allready comes with pip. i succesfully used it to download pygame but now i a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,092 | cmd | # installing packages with pip returns error
a while ago i downloaded pip from <https://pip.pypa.io/en/stable/installing/>
before i realised my version of python allready comes with pip. i succesfully used it to download pygame but now i am trying to download numpy and no matter what i try it returns the error below.
... | Try this:
`C:\Users\riley> pip install --trusted-host pypi.org numpy`
More info [here](https://stackoverflow.com/a/29751768/5386668). |
16567432 | How is the skipping implemented in Spring Batch? | 11 | 2013-05-15 14:12:40 | <p>I was wondering how I could determine in my <code>ItemWriter</code>, whether Spring Batch was currently in chunk-processing-mode or in the fallback single-item-processing-mode. In the first place I didn't find the information how this fallback mechanism is implemented anyway.</p>
<p>Even if I haven't found the solu... | 13,419 | 193,705 | 2014-10-08 09:07:31 | 16,567,433 | 17 | 2013-05-15 14:12:40 | 193,705 | 2014-10-08 09:07:31 | https://stackoverflow.com/q/16567432 | https://stackoverflow.com/a/16567433 | <p>The implementation of the skip mechanism can be found in the <a href="http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.html">FaultTolerantChunkProcessor</a> and in the <a href="http://static.springsource.org/spring-batch/apidocs/org/springframew... | <p>The implementation of the skip mechanism can be found in the <a href="http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.html">FaultTolerantChunkProcessor</a> and in the <a href="http://static.springsource.org/spring-batch/apidocs/org/springframew... | 1170, 5971, 22013, 41895 | chunks, fallback, skip, spring-batch | <h1>How is the skipping implemented in Spring Batch?</h1>
<p>I was wondering how I could determine in my <code>ItemWriter</code>, whether Spring Batch was currently in chunk-processing-mode or in the fallback single-item-processing-mode. In the first place I didn't find the information how this fallback mechanism is im... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,094 | cmd | # How is the skipping implemented in Spring Batch?
I was wondering how I could determine in my `ItemWriter`, whether Spring Batch was currently in chunk-processing-mode or in the fallback single-item-processing-mode. In the first place I didn't find the information how this fallback mechanism is implemented anyway.
E... | The implementation of the skip mechanism can be found in the [FaultTolerantChunkProcessor](http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.html) and in the [RetryTemplate](http://static.springsource.org/spring-batch/apidocs/org/springframework/bat... |
212906 | Script to associate an extension to a program | 11 | 2008-10-17 16:41:58 | <p>My customer is replacing MS Office with OpenOffice in some workstations. My program export a file to Excel using the .xml extension (using open format) and opens it using the current associated program (using ShellExecute)</p>
<p>The problem is that OpenOffice does not register the .xml extension associated with it... | 27,339 | 2,385 | 2012-09-18 17:32:39 | 212,921 | 17 | 2008-10-17 16:47:06 | 18,771 | 2008-10-17 17:48:42 | https://stackoverflow.com/q/212906 | https://stackoverflow.com/a/212921 | <p>The real association is stored in the key that <code>"HKEY_CLASSES_ROOT\.xml"</code> points to.</p>
<p>On my machine, the default value of that key says <code>"xmlfile"</code>, most likely that is the same for yours.</p>
<p>So let's go to <code>"HKEY_CLASSES_ROOT\xmlfile"</code>. There you can see (and change) wha... | <p>The real association is stored in the key that <code>"HKEY_CLASSES_ROOT\.xml"</code> points to.</p> <p>On my machine, the default value of that key says <code>"xmlfile"</code>, most likely that is the same for yours.</p> <p>So let's go to <code>"HKEY_CLASSES_ROOT\xmlfile"</code>. There you can see (and change) wha... | 263, 531, 4207, 5310, 7002 | batch-file, file, openoffice.org, registry, scripting | <h1>Script to associate an extension to a program</h1>
<p>My customer is replacing MS Office with OpenOffice in some workstations. My program export a file to Excel using the .xml extension (using open format) and opens it using the current associated program (using ShellExecute)</p>
<p>The problem is that OpenOffice ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,096 | cmd | # Script to associate an extension to a program
My customer is replacing MS Office with OpenOffice in some workstations. My program export a file to Excel using the .xml extension (using open format) and opens it using the current associated program (using ShellExecute)
The problem is that OpenOffice does not registe... | The real association is stored in the key that `"HKEY_CLASSES_ROOT\.xml"` points to.
On my machine, the default value of that key says `"xmlfile"`, most likely that is the same for yours.
So let's go to `"HKEY_CLASSES_ROOT\xmlfile"`. There you can see (and change) what command is going to be used to launch that type ... |
30463758 | How to create a Simple Build Script for Visual Studio from the Command Line? | 10 | 2015-05-26 16:11:55 | <p>I have a lot of Visual Studio Project Solutions in multiple directories (all with the extension .sln) and I want to write a simple batch script that will automatically build all solutions listed in the batch file.</p>
<p>I am able to manually build a solution by starting up the <code>Visual Studio Command Prompt</c... | 38,552 | 4,512,948 | 2015-06-02 14:13:34 | 30,464,597 | 17 | 2015-05-26 16:55:38 | 4,512,948 | 2015-06-02 14:13:34 | https://stackoverflow.com/q/30463758 | https://stackoverflow.com/a/30464597 | <p>Found the solution, as noted by Jimmy, one needs to remove the environment variable <code>%comspec%</code> as that is a shortcut to CMD.exe. </p>
<p>However, just removing <code>"%comspec" /k</code> will cause a CMD instance to open and then exit after a second. I also previously tried the <code>call</code> functio... | <p>Found the solution, as noted by Jimmy, one needs to remove the environment variable <code>%comspec%</code> as that is a shortcut to CMD.exe. </p> <p>However, just removing <code>"%comspec" /k</code> will cause a CMD instance to open and then exit after a second. I also previously tried the <code>call</code> functio... | 2631, 7002, 13693, 80825 | batch-file, build-script, cmd, visual-studio-2012 | <h1>How to create a Simple Build Script for Visual Studio from the Command Line?</h1>
<p>I have a lot of Visual Studio Project Solutions in multiple directories (all with the extension .sln) and I want to write a simple batch script that will automatically build all solutions listed in the batch file.</p>
<p>I am able... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,097 | cmd | # How to create a Simple Build Script for Visual Studio from the Command Line?
I have a lot of Visual Studio Project Solutions in multiple directories (all with the extension .sln) and I want to write a simple batch script that will automatically build all solutions listed in the batch file.
I am able to manually bui... | Found the solution, as noted by Jimmy, one needs to remove the environment variable `%comspec%` as that is a shortcut to CMD.exe.
However, just removing `"%comspec" /k` will cause a CMD instance to open and then exit after a second. I also previously tried the `call` function which created a separate CMD instance when... |
12583349 | Command to open "Configure advanced user profile properties" (Windows 7) | 10 | 2012-09-25 12:51:56 | <p>I'm trying to figure out how to open the "Configure advanced user profile properties" control panel window by command line, so that I can provide a link to it in my application.</p>
<p>It can be opened without going through the control panel by typing "userprofile" in Start->Search box. So I assume that it must hav... | 79,898 | 934,676 | 2022-10-16 20:47:45 | 12,587,748 | 17 | 2012-09-25 17:02:44 | 1,123,692 | 2016-06-28 14:47:04 | https://stackoverflow.com/q/12583349 | https://stackoverflow.com/a/12587748 | <p>The actual command line for <code>Configure advanced user profile properties</code> is:<br>
<code>rundll32.exe sysdm.cpl,EditUserProfiles</code>. You can just copy & paste this into cmd window to run.</p>
<p><strong>Further reading:</strong> <a href="https://archive.is/EMb0j#selection-1805.20-1805.59" rel="nore... | <p>The actual command line for <code>Configure advanced user profile properties</code> is:<br> <code>rundll32.exe sysdm.cpl,EditUserProfiles</code>. You can just copy & paste this into cmd window to run.</p> <p><strong>Further reading:</strong> <a href="https://archive.is/EMb0j#selection-1805.20-1805.59" rel="nore... | 64, 2631, 34595 | cmd, windows, windows-7 | <h1>Command to open "Configure advanced user profile properties" (Windows 7)</h1>
<p>I'm trying to figure out how to open the "Configure advanced user profile properties" control panel window by command line, so that I can provide a link to it in my application.</p>
<p>It can be opened without going through the contro... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,098 | cmd | # Command to open "Configure advanced user profile properties" (Windows 7)
I'm trying to figure out how to open the "Configure advanced user profile properties" control panel window by command line, so that I can provide a link to it in my application.
It can be opened without going through the control panel by typin... | The actual command line for `Configure advanced user profile properties` is:
`rundll32.exe sysdm.cpl,EditUserProfiles`. You can just copy & paste this into cmd window to run.
**Further reading:** [Entry for `run` at ss64.com](https://archive.is/EMb0j#selection-1805.20-1805.59) |
11024993 | Run Python in cmd | 10 | 2012-06-13 23:49:41 | <p>I am running python 2.7, I can run a program fine when I open the <code>*.py</code> file.</p>
<p>But when I go to cmd and type "<code>python *.py any other args</code>", it doesn't work, it says that python is not recognised. This is hard because I am trying to do things like <code>sys.argv[]</code>, any help is gr... | 74,163 | 1,365,811 | 2018-12-18 06:12:41 | 11,025,010 | 17 | 2012-06-13 23:51:20 | 1,209,279 | 2012-06-14 01:36:20 | https://stackoverflow.com/q/11024993 | https://stackoverflow.com/a/11025010 | <p>You probably don't have the Python executable on your <code>PATH</code>. The <a href="http://en.wikipedia.org/wiki/PATH_%28variable%29">PATH variable</a> tells the command interpreter where to find the commands you are issuing.</p>
<p>If you are on a <strong>Unix/Linux</strong> system try</p>
<pre><code>/usr/bin/p... | <p>You probably don't have the Python executable on your <code>PATH</code>. The <a href="http://en.wikipedia.org/wiki/PATH_%28variable%29">PATH variable</a> tells the command interpreter where to find the commands you are issuing.</p> <p>If you are on a <strong>Unix/Linux</strong> system try</p> <pre><code>/usr/bin/p... | 16, 2631, 6268, 34595, 59047 | cmd, path, python, python-2.7, windows-7 | <h1>Run Python in cmd</h1>
<p>I am running python 2.7, I can run a program fine when I open the <code>*.py</code> file.</p>
<p>But when I go to cmd and type "<code>python *.py any other args</code>", it doesn't work, it says that python is not recognised. This is hard because I am trying to do things like <code>sys.ar... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,099 | cmd | # Run Python in cmd
I am running python 2.7, I can run a program fine when I open the `*.py` file.
But when I go to cmd and type "`python *.py any other args`", it doesn't work, it says that python is not recognised. This is hard because I am trying to do things like `sys.argv[]`, any help is great.
Thanks | You probably don't have the Python executable on your `PATH`. The [PATH variable](http://en.wikipedia.org/wiki/PATH_%28variable%29) tells the command interpreter where to find the commands you are issuing.
If you are on a **Unix/Linux** system try
```
/usr/bin/python
```
Under **Windows** it may vary, so find where ... |
9143628 | bat function to find a file in folder and subfolders and do something with it. | 10 | 2012-02-04 19:08:06 | <p>I need to find all files with specific filename(for example main.css) in folder and all subfolders and then do something with it(eg. rename, move, delete, add text line, etc) </p>
| 37,894 | 336,441 | 2013-09-12 17:28:19 | 9,144,149 | 17 | 2012-02-04 20:12:51 | 505,088 | 2012-02-04 20:12:51 | https://stackoverflow.com/q/9143628 | https://stackoverflow.com/a/9144149 | <p>This is what you need:</p>
<pre><code>for /R %f in (main.css) do @echo "%f"
</code></pre>
<p>Naturally you would replace <code>echo</code> with whatever it is you wish to do to the file. You can use wildcards if you need to:</p>
<pre><code>for /R %f in (*.css) do @echo "%f"
</code></pre>
| <p>This is what you need:</p> <pre><code>for /R %f in (main.css) do @echo "%f" </code></pre> <p>Naturally you would replace <code>echo</code> with whatever it is you wish to do to the file. You can use wildcards if you need to:</p> <pre><code>for /R %f in (*.css) do @echo "%f" </code></pre> | 64, 7002, 10193, 30645 | batch-file, batch-processing, find, windows | <h1>bat function to find a file in folder and subfolders and do something with it.</h1>
<p>I need to find all files with specific filename(for example main.css) in folder and all subfolders and then do something with it(eg. rename, move, delete, add text line, etc) </p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,100 | cmd | # bat function to find a file in folder and subfolders and do something with it.
I need to find all files with specific filename(for example main.css) in folder and all subfolders and then do something with it(eg. rename, move, delete, add text line, etc) | This is what you need:
```
for /R %f in (main.css) do @echo "%f"
```
Naturally you would replace `echo` with whatever it is you wish to do to the file. You can use wildcards if you need to:
```
for /R %f in (*.css) do @echo "%f"
``` |
4663657 | Using Command Prompt To Call a Batch File in a Sub-Directory | 10 | 2011-01-11 23:00:35 | <p>I'd like to use a batch file to call a different batch file that is in a sub directory. For instance, if my file system look as follows:</p>
<p>MainFolder<br>
main.bat<br>
FirstDirectory<br>
SecondDirectory<br>
&n... | 34,625 | 387,175 | 2016-10-28 02:48:45 | 4,663,703 | 17 | 2011-01-11 23:07:13 | 311,207 | 2011-02-01 21:16:55 | https://stackoverflow.com/q/4663657 | https://stackoverflow.com/a/4663703 | <p>You can indeed call a batch file from another batch file using the <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true" rel="noreferrer"><code>call</code></a> command. As @Blorgbeard states, the issues is the leading backslash <code>\</code>. Removing it indica... | <p>You can indeed call a batch file from another batch file using the <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true" rel="noreferrer"><code>call</code></a> command. As @Blorgbeard states, the issues is the leading backslash <code>\</code>. Removing it indica... | 64, 1231, 7002 | batch-file, command-line, windows | <h1>Using Command Prompt To Call a Batch File in a Sub-Directory</h1>
<p>I'd like to use a batch file to call a different batch file that is in a sub directory. For instance, if my file system look as follows:</p>
<p>MainFolder<br>
main.bat<br>
FirstDirectory<br>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,101 | cmd | # Using Command Prompt To Call a Batch File in a Sub-Directory
I'd like to use a batch file to call a different batch file that is in a sub directory. For instance, if my file system look as follows:
MainFolder
main.bat
FirstDirectory
SecondDirectory
foo.bat
Then main.bat might look somet... | You can indeed call a batch file from another batch file using the [`call`](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true) command. As @Blorgbeard states, the issues is the leading backslash `\`. Removing it indicates `SecondDirectory` is relative to the current work... |
4495576 | echo -e equivalent in Windows? | 10 | 2010-12-21 01:24:43 | <p>Is there any Linux "echo -e" equivalent in windows so I can use "echo -e \xnnn" to print out the character whose ASCII code is the hexadecimal value nnn ?</p>
| 38,833 | 198,497 | 2025-11-24 10:22:28 | 4,497,133 | 17 | 2010-12-21 07:38:23 | 463,115 | 2017-07-04 12:25:32 | https://stackoverflow.com/q/4495576 | https://stackoverflow.com/a/4497133 | <p>There is no equivalent, but you can write your own function.</p>
<p>I would split the problem into two parts. </p>
<ul>
<li>Convert the hex number to decimal. </li>
<li>Convert the decimal number to ASCII.</li>
</ul>
<p>Converting from hex to decimal is simple by</p>
<pre><code>set "myHex=4A"
set /a decimal=0x... | <p>There is no equivalent, but you can write your own function.</p> <p>I would split the problem into two parts. </p> <ul> <li>Convert the hex number to decimal. </li> <li>Convert the decimal number to ASCII.</li> </ul> <p>Converting from hex to decimal is simple by</p> <pre><code>set "myHex=4A" set /a decimal=0x... | 64, 2631, 7002, 13824 | batch-file, cmd, echo, windows | <h1>echo -e equivalent in Windows?</h1>
<p>Is there any Linux "echo -e" equivalent in windows so I can use "echo -e \xnnn" to print out the character whose ASCII code is the hexadecimal value nnn ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,102 | cmd | # echo -e equivalent in Windows?
Is there any Linux "echo -e" equivalent in windows so I can use "echo -e \xnnn" to print out the character whose ASCII code is the hexadecimal value nnn ? | There is no equivalent, but you can write your own function.
I would split the problem into two parts.
- Convert the hex number to decimal.
- Convert the decimal number to ASCII.
Converting from hex to decimal is simple by
```
set "myHex=4A"
set /a decimal=0x%myHex%
```
Converting a number to an ASCII is more tric... |
544417 | Deleting empty (zero-byte) files | 10 | 2009-02-13 01:45:46 | <p>What's the easiest/best way to find and remove empty (zero-byte) files using only tools native to Mac OS X?</p>
| 12,764 | 214,303 | 2024-07-22 14:40:53 | 544,428 | 17 | 2009-02-13 01:50:03 | 14,122 | 2017-01-16 19:03:19 | https://stackoverflow.com/q/544417 | https://stackoverflow.com/a/544428 | <p>Easy enough:</p>
<pre><code>find . -type f -size 0 -exec rm -f '{}' +
</code></pre>
<hr>
<p>To ignore any file having xattr content (assuming the MacOS <code>find</code> implementation):</p>
<pre><code>find . -type f -size 0 '!' -xattr -exec rm -f '{}' +
</code></pre>
<p>That said, note that many xattrs are not... | <p>Easy enough:</p> <pre><code>find . -type f -size 0 -exec rm -f '{}' + </code></pre> <hr> <p>To ignore any file having xattr content (assuming the MacOS <code>find</code> implementation):</p> <pre><code>find . -type f -size 0 '!' -xattr -exec rm -f '{}' + </code></pre> <p>That said, note that many xattrs are not... | 1231, 5310, 7002 | batch-file, command-line, file | <h1>Deleting empty (zero-byte) files</h1>
<p>What's the easiest/best way to find and remove empty (zero-byte) files using only tools native to Mac OS X?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,104 | cmd | # Deleting empty (zero-byte) files
What's the easiest/best way to find and remove empty (zero-byte) files using only tools native to Mac OS X? | Easy enough:
```
find . -type f -size 0 -exec rm -f '{}' +
```
---
To ignore any file having xattr content (assuming the MacOS `find` implementation):
```
find . -type f -size 0 '!' -xattr -exec rm -f '{}' +
```
That said, note that many xattrs are not particularly useful (for example, `com.apple.quarantine` exist... |
298292 | Reading a value from a file in a windows batch script | 10 | 2008-11-18 09:54:13 | <p>I'm trying to read a value from a file and use it in a subsequent command.</p>
<p>I have a file called <code>AppServer.pid</code> which contains the process id of my app server (just the number, it's not a properties file or anything like that).</p>
<p>The app server is hanging, so I want to take this value and pa... | 17,082 | 21,590 | 2016-07-19 00:40:12 | 298,409 | 17 | 2008-11-18 10:45:00 | 25,758 | 2008-11-18 12:30:23 | https://stackoverflow.com/q/298292 | https://stackoverflow.com/a/298409 | <p>This works:</p>
<pre><code>SET /P VALUE_FROM_FILE= < AppServer.pid
taskkill /pid %VALUE_FROM_FILE% /f
</code></pre>
<p>The /P parameter used with SET allows you to set the value of a parameter using input from the user (or in this case, input from a file)</p>
| <p>This works:</p> <pre><code>SET /P VALUE_FROM_FILE= < AppServer.pid taskkill /pid %VALUE_FROM_FILE% /f </code></pre> <p>The /P parameter used with SET allows you to set the value of a parameter using input from the user (or in this case, input from a file)</p> | 64, 531, 5310, 7002 | batch-file, file, scripting, windows | <h1>Reading a value from a file in a windows batch script</h1>
<p>I'm trying to read a value from a file and use it in a subsequent command.</p>
<p>I have a file called <code>AppServer.pid</code> which contains the process id of my app server (just the number, it's not a properties file or anything like that).</p>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,105 | cmd | # Reading a value from a file in a windows batch script
I'm trying to read a value from a file and use it in a subsequent command.
I have a file called `AppServer.pid` which contains the process id of my app server (just the number, it's not a properties file or anything like that).
The app server is hanging, so I w... | This works:
```
SET /P VALUE_FROM_FILE= < AppServer.pid
taskkill /pid %VALUE_FROM_FILE% /f
```
The /P parameter used with SET allows you to set the value of a parameter using input from the user (or in this case, input from a file) |
48764076 | Normalize file path in batch | 9 | 2018-02-13 10:04:32 | <p>Is there a way to resolve the <code>..</code> from an absolute file path in batch? For example, the following batch script should output <code>C:\Users\xyz\other\abc.txt</code>:</p>
<pre><code>REM Project dir is an absolute path, for example, C:\Users\xyz\project\
SET projectDir=%~1
REM Target file is a path relat... | 4,651 | 6,095,394 | 2025-10-03 10:43:51 | 48,764,567 | 17 | 2018-02-13 10:30:01 | 2,152,082 | 2025-10-03 10:43:51 | https://stackoverflow.com/q/48764076 | https://stackoverflow.com/a/48764567 | <p>I wonder, how anyone ever could come up with a path like <code>C:\Users\xyz\project\..\other\abc.txt</code>, but here we go:</p>
<pre><code>SET "absPath=C:\Users\xyz\project\..\other\abc.txt"
for %%i in ("%absPath%") do SET "absPathClean=%%~fi"
echo %absPathClean%
</code></pre>
<p>works... | <p>I wonder, how anyone ever could come up with a path like <code>C:\Users\xyz\project\..\other\abc.txt</code>, but here we go:</p> <pre><code>SET "absPath=C:\Users\xyz\project\..\other\abc.txt" for %%i in ("%absPath%") do SET "absPathClean=%%~fi" echo %absPathClean% </code></pre> <p>works... | 64, 7002 | batch-file, windows | <h1>Normalize file path in batch</h1>
<p>Is there a way to resolve the <code>..</code> from an absolute file path in batch? For example, the following batch script should output <code>C:\Users\xyz\other\abc.txt</code>:</p>
<pre><code>REM Project dir is an absolute path, for example, C:\Users\xyz\project\
SET projectDi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,106 | cmd | # Normalize file path in batch
Is there a way to resolve the `..` from an absolute file path in batch? For example, the following batch script should output `C:\Users\xyz\other\abc.txt`:
```
REM Project dir is an absolute path, for example, C:\Users\xyz\project\
SET projectDir=%~1
REM Target file is a path relative ... | I wonder, how anyone ever could come up with a path like `C:\Users\xyz\project\..\other\abc.txt`, but here we go:
```
SET "absPath=C:\Users\xyz\project\..\other\abc.txt"
for %%i in ("%absPath%") do SET "absPathClean=%%~fi"
echo %absPathClean%
```
works for both files and folders.
For more information, consult `for /... |
29772892 | silent command net stop | 9 | 2015-04-21 12:57:57 | <p>I need to stop a service that has dependencies.</p>
<p>Annoyingly it asks the user to press yes or no. The trouble is that I don't want it to ask. I want it to automatically do it.
for example </p>
<pre><code>net stop msmq
</code></pre>
<p>but i cant see any possibilities.</p>
<pre><code>NET
[ ACCOUNTS | COM... | 11,803 | 3,635,582 | 2015-04-21 12:59:26 | 29,772,932 | 17 | 2015-04-21 12:59:26 | 3,635,582 | 2015-04-21 12:59:26 | https://stackoverflow.com/q/29772892 | https://stackoverflow.com/a/29772932 | <p>I found the answer.
I tried to use this command:</p>
<pre><code>net stop msmq /y
</code></pre>
| <p>I found the answer. I tried to use this command:</p> <pre><code>net stop msmq /y </code></pre> | 1796, 2631 | cmd, command | <h1>silent command net stop</h1>
<p>I need to stop a service that has dependencies.</p>
<p>Annoyingly it asks the user to press yes or no. The trouble is that I don't want it to ask. I want it to automatically do it.
for example </p>
<pre><code>net stop msmq
</code></pre>
<p>but i cant see any possibilities.</p>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,107 | cmd | # silent command net stop
I need to stop a service that has dependencies.
Annoyingly it asks the user to press yes or no. The trouble is that I don't want it to ask. I want it to automatically do it.
for example
```
net stop msmq
```
but i cant see any possibilities.
```
NET
[ ACCOUNTS | COMPUTER | CONFIG | CO... | I found the answer.
I tried to use this command:
```
net stop msmq /y
``` |
19225720 | Verifying success for spring JDBC batch update | 9 | 2013-10-07 13:06:07 | <p>I am using Spring JDBCTemplate batchUpdate to insert data in a batch. I want to verify if the data is successfully inserted. JDBCTemplate batchUpdate returns an int[][], so which is the right way to verify that the data is inserted? </p>
<p>This <a href="http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch1... | 17,179 | 1,386,155 | 2013-10-07 19:41:50 | 19,226,851 | 17 | 2013-10-07 13:59:33 | 579,580 | 2013-10-07 19:41:50 | https://stackoverflow.com/q/19225720 | https://stackoverflow.com/a/19226851 | <p>-2 does not necessarily mean error, it might be as mentioned, the case of count of affected rows is not available.</p>
<p><strong>EDIT</strong></p>
<p>-2 is the value of Statement.SUCCESS_NO_INFO (while EXECUTE_FAILED is -3). So unless the driver does not comply with the JDBC specification, -2 unequivocally means ... | <p>-2 does not necessarily mean error, it might be as mentioned, the case of count of affected rows is not available.</p> <p><strong>EDIT</strong></p> <p>-2 is the value of Statement.SUCCESS_NO_INFO (while EXECUTE_FAILED is -3). So unless the driver does not comply with the JDBC specification, -2 unequivocally means ... | 17, 5617, 16850, 35561 | batch-updates, java, jdbc, spring-jdbc | <h1>Verifying success for spring JDBC batch update</h1>
<p>I am using Spring JDBCTemplate batchUpdate to insert data in a batch. I want to verify if the data is successfully inserted. JDBCTemplate batchUpdate returns an int[][], so which is the right way to verify that the data is inserted? </p>
<p>This <a href="http:... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,108 | cmd | # Verifying success for spring JDBC batch update
I am using Spring JDBCTemplate batchUpdate to insert data in a batch. I want to verify if the data is successfully inserted. JDBCTemplate batchUpdate returns an int[][], so which is the right way to verify that the data is inserted?
This [link](http://docs.spring.io/sp... | -2 does not necessarily mean error, it might be as mentioned, the case of count of affected rows is not available.
**EDIT**
-2 is the value of Statement.SUCCESS_NO_INFO (while EXECUTE_FAILED is -3). So unless the driver does not comply with the JDBC specification, -2 unequivocally means success
**END OF EDIT**
The ... |
17241089 | How do I conditionally turn @ECHO ON/OFF in a Windows batch file? | 9 | 2013-06-21 17:31:36 | <p>I have a batch file that can be run locally or on the build server to do some kind of interesting job. On the local machine, I want <code>@ECHO OFF</code> so that your console isn't full of debug strings. On the build server, I'd rather have <code>@ECHO ON</code> so that failures can be investigated.</p>
<p>The bui... | 46,021 | 3,619 | 2016-08-08 14:44:31 | 17,241,240 | 17 | 2013-06-21 17:40:10 | 68,204 | 2013-06-24 21:34:43 | https://stackoverflow.com/q/17241089 | https://stackoverflow.com/a/17241240 | <p>The command is not actually named <code>@echo</code>. The <code>@</code> is an optional flag valid at the beginning of a statement to indicate that echo is suppressed for that statement. So using the <code>@</code> on each reference to the <code>echo</code> command will hide the <code>echo</code> command itself, but... | <p>The command is not actually named <code>@echo</code>. The <code>@</code> is an optional flag valid at the beginning of a statement to indicate that echo is suppressed for that statement. So using the <code>@</code> on each reference to the <code>echo</code> command will hide the <code>echo</code> command itself, but... | 64, 1357, 2631, 7002, 13824 | batch-file, cmd, echo, parsing, windows | <h1>How do I conditionally turn @ECHO ON/OFF in a Windows batch file?</h1>
<p>I have a batch file that can be run locally or on the build server to do some kind of interesting job. On the local machine, I want <code>@ECHO OFF</code> so that your console isn't full of debug strings. On the build server, I'd rather have ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,109 | cmd | # How do I conditionally turn @ECHO ON/OFF in a Windows batch file?
I have a batch file that can be run locally or on the build server to do some kind of interesting job. On the local machine, I want `@ECHO OFF` so that your console isn't full of debug strings. On the build server, I'd rather have `@ECHO ON` so that f... | The command is not actually named `@echo`. The `@` is an optional flag valid at the beginning of a statement to indicate that echo is suppressed for that statement. So using the `@` on each reference to the `echo` command will hide the `echo` command itself, but not the `if` command that precedes it.
But the issue tha... |
5886334 | Windows Batch: Set Variables from Text File | 9 | 2011-05-04 15:58:54 | <p>Im currently looking for a method to set variables in a windows batch file from linkes in txt document.</p>
<p>So for example, if the text file reads:</p>
<pre><code>http://website1.com
http://website2.com
http://website3.com
</code></pre>
<p>I can hopefully output them to variables in the batch. Example:</p>
<p... | 59,174 | 721,386 | 2021-09-26 19:36:50 | 5,886,731 | 17 | 2011-05-04 16:33:18 | 3,501 | 2011-05-04 16:33:18 | https://stackoverflow.com/q/5886334 | https://stackoverflow.com/a/5886731 | <p>The FOR /F loop command can be used to read lines from a text file:</p>
<pre><code>@echo off
setlocal ENABLEDELAYEDEXPANSION
set vidx=0
for /F "tokens=*" %%A in (sites.txt) do (
SET /A vidx=!vidx! + 1
set var!vidx!=%%A
)
set var
</code></pre>
<p>You end up with:</p>
<pre><code>var1=http://website1.com
var... | <p>The FOR /F loop command can be used to read lines from a text file:</p> <pre><code>@echo off setlocal ENABLEDELAYEDEXPANSION set vidx=0 for /F "tokens=*" %%A in (sites.txt) do ( SET /A vidx=!vidx! + 1 set var!vidx!=%%A ) set var </code></pre> <p>You end up with:</p> <pre><code>var1=http://website1.com var... | 64, 1469, 7002, 17938 | batch-file, text, text-files, windows | <h1>Windows Batch: Set Variables from Text File</h1>
<p>Im currently looking for a method to set variables in a windows batch file from linkes in txt document.</p>
<p>So for example, if the text file reads:</p>
<pre><code>http://website1.com
http://website2.com
http://website3.com
</code></pre>
<p>I can hopefully ou... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,110 | cmd | # Windows Batch: Set Variables from Text File
Im currently looking for a method to set variables in a windows batch file from linkes in txt document.
So for example, if the text file reads:
```
http://website1.com
http://website2.com
http://website3.com
```
I can hopefully output them to variables in the batch. Exa... | The FOR /F loop command can be used to read lines from a text file:
```
@echo off
setlocal ENABLEDELAYEDEXPANSION
set vidx=0
for /F "tokens=*" %%A in (sites.txt) do (
SET /A vidx=!vidx! + 1
set var!vidx!=%%A
)
set var
```
You end up with:
```
var1=http://website1.com
var2=http://website2.com
var3=http://webs... |
3961790 | Trying to edit the registry in Windows with a batch file | 9 | 2010-10-18 17:41:52 | <p>I am supporting a few offices across the country running Windows XP. They are stand alone, no Windows Server or Active Directory, anything like that. I just switched them over to Google Apps, and in the process replaced Windows Live Messenger with Google Talk. I really want to stop Windows Live from being used, the ... | 41,452 | 110,098 | 2015-07-15 14:19:21 | 3,961,967 | 17 | 2010-10-18 18:01:02 | 147,320 | 2010-10-18 18:01:02 | https://stackoverflow.com/q/3961790 | https://stackoverflow.com/a/3961967 | <p>Looks to me like you have the Registry value name and data swapped. According to the <a href="http://support.microsoft.com/kb/323525" rel="noreferrer">kb article</a>, the REG_SZ value(s) should be named numerically starting with "1", and the included data would be the executable name ("msnmsgr.exe"). Thus, your .REG... | <p>Looks to me like you have the Registry value name and data swapped. According to the <a href="http://support.microsoft.com/kb/323525" rel="noreferrer">kb article</a>, the REG_SZ value(s) should be named numerically starting with "1", and the included data would be the executable name ("msnmsgr.exe"). Thus, your .REG... | 64, 263, 7002 | batch-file, registry, windows | <h1>Trying to edit the registry in Windows with a batch file</h1>
<p>I am supporting a few offices across the country running Windows XP. They are stand alone, no Windows Server or Active Directory, anything like that. I just switched them over to Google Apps, and in the process replaced Windows Live Messenger with Goo... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,111 | cmd | # Trying to edit the registry in Windows with a batch file
I am supporting a few offices across the country running Windows XP. They are stand alone, no Windows Server or Active Directory, anything like that. I just switched them over to Google Apps, and in the process replaced Windows Live Messenger with Google Talk.... | Looks to me like you have the Registry value name and data swapped. According to the [kb article](http://support.microsoft.com/kb/323525), the REG_SZ value(s) should be named numerically starting with "1", and the included data would be the executable name ("msnmsgr.exe"). Thus, your .REG file should look like this:
`... |
2405666 | starting a windows executable via batch script, exe not in Program Files | 9 | 2010-03-08 23:50:43 | <p>This is probably batch scripting 101, but I can't find any clear explanation/documentation on why this is happening or if my workaround is actually the solution. So basically any terminology or links to good sources is really appreciated.</p>
<p>So I have a program I want to execute via batch script (along with sev... | 48,822 | 49,478 | 2016-02-04 06:26:53 | 2,405,679 | 17 | 2010-03-08 23:55:01 | 284,364 | 2013-04-25 18:32:43 | https://stackoverflow.com/q/2405666 | https://stackoverflow.com/a/2405679 | <p>you are doing it perfectly :-)</p>
<p>the executable is probably looking for this file in the "current working directory", which is being set, when you "cd" to it before.</p>
<p>you can set your working directory manually by creating a shortcut to your batch file; right click; properties.</p>
<p>edit:</p>
<p>you... | <p>you are doing it perfectly :-)</p> <p>the executable is probably looking for this file in the "current working directory", which is being set, when you "cd" to it before.</p> <p>you can set your working directory manually by creating a shortcut to your batch file; right click; properties.</p> <p>edit:</p> <p>you... | 64, 1231, 7002 | batch-file, command-line, windows | <h1>starting a windows executable via batch script, exe not in Program Files</h1>
<p>This is probably batch scripting 101, but I can't find any clear explanation/documentation on why this is happening or if my workaround is actually the solution. So basically any terminology or links to good sources is really appreciat... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,112 | cmd | # starting a windows executable via batch script, exe not in Program Files
This is probably batch scripting 101, but I can't find any clear explanation/documentation on why this is happening or if my workaround is actually the solution. So basically any terminology or links to good sources is really appreciated.
So I... | you are doing it perfectly :-)
the executable is probably looking for this file in the "current working directory", which is being set, when you "cd" to it before.
you can set your working directory manually by creating a shortcut to your batch file; right click; properties.
edit:
you can also set your current work... |
47331056 | aws batch: submit job using lambda | 8 | 2017-11-16 13:34:10 | <p>Context: AWS, S3, <strong>Lambda</strong>, <strong>Batch</strong>.</p>
<p>I have a lambda that is triggered when a file is uploaded in a S3 Bucket. I want that the lambda submit a Batch job.</p>
<p>(edit: Between S3 and Lambda everything works fine. The problem is between Lambda and Batch.)</p>
<p><strong>Q</stro... | 10,450 | 2,107,667 | 2020-12-15 04:42:13 | 47,331,667 | 17 | 2017-11-16 14:02:33 | 2,107,667 | 2017-11-16 14:02:33 | https://stackoverflow.com/q/47331056 | https://stackoverflow.com/a/47331667 | <p>It seems that this was the role I was looking for: <code>batch:SubmitJob</code>. Using this role, the lambda was able to submit the job.</p>
<pre><code>iamRoleStatements:
- Effect: Allow
Action:
- batch:SubmitJob
Resource: "arn:aws:batch:*:*:*"
</code></pre>
| <p>It seems that this was the role I was looking for: <code>batch:SubmitJob</code>. Using this role, the lambda was able to submit the job.</p> <pre><code>iamRoleStatements: - Effect: Allow Action: - batch:SubmitJob Resource: "arn:aws:batch:*:*:*" </code></pre> | 4538, 33388, 108737, 124227 | amazon-web-services, aws-batch, aws-lambda, roles | <h1>aws batch: submit job using lambda</h1>
<p>Context: AWS, S3, <strong>Lambda</strong>, <strong>Batch</strong>.</p>
<p>I have a lambda that is triggered when a file is uploaded in a S3 Bucket. I want that the lambda submit a Batch job.</p>
<p>(edit: Between S3 and Lambda everything works fine. The problem is betwee... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,113 | cmd | # aws batch: submit job using lambda
Context: AWS, S3, **Lambda**, **Batch**.
I have a lambda that is triggered when a file is uploaded in a S3 Bucket. I want that the lambda submit a Batch job.
(edit: Between S3 and Lambda everything works fine. The problem is between Lambda and Batch.)
**Q**: What is the **role**... | It seems that this was the role I was looking for: `batch:SubmitJob`. Using this role, the lambda was able to submit the job.
```
iamRoleStatements:
- Effect: Allow
Action:
- batch:SubmitJob
Resource: "arn:aws:batch:*:*:*"
``` |
28810194 | How to pass a list of strings to a batch-script as a parameter? | 8 | 2015-03-02 12:46:59 | <p>My batch script is used to process a list of strings and I would like to parameterize it so it will accept this list as a parameter from the user.</p>
<p>This is how my code is processing this list currently:</p>
<pre><code>set QUEUES=cars plans others
FOR %%q IN (%QUEUES%) DO Call :defineQueues %%q
</code></pre>
... | 22,663 | 952,310 | 2022-08-23 15:20:12 | 28,810,289 | 17 | 2015-03-02 12:52:51 | 4,584,335 | 2015-03-02 20:23:28 | https://stackoverflow.com/q/28810194 | https://stackoverflow.com/a/28810289 | <p>You have to enclose your string with quotes:</p>
<pre><code>myScript.bat "cars plans others"
</code></pre>
<p>Then <code>%1</code> will be equals to <code>"cars plans others"</code></p>
<p>Or <code>%~1%</code> to remove the quotes and only get <code>cars plans others</code></p>
<p>Otherwise, you will get 3 diffe... | <p>You have to enclose your string with quotes:</p> <pre><code>myScript.bat "cars plans others" </code></pre> <p>Then <code>%1</code> will be equals to <code>"cars plans others"</code></p> <p>Or <code>%~1%</code> to remove the quotes and only get <code>cars plans others</code></p> <p>Otherwise, you will get 3 diffe... | 7002 | batch-file | <h1>How to pass a list of strings to a batch-script as a parameter?</h1>
<p>My batch script is used to process a list of strings and I would like to parameterize it so it will accept this list as a parameter from the user.</p>
<p>This is how my code is processing this list currently:</p>
<pre><code>set QUEUES=cars pl... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,114 | cmd | # How to pass a list of strings to a batch-script as a parameter?
My batch script is used to process a list of strings and I would like to parameterize it so it will accept this list as a parameter from the user.
This is how my code is processing this list currently:
```
set QUEUES=cars plans others
FOR %%q IN (%QUE... | You have to enclose your string with quotes:
```
myScript.bat "cars plans others"
```
Then `%1` will be equals to `"cars plans others"`
Or `%~1%` to remove the quotes and only get `cars plans others`
Otherwise, you will get 3 different parameter values:
```
myScript.bat cars plans others
%1 => cars
%2 => plans
%3... |
28028414 | How can I make a Variable True and check if the variable is true? | 8 | 2015-01-19 15:47:16 | <p>EDIT</p>
<p>I think i formulated myself wrong,
the sword is an item you can obtain ingame, so the value starts at 0 (FALSE).
When the player obtains the sword, the variable goes to 1 (TRUE).
Now, after the variable is true, I want to be able to use</p>
<pre><code> choice /c 12 /n /m "What do you want to do?"
... | 16,439 | 4,470,626 | 2015-01-19 17:21:45 | 28,030,233 | 17 | 2015-01-19 17:21:45 | 4,470,674 | 2015-01-19 17:21:45 | https://stackoverflow.com/q/28028414 | https://stackoverflow.com/a/28030233 | <p>Try this: </p>
<pre><code>@echo off
set sword=true
:start
if %sword% equ true echo You have a sword.
if %sword% neq true echo You do not have a sword.
pause
</code></pre>
| <p>Try this: </p> <pre><code>@echo off set sword=true :start if %sword% equ true echo You have a sword. if %sword% neq true echo You do not have a sword. pause </code></pre> | 2773, 2848, 7002 | batch-file, boolean, if-statement | <h1>How can I make a Variable True and check if the variable is true?</h1>
<p>EDIT</p>
<p>I think i formulated myself wrong,
the sword is an item you can obtain ingame, so the value starts at 0 (FALSE).
When the player obtains the sword, the variable goes to 1 (TRUE).
Now, after the variable is true, I want to be able... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,115 | cmd | # How can I make a Variable True and check if the variable is true?
EDIT
I think i formulated myself wrong,
the sword is an item you can obtain ingame, so the value starts at 0 (FALSE).
When the player obtains the sword, the variable goes to 1 (TRUE).
Now, after the variable is true, I want to be able to use
```
c... | Try this:
```
@echo off
set sword=true
:start
if %sword% equ true echo You have a sword.
if %sword% neq true echo You do not have a sword.
pause
``` |
18866089 | Reading a text file line by line and storing it in an array using batch script | 8 | 2013-09-18 07:19:39 | <p>I want to read a text file and store each line in an array. When I used the code below, <code>"echo %i%"</code> is printing <code>0</code> every time and only <code>array[0]</code> value is getting assigned. But in <code>"set n=%i%"</code>,<code>n</code> value is assigned as the last incremented I value.Also <code>"... | 48,554 | 2,239,262 | 2018-08-15 20:10:28 | 18,869,970 | 17 | 2013-09-18 10:37:38 | 2,299,431 | 2013-09-18 10:37:38 | https://stackoverflow.com/q/18866089 | https://stackoverflow.com/a/18869970 | <p>Here's a method that is useful at times and very similar to your code:</p>
<pre><code>@echo off
set "file=C:\Users\Admin\Documents\url.txt"
set /A i=0
for /F "usebackq delims=" %%a in ("%file%") do (
set /A i+=1
call echo %%i%%
call set array[%%i%%]=%%a
call set n=%%i%%
)
for /L %%i in (1,1,%n%) do call echo %%ar... | <p>Here's a method that is useful at times and very similar to your code:</p> <pre><code>@echo off set "file=C:\Users\Admin\Documents\url.txt" set /A i=0 for /F "usebackq delims=" %%a in ("%file%") do ( set /A i+=1 call echo %%i%% call set array[%%i%%]=%%a call set n=%%i%% ) for /L %%i in (1,1,%n%) do call echo %%ar... | 64, 7002 | batch-file, windows | <h1>Reading a text file line by line and storing it in an array using batch script</h1>
<p>I want to read a text file and store each line in an array. When I used the code below, <code>"echo %i%"</code> is printing <code>0</code> every time and only <code>array[0]</code> value is getting assigned. But in <code>"set n=%... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,116 | cmd | # Reading a text file line by line and storing it in an array using batch script
I want to read a text file and store each line in an array. When I used the code below, `"echo %i%"` is printing `0` every time and only `array[0]` value is getting assigned. But in `"set n=%i%"`,`n` value is assigned as the last incremen... | Here's a method that is useful at times and very similar to your code:
```
@echo off
set "file=C:\Users\Admin\Documents\url.txt"
set /A i=0
for /F "usebackq delims=" %%a in ("%file%") do (
set /A i+=1
call echo %%i%%
call set array[%%i%%]=%%a
call set n=%%i%%
)
for /L %%i in (1,1,%n%) do call echo %%array[%%i]%%
``` |
18727231 | How to extract a substring on batch file | 8 | 2013-09-10 19:24:02 | <p>Now I need get the substring form a string on batch File</p>
<p>I have this</p>
<pre><code>set path="c:\test\branches\9.1\_build"
</code></pre>
<p>I need get the first value after the branches value : <code>9.1</code></p>
<p>But this value can be in other position like</p>
<pre><code>c:\xxx\yyyy\zzzz\branches\o... | 29,386 | 2,708,534 | 2013-09-10 20:33:03 | 18,727,739 | 17 | 2013-09-10 19:57:34 | 2,098,699 | 2013-09-10 20:08:11 | https://stackoverflow.com/q/18727231 | https://stackoverflow.com/a/18727739 | <pre><code>set "mypath=c:\test\branches\9.1\_build"
set "value=%mypath:*\branches\=%"
if "%value%"=="%mypath%" echo "\branches\" not found &goto :eof
for /f "delims=\" %%a in ("%value%") do set "value=%%~a"
echo %value%
</code></pre>
| <pre><code>set "mypath=c:\test\branches\9.1\_build" set "value=%mypath:*\branches\=%" if "%value%"=="%mypath%" echo "\branches\" not found &goto :eof for /f "delims=\" %%a in ("%value%") do set "value=%%~a" echo %value% </code></pre> | 4371, 7002 | batch-file, substring | <h1>How to extract a substring on batch file</h1>
<p>Now I need get the substring form a string on batch File</p>
<p>I have this</p>
<pre><code>set path="c:\test\branches\9.1\_build"
</code></pre>
<p>I need get the first value after the branches value : <code>9.1</code></p>
<p>But this value can be in other positio... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,117 | cmd | # How to extract a substring on batch file
Now I need get the substring form a string on batch File
I have this
```
set path="c:\test\branches\9.1\_build"
```
I need get the first value after the branches value : `9.1`
But this value can be in other position like
```
c:\xxx\yyyy\zzzz\branches\otherbranch\zzz\uuuu... | ```
set "mypath=c:\test\branches\9.1\_build"
set "value=%mypath:*\branches\=%"
if "%value%"=="%mypath%" echo "\branches\" not found &goto :eof
for /f "delims=\" %%a in ("%value%") do set "value=%%~a"
echo %value%
``` |
9757480 | Echo exact string in windows batch file? | 8 | 2012-03-18 10:10:08 | <p>I'm trying to echo a string stored in a variable but it seems to require a lot of escaping. I'm trying with the following code:</p>
<pre><code>setlocal EnableDelayedExpansion
@echo off
set "grass=@##&!$^&%**(&)"
echo !grass!
</code></pre>
<p>I want to echo the variable <code>grass</code> verbatim so I ... | 19,580 | 1,077,213 | 2012-03-18 14:56:44 | 9,758,803 | 17 | 2012-03-18 13:44:47 | 1,012,053 | 2012-03-18 14:56:44 | https://stackoverflow.com/q/9757480 | https://stackoverflow.com/a/9758803 | <p><code>echo !grass!</code> will always echo the current value verbatim, without the need of any escaping. Your problem is, the value is not what you think it is! The problem is occurring when you are trying to SET the value.</p>
<p>The correct escape sequence to set your value is</p>
<pre><code>set "grass=@##&^... | <p><code>echo !grass!</code> will always echo the current value verbatim, without the need of any escaping. Your problem is, the value is not what you think it is! The problem is occurring when you are trying to SET the value.</p> <p>The correct escape sequence to set your value is</p> <pre><code>set "grass=@##&^... | 4804, 7002 | batch-file, escaping | <h1>Echo exact string in windows batch file?</h1>
<p>I'm trying to echo a string stored in a variable but it seems to require a lot of escaping. I'm trying with the following code:</p>
<pre><code>setlocal EnableDelayedExpansion
@echo off
set "grass=@##&!$^&%**(&)"
echo !grass!
</code></pre>
<p>I want to e... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,118 | cmd | # Echo exact string in windows batch file?
I'm trying to echo a string stored in a variable but it seems to require a lot of escaping. I'm trying with the following code:
```
setlocal EnableDelayedExpansion
@echo off
set "grass=@##&!$^&%**(&)"
echo !grass!
```
I want to echo the variable `grass` verbatim so I see a ... | `echo !grass!` will always echo the current value verbatim, without the need of any escaping. Your problem is, the value is not what you think it is! The problem is occurring when you are trying to SET the value.
The correct escape sequence to set your value is
```
set "grass=@##&^!$^^&%%**(&)"
```
And now for the e... |
4779303 | How to copy all files created between two dates using Command prompt? | 8 | 2011-01-24 06:35:46 | <p>I have written code in window batch file (eq. getFiles.bat ) that get all files within select date range.
eq. </p>
<pre><code>xcopy /S /D:01-10-2011 *.* C:\todaysFiles
</code></pre>
<p>But I want get all files in between two dates including <strong>From date</strong> and <strong>To date</strong>.
<br> file extens... | 44,375 | 568,085 | 2018-11-04 04:32:52 | 4,780,219 | 17 | 2011-01-24 09:06:16 | 71,791 | 2011-01-24 09:06:16 | https://stackoverflow.com/q/4779303 | https://stackoverflow.com/a/4780219 | <p>If you're on Vista/Win7/WinServer2008 you can use <code>robocopy</code> like so:</p>
<pre><code>robocopy c:\source c:\destination *.* /MAXAGE:20101231 /MINAGE:20111001
</code></pre>
<p>On XP, I'm not sure if there are built-in solutions short of using Powershell and the like.</p>
| <p>If you're on Vista/Win7/WinServer2008 you can use <code>robocopy</code> like so:</p> <pre><code>robocopy c:\source c:\destination *.* /MAXAGE:20101231 /MINAGE:20111001 </code></pre> <p>On XP, I'm not sure if there are built-in solutions short of using Powershell and the like.</p> | 1796, 7002, 9938 | batch-file, command, command-prompt | <h1>How to copy all files created between two dates using Command prompt?</h1>
<p>I have written code in window batch file (eq. getFiles.bat ) that get all files within select date range.
eq. </p>
<pre><code>xcopy /S /D:01-10-2011 *.* C:\todaysFiles
</code></pre>
<p>But I want get all files in between two dates incl... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,119 | cmd | # How to copy all files created between two dates using Command prompt?
I have written code in window batch file (eq. getFiles.bat ) that get all files within select date range.
eq.
```
xcopy /S /D:01-10-2011 *.* C:\todaysFiles
```
But I want get all files in between two dates including **From date** and **To date*... | If you're on Vista/Win7/WinServer2008 you can use `robocopy` like so:
```
robocopy c:\source c:\destination *.* /MAXAGE:20101231 /MINAGE:20111001
```
On XP, I'm not sure if there are built-in solutions short of using Powershell and the like. |
2113495 | CMD Command to Copy files with certain extension | 8 | 2010-01-21 22:36:57 | <p>So I'm using this command to copy only txt files from a certain directory to another directory</p>
<pre><code>for /R c:\source %%f in (*.xml) do copy %%f x:\destination\
</code></pre>
<p>But it only copies over the text files without a space in the name, so it copies test.txt but not test 2.txt. How do I make it s... | 27,261 | 222,676 | 2015-04-29 19:06:51 | 2,113,519 | 17 | 2010-01-21 22:40:48 | 182,289 | 2013-04-09 12:46:00 | https://stackoverflow.com/q/2113495 | https://stackoverflow.com/a/2113519 | <p>Add quotes just around the variable after the copy command:</p>
<pre><code>for /R c:\source %%f in (*.xml) do copy "%%f" x:\destination\
</code></pre>
| <p>Add quotes just around the variable after the copy command:</p> <pre><code>for /R c:\source %%f in (*.xml) do copy "%%f" x:\destination\ </code></pre> | 2631 | cmd | <h1>CMD Command to Copy files with certain extension</h1>
<p>So I'm using this command to copy only txt files from a certain directory to another directory</p>
<pre><code>for /R c:\source %%f in (*.xml) do copy %%f x:\destination\
</code></pre>
<p>But it only copies over the text files without a space in the name, so... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,120 | cmd | # CMD Command to Copy files with certain extension
So I'm using this command to copy only txt files from a certain directory to another directory
```
for /R c:\source %%f in (*.xml) do copy %%f x:\destination\
```
But it only copies over the text files without a space in the name, so it copies test.txt but not test ... | Add quotes just around the variable after the copy command:
```
for /R c:\source %%f in (*.xml) do copy "%%f" x:\destination\
``` |
58827480 | Can you initialize Spring Batch metadata tables with Liquibase? | 7 | 2019-11-12 22:13:43 | <p>Currently I have a setup like below. On running the batch job locally the job will create the necessary metadata tables automatically using the <code>data-source</code> property values since <code>initialize-schema</code> is set to always. Liquibase will also run and create any tables listed in its changelog.</p>
<... | 6,380 | 5,416,477 | 2023-05-18 06:10:26 | 58,854,924 | 17 | 2019-11-14 10:45:42 | 3,535,298 | 2019-11-14 10:45:42 | https://stackoverflow.com/q/58827480 | https://stackoverflow.com/a/58854924 | <p>Yes, you can reference the schema files that already exist in Spring Batch project. In <code>org.springframework.batch.core</code> package you can find schema-*.sql files where * is the name of the targeted db. Since you are running on mysql, your change set would look something like this:</p>
<pre><code>- changeSe... | <p>Yes, you can reference the schema files that already exist in Spring Batch project. In <code>org.springframework.batch.core</code> package you can find schema-*.sql files where * is the name of the targeted db. Since you are running on mysql, your change set would look something like this:</p> <pre><code>- changeSe... | 17, 1211, 28783, 41895, 95875 | java, liquibase, spring, spring-batch, spring-boot | <h1>Can you initialize Spring Batch metadata tables with Liquibase?</h1>
<p>Currently I have a setup like below. On running the batch job locally the job will create the necessary metadata tables automatically using the <code>data-source</code> property values since <code>initialize-schema</code> is set to always. Liqu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,121 | cmd | # Can you initialize Spring Batch metadata tables with Liquibase?
Currently I have a setup like below. On running the batch job locally the job will create the necessary metadata tables automatically using the `data-source` property values since `initialize-schema` is set to always. Liquibase will also run and create ... | Yes, you can reference the schema files that already exist in Spring Batch project. In `org.springframework.batch.core` package you can find schema-*.sql files where * is the name of the targeted db. Since you are running on mysql, your change set would look something like this:
```
- changeSet:
id: 1234
author: a... |
8453277 | How can a 32-bit cmd.exe launch a 64-bit cmd.exe on Windows Server 2003 x64? | 7 | 2011-12-10 00:11:44 | <p>This is a follow up to <em><a href="https://stackoverflow.com/questions/8419023">7-Zip execution permissions on Windows Server 2008 64-bit</a></em>.</p>
<p>I'm trying to avoid having an overly complicated build process to make multiple 7-Zip EXE files. I just need a .cmd to kick off my Java process after reading so... | 18,121 | 203,463 | 2017-01-10 20:21:41 | 8,800,065 | 17 | 2012-01-10 07:50:01 | 785,536 | 2012-03-22 06:23:01 | https://stackoverflow.com/q/8453277 | https://stackoverflow.com/a/8800065 | <p>To launch 64-bit cmd.exe from 32-bit cmd.exe you must be able to access <code>c:\Windows\System32</code> folder without being redirected to <code>c:\Windows\SysWow64</code> folder. In Win2008 you can achieve this by accessing <code>c:\Windows\Sysnative</code> path. Unfortunately on Win2003 a hotfix is required (see ... | <p>To launch 64-bit cmd.exe from 32-bit cmd.exe you must be able to access <code>c:\Windows\System32</code> folder without being redirected to <code>c:\Windows\SysWow64</code> folder. In Win2008 you can achieve this by accessing <code>c:\Windows\Sysnative</code> path. Unfortunately on Win2003 a hotfix is required (see ... | 64, 2631, 32643 | 32bit-64bit, cmd, windows | <h1>How can a 32-bit cmd.exe launch a 64-bit cmd.exe on Windows Server 2003 x64?</h1>
<p>This is a follow up to <em><a href="https://stackoverflow.com/questions/8419023">7-Zip execution permissions on Windows Server 2008 64-bit</a></em>.</p>
<p>I'm trying to avoid having an overly complicated build process to make mul... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,123 | cmd | # How can a 32-bit cmd.exe launch a 64-bit cmd.exe on Windows Server 2003 x64?
This is a follow up to *[7-Zip execution permissions on Windows Server 2008 64-bit](https://stackoverflow.com/questions/8419023)*.
I'm trying to avoid having an overly complicated build process to make multiple 7-Zip EXE files. I just need... | To launch 64-bit cmd.exe from 32-bit cmd.exe you must be able to access `c:\Windows\System32` folder without being redirected to `c:\Windows\SysWow64` folder. In Win2008 you can achieve this by accessing `c:\Windows\Sysnative` path. Unfortunately on Win2003 a hotfix is required (see <http://support.microsoft.com/kb/942... |
27882070 | Why does pg_restore return "options -d/--dbname and -f/--file cannot be used together"? | 6 | 2015-01-10 23:00:33 | <p>The following Windows batch script fails on the line with database restore:</p>
<pre><code>@Echo off
set Path=C:\Program Files (x86)
set Backup_Path=C:\Program Files (x86)
c:
cd \
cd C:\Program Files (x86)\PostgreSQL\9.1\bin
@echo "Wait ..."
setlocal
set PGPASSWORD=1234
psql.exe -U postgres -c "create d... | 7,005 | 4,095,234 | 2015-01-10 23:18:07 | 27,882,184 | 17 | 2015-01-10 23:14:39 | null | 2015-01-10 23:14:39 | https://stackoverflow.com/q/27882070 | https://stackoverflow.com/a/27882184 | <p><code>-f</code> is the <strong>output</strong> filename, not the input file. </p>
<p>The input file does not have any parameter switch.</p>
<pre><code>c:\>pg_restore --help
pg_restore restores a PostgreSQL database from an archive created by pg_dump.
Usage:
pg_restore [OPTION]... [FILE]
General options:
-... | <p><code>-f</code> is the <strong>output</strong> filename, not the input file. </p> <p>The input file does not have any parameter switch.</p> <pre><code>c:\>pg_restore --help pg_restore restores a PostgreSQL database from an archive created by pg_dump. Usage: pg_restore [OPTION]... [FILE] General options: -... | 256, 7002, 74517, 93819 | batch-file, postgresql, postgresql-9.1, postgresql-9.3 | <h1>Why does pg_restore return "options -d/--dbname and -f/--file cannot be used together"?</h1>
<p>The following Windows batch script fails on the line with database restore:</p>
<pre><code>@Echo off
set Path=C:\Program Files (x86)
set Backup_Path=C:\Program Files (x86)
c:
cd \
cd C:\Program Files (x86)\Postgr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,124 | cmd | # Why does pg_restore return "options -d/--dbname and -f/--file cannot be used together"?
The following Windows batch script fails on the line with database restore:
```
@Echo off
set Path=C:\Program Files (x86)
set Backup_Path=C:\Program Files (x86)
c:
cd \
cd C:\Program Files (x86)\PostgreSQL\9.1\bin
@ech... | `-f` is the **output** filename, not the input file.
The input file does not have any parameter switch.
```
c:\>pg_restore --help
pg_restore restores a PostgreSQL database from an archive created by pg_dump.
Usage:
pg_restore [OPTION]... [FILE]
General options:
-d, --dbname=NAME connect to database name
... |
11525056 | How to create a batch file to run cmd as administrator | 59 | 2012-07-17 14:44:14 | <p>I need to run a batch file which needs to register a DLL. The DLL registration is failing because the Batch file is not starting the command prompt as "administrator".</p>
<p>Is there any way to start the "<strong>Command Prompt</strong>" as <strong>administrator</strong> through the batch file.</p>
<p>Environme... | 441,994 | 1,394,034 | 2023-11-06 03:34:24 | 11,525,110 | 16 | 2012-07-17 14:47:03 | 799,586 | 2012-07-17 16:23:00 | https://stackoverflow.com/q/11525056 | https://stackoverflow.com/a/11525110 | <p>You might have to use another batch file first to launch the second with admin rights.</p>
<p>In the first use</p>
<pre><code>runas /noprofile /user:mymachine\administrator yourbatchfile.bat
</code></pre>
<p>Upon further reading, you must be able to type in the password at the prompt. You cannot pipe the password... | <p>You might have to use another batch file first to launch the second with admin rights.</p> <p>In the first use</p> <pre><code>runas /noprofile /user:mymachine\administrator yourbatchfile.bat </code></pre> <p>Upon further reading, you must be able to type in the password at the prompt. You cannot pipe the password... | 7002 | batch-file | <h1>How to create a batch file to run cmd as administrator</h1>
<p>I need to run a batch file which needs to register a DLL. The DLL registration is failing because the Batch file is not starting the command prompt as "administrator".</p>
<p>Is there any way to start the "<strong>Command Prompt</strong>" as <strong>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,125 | cmd | # How to create a batch file to run cmd as administrator
I need to run a batch file which needs to register a DLL. The DLL registration is failing because the Batch file is not starting the command prompt as "administrator".
Is there any way to start the "**Command Prompt**" as **administrator** through the batch fil... | You might have to use another batch file first to launch the second with admin rights.
In the first use
```
runas /noprofile /user:mymachine\administrator yourbatchfile.bat
```
Upon further reading, you must be able to type in the password at the prompt. You cannot pipe the password as this feature was locked down f... |
37213316 | Execute batch of promises in series. Once Promise.all is done go to the next batch | 37 | 2016-05-13 14:57:51 | <p>I have an array that contains an array of promises, and each inner array could have either 4k, 2k or 500 promises. In total there are around 60k promises and I may test it with other values as well.</p>
<p>I need to execute the first batch <code>Promise.all(BigArray[0])</code> of calls/promises in parallel.</p>
<p>O... | 38,273 | 1,554,966 | 2025-04-10 11:08:32 | 37,214,567 | 16 | 2016-05-13 16:03:10 | 816,620 | 2016-05-13 16:21:07 | https://stackoverflow.com/q/37213316 | https://stackoverflow.com/a/37214567 | <p>Your question is a bit misnamed which may have confused some folks in this question and in the previous version of this question. You are trying to execute a batch of async operations in series, one batch of operations, then when that is done execute another batch of operations. The results of those async operatio... | <p>Your question is a bit misnamed which may have confused some folks in this question and in the previous version of this question. You are trying to execute a batch of async operations in series, one batch of operations, then when that is done execute another batch of operations. The results of those async operatio... | 3, 2314, 21023, 46426, 48682 | batching, javascript, loops, node.js, promise | <h1>Execute batch of promises in series. Once Promise.all is done go to the next batch</h1>
<p>I have an array that contains an array of promises, and each inner array could have either 4k, 2k or 500 promises. In total there are around 60k promises and I may test it with other values as well.</p>
<p>I need to execute t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,126 | cmd | # Execute batch of promises in series. Once Promise.all is done go to the next batch
I have an array that contains an array of promises, and each inner array could have either 4k, 2k or 500 promises. In total there are around 60k promises and I may test it with other values as well.
I need to execute the first batch ... | Your question is a bit misnamed which may have confused some folks in this question and in the previous version of this question. You are trying to execute a batch of async operations in series, one batch of operations, then when that is done execute another batch of operations. The results of those async operations ar... |
8530976 | How to conditionally take action if FINDSTR fails to find a string | 35 | 2011-12-16 07:14:50 | <p>I have a batch file as follows;</p>
<pre><code>CD C:\MyFolder
findstr /c:"stringToCheck" fileToCheck.bat
IF NOT XCOPY "C:\OtherFolder\fileToCheck.bat" "C:\MyFolder" /s /y
</code></pre>
<p>I am getting an error ("C:\OtherFolder\fileToCheck.bat" was unexpected at this time.) when trying to execute this.</p>
<p>Plea... | 152,446 | 485,743 | 2019-02-17 02:10:32 | 8,531,199 | 16 | 2011-12-16 07:41:03 | 391,174 | 2015-11-23 17:12:03 | https://stackoverflow.com/q/8530976 | https://stackoverflow.com/a/8531199 | <p>You are not evaluating a condition for the IF. I am guessing you want to not copy if you find stringToCheck in fileToCheck. You need to do something like (code untested but you get the idea):</p>
<pre><code>CD C:\MyFolder
findstr /c:"stringToCheck" fileToCheck.bat
IF NOT ERRORLEVEL 0 XCOPY "C:\OtherFolder\fileToChe... | <p>You are not evaluating a condition for the IF. I am guessing you want to not copy if you find stringToCheck in fileToCheck. You need to do something like (code untested but you get the idea):</p> <pre><code>CD C:\MyFolder findstr /c:"stringToCheck" fileToCheck.bat IF NOT ERRORLEVEL 0 XCOPY "C:\OtherFolder\fileToChe... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>How to conditionally take action if FINDSTR fails to find a string</h1>
<p>I have a batch file as follows;</p>
<pre><code>CD C:\MyFolder
findstr /c:"stringToCheck" fileToCheck.bat
IF NOT XCOPY "C:\OtherFolder\fileToCheck.bat" "C:\MyFolder" /s /y
</code></pre>
<p>I am getting an error ("C:\OtherFolder\fileToCheck.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,127 | cmd | # How to conditionally take action if FINDSTR fails to find a string
I have a batch file as follows;
```
CD C:\MyFolder
findstr /c:"stringToCheck" fileToCheck.bat
IF NOT XCOPY "C:\OtherFolder\fileToCheck.bat" "C:\MyFolder" /s /y
```
I am getting an error ("C:\OtherFolder\fileToCheck.bat" was unexpected at this time.... | You are not evaluating a condition for the IF. I am guessing you want to not copy if you find stringToCheck in fileToCheck. You need to do something like (code untested but you get the idea):
```
CD C:\MyFolder
findstr /c:"stringToCheck" fileToCheck.bat
IF NOT ERRORLEVEL 0 XCOPY "C:\OtherFolder\fileToCheck.bat" "C:\My... |
18999724 | Spring Batch: One reader, multiple processors and writers | 34 | 2013-09-25 08:20:30 | <p>In Spring batch I need to pass the items read by an ItemReader to two different processors and writer. What I'm trying to achieve is that...</p>
<pre>
+---> ItemProcessor#1 ---> ItemWriter#1
|
ItemReader ---> item ---+
|
... | 49,134 | 1,631,510 | 2018-10-05 14:38:48 | 19,001,334 | 16 | 2013-09-25 09:38:46 | 2,587,166 | 2018-03-09 10:41:27 | https://stackoverflow.com/q/18999724 | https://stackoverflow.com/a/19001334 | <p>This solution is valid if your item should be processed by processor #1 and processor #2</p>
<p>You have to create a processor #0 with this signature:</p>
<pre><code>class Processor0<Item, CompositeResultBean>
</code></pre>
<p>where <code>CompositeResultBean</code> is a bean defined as</p>
<pre><code>class... | <p>This solution is valid if your item should be processed by processor #1 and processor #2</p> <p>You have to create a processor #0 with this signature:</p> <pre><code>class Processor0<Item, CompositeResultBean> </code></pre> <p>where <code>CompositeResultBean</code> is a bean defined as</p> <pre><code>class... | 1211, 41895, 134988, 134989 | itemprocessor, itemwriter, spring, spring-batch | <h1>Spring Batch: One reader, multiple processors and writers</h1>
<p>In Spring batch I need to pass the items read by an ItemReader to two different processors and writer. What I'm trying to achieve is that...</p>
<pre>
+---> ItemProcessor#1 ---> ItemWriter#1
|
ItemRead... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,128 | cmd | # Spring Batch: One reader, multiple processors and writers
In Spring batch I need to pass the items read by an ItemReader to two different processors and writer. What I'm trying to achieve is that...
```
+---> ItemProcessor#1 ---> ItemWriter#1
|
ItemReader ---> item --... | This solution is valid if your item should be processed by processor #1 and processor #2
You have to create a processor #0 with this signature:
```
class Processor0<Item, CompositeResultBean>
```
where `CompositeResultBean` is a bean defined as
```
class CompositeResultBean {
Processor1ResultBean result1;
Proce... |
12168527 | Batch file to run a command in cmd within a directory | 24 | 2012-08-28 22:39:02 | <p>I want to have a batch file(must be placed on desktop) which does the following;</p>
<ul>
<li>opens cmd</li>
<li>navigates to a directory, e.g. <code>C:\activiti-5.9\setup</code></li>
<li>runs a command within the directory, e.g. <code>ant demo.start</code> (this command runs the activiti server)</li>
</ul>
<p>I t... | 213,218 | 1,348,782 | 2019-02-11 16:01:42 | 12,197,266 | 16 | 2012-08-30 12:51:17 | 1,348,782 | 2012-08-30 12:51:17 | https://stackoverflow.com/q/12168527 | https://stackoverflow.com/a/12197266 | <p>For me, the following is working and running activiti server as well as opening the explorer in browser (with the help of <em>zb226's</em> answer and comment);</p>
<p><code>START "runas /user:administrator" cmd /K "cd C:\activiti-5.9\setup & ant demo.start"</code></p>
<p><code>START /wait localhost:8080/activi... | <p>For me, the following is working and running activiti server as well as opening the explorer in browser (with the help of <em>zb226's</em> answer and comment);</p> <p><code>START "runas /user:administrator" cmd /K "cd C:\activiti-5.9\setup & ant demo.start"</code></p> <p><code>START /wait localhost:8080/activi... | 7002 | batch-file | <h1>Batch file to run a command in cmd within a directory</h1>
<p>I want to have a batch file(must be placed on desktop) which does the following;</p>
<ul>
<li>opens cmd</li>
<li>navigates to a directory, e.g. <code>C:\activiti-5.9\setup</code></li>
<li>runs a command within the directory, e.g. <code>ant demo.start</c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,129 | cmd | # Batch file to run a command in cmd within a directory
I want to have a batch file(must be placed on desktop) which does the following;
- opens cmd
- navigates to a directory, e.g. `C:\activiti-5.9\setup`
- runs a command within the directory, e.g. `ant demo.start` (this command runs the activiti server)
I tried th... | For me, the following is working and running activiti server as well as opening the explorer in browser (with the help of *zb226's* answer and comment);
`START "runas /user:administrator" cmd /K "cd C:\activiti-5.9\setup & ant demo.start"`
`START /wait localhost:8080/activiti-explorer` |
14639743 | Batch Script to Run as Administrator | 22 | 2013-02-01 04:29:11 | <p>I'm writing a client/server checking program but it needs to run as Administrator.</p>
<p>I want this to run silently on my network and users, and I don't want the "Run as" Administrator" prompt. Is there any beginning code that I can place into the batch file to make it auto-run as Administrator?</p>
| 332,661 | 1,702,108 | 2023-12-04 17:40:40 | 20,999,038 | 16 | 2014-01-08 14:57:15 | 2,910,650 | 2018-07-03 06:54:05 | https://stackoverflow.com/q/14639743 | https://stackoverflow.com/a/20999038 | <h2>Solutions that did not work</h2>
<p>No: The - create a shortcut [ -> Compatibility -> "run this program as an administrator" ] solution does not work.</p>
<p>This option is greyed out in Windows 7. Even with UAC disabled</p>
<p>No: The <code>runas /env /user:domain\Administrator <program.exe/command you want... | <h2>Solutions that did not work</h2> <p>No: The - create a shortcut [ -> Compatibility -> "run this program as an administrator" ] solution does not work.</p> <p>This option is greyed out in Windows 7. Even with UAC disabled</p> <p>No: The <code>runas /env /user:domain\Administrator <program.exe/command you want... | 5623, 7002, 18449 | administrator, batch-file, runas | <h1>Batch Script to Run as Administrator</h1>
<p>I'm writing a client/server checking program but it needs to run as Administrator.</p>
<p>I want this to run silently on my network and users, and I don't want the "Run as" Administrator" prompt. Is there any beginning code that I can place into the batch file to make i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,130 | cmd | # Batch Script to Run as Administrator
I'm writing a client/server checking program but it needs to run as Administrator.
I want this to run silently on my network and users, and I don't want the "Run as" Administrator" prompt. Is there any beginning code that I can place into the batch file to make it auto-run as Ad... | ## Solutions that did not work
No: The - create a shortcut [ -> Compatibility -> "run this program as an administrator" ] solution does not work.
This option is greyed out in Windows 7. Even with UAC disabled
No: The `runas /env /user:domain\Administrator <program.exe/command you want to execute>` is also not suffic... |
7503491 | forfiles with UNC path | 20 | 2011-09-21 16:43:07 | <p>I am trying to use <code>ForFiles</code> to delete files that are older than 7 days.<br />
The files are in a UNC path.<br />
Below is the script that I am using.</p>
<pre class="lang-none prettyprint-override"><code>Forfiles -p \\devexpress\C$\FULL\ -s -m *.* -d -7 -c "cmd /c del /q @path"
</code></pre>
... | 73,650 | 912,896 | 2025-10-02 06:54:36 | 7,503,844 | 16 | 2011-09-21 17:14:40 | 30,447 | 2011-09-21 17:14:40 | https://stackoverflow.com/q/7503491 | https://stackoverflow.com/a/7503844 | <p>The error I get when trying to reproduce the problem says that the problem is not with FORFILES not suporting UNC Path, but with CMD not being able to start with an UNC path as default directory. In case that this is also your problem, there are three approaches to solve it.</p>
<ol>
<li><p>you might assign the UN... | <p>The error I get when trying to reproduce the problem says that the problem is not with FORFILES not suporting UNC Path, but with CMD not being able to start with an UNC path as default directory. In case that this is also your problem, there are three approaches to solve it.</p> <ol> <li><p>you might assign the UN... | 7002, 136758 | batch-file, forfiles | <h1>forfiles with UNC path</h1>
<p>I am trying to use <code>ForFiles</code> to delete files that are older than 7 days.<br />
The files are in a UNC path.<br />
Below is the script that I am using.</p>
<pre class="lang-none prettyprint-override"><code>Forfiles -p \\devexpress\C$\FULL\ -s -m *.* -d -7 -c "cmd /c de... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,131 | cmd | # forfiles with UNC path
I am trying to use `ForFiles` to delete files that are older than 7 days.
The files are in a UNC path.
Below is the script that I am using.
```
Forfiles -p \\devexpress\C$\FULL\ -s -m *.* -d -7 -c "cmd /c del /q @path"
```
But I get `ERROR: UNC paths (\\machine\share) are not supported.`... | The error I get when trying to reproduce the problem says that the problem is not with FORFILES not suporting UNC Path, but with CMD not being able to start with an UNC path as default directory. In case that this is also your problem, there are three approaches to solve it.
1. you might assign the UNC path to a disk ... |
23116474 | print vs. echo in R | 19 | 2014-04-16 17:43:14 | <p>I'm running a batch process using Rscript. I would like to print messages to screen just like "echo" does in bash. So I use the function "print".</p>
<p>The problem is that print's output does not go to the screen. It goes to the log file instead. Anybody knows what's the equivalent of echo in R?</p>
| 26,241 | 1,267,849 | 2015-02-09 10:51:52 | 28,408,025 | 16 | 2015-02-09 10:51:52 | 139,637 | 2015-02-09 10:51:52 | https://stackoverflow.com/q/23116474 | https://stackoverflow.com/a/28408025 | <p>As Thomas pointed out on the comments...</p>
<p><code>message ("Print this on the screen")</code></p>
<p>For more info you can check the <a href="http://stat.ethz.ch/R-manual/R-devel/library/base/html/message.html">message documentation</a></p>
| <p>As Thomas pointed out on the comments...</p> <p><code>message ("Print this on the screen")</code></p> <p>For more info you can check the <a href="http://stat.ethz.ch/R-manual/R-devel/library/base/html/message.html">message documentation</a></p> | 4452, 13824, 30645, 44486 | batch-processing, echo, r, rscript | <h1>print vs. echo in R</h1>
<p>I'm running a batch process using Rscript. I would like to print messages to screen just like "echo" does in bash. So I use the function "print".</p>
<p>The problem is that print's output does not go to the screen. It goes to the log file instead. Anybody knows what's the equivalent of... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,132 | cmd | # print vs. echo in R
I'm running a batch process using Rscript. I would like to print messages to screen just like "echo" does in bash. So I use the function "print".
The problem is that print's output does not go to the screen. It goes to the log file instead. Anybody knows what's the equivalent of echo in R? | As Thomas pointed out on the comments...
`message ("Print this on the screen")`
For more info you can check the [message documentation](http://stat.ethz.ch/R-manual/R-devel/library/base/html/message.html) |
16301315 | Spring @Transactional and JDBC autoCommit | 19 | 2013-04-30 13:37:54 | <p>On my actual application, I have a DBCP connection pool which doesn't have JDBC autoCommit=false set. It seems to have the default autoCommit=true.
This is probably a mistake but I'd like to understand the impact of changing this parameter.</p>
<p>I am using:
- Spring with @Transactional annotation
- Spring Batch... | 24,842 | 82,609 | 2013-04-30 14:28:33 | 16,302,350 | 16 | 2013-04-30 14:28:33 | 567,420 | 2013-04-30 14:28:33 | https://stackoverflow.com/q/16301315 | https://stackoverflow.com/a/16302350 | <p>PlatformTransactionManager is an interface, so I would not blanket say that all implementations set AutoCommit = false, however the most common implementation (DataSourceTransactionManager) does set AutoCommit = false. see code snippet below from the doBegin method:</p>
<pre><code>if (con.getAutoCommit()) {
... | <p>PlatformTransactionManager is an interface, so I would not blanket say that all implementations set AutoCommit = false, however the most common implementation (DataSourceTransactionManager) does set AutoCommit = false. see code snippet below from the doBegin method:</p> <pre><code>if (con.getAutoCommit()) { ... | 1211, 5617, 41895 | jdbc, spring, spring-batch | <h1>Spring @Transactional and JDBC autoCommit</h1>
<p>On my actual application, I have a DBCP connection pool which doesn't have JDBC autoCommit=false set. It seems to have the default autoCommit=true.
This is probably a mistake but I'd like to understand the impact of changing this parameter.</p>
<p>I am using:
- Sp... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,133 | cmd | # Spring @Transactional and JDBC autoCommit
On my actual application, I have a DBCP connection pool which doesn't have JDBC autoCommit=false set. It seems to have the default autoCommit=true.
This is probably a mistake but I'd like to understand the impact of changing this parameter.
I am using:
- Spring with @Transa... | PlatformTransactionManager is an interface, so I would not blanket say that all implementations set AutoCommit = false, however the most common implementation (DataSourceTransactionManager) does set AutoCommit = false. see code snippet below from the doBegin method:
```
if (con.getAutoCommit()) {
txObject.... |
8143132 | batch file to open tabs in a NEW browser window | 18 | 2011-11-15 21:06:21 | <p>I need to modify batch file.</p>
<p>I have a batch file that opens many tabs when I click icon from desktop. These tabs are opened in my ALREADY OPENED default browser.</p>
<p>I would like to have a NEW WINDOW open for these tabs. </p>
<p>The batch file looks like this:</p>
<pre><code>@echo off
start "webpage na... | 109,834 | 552,085 | 2024-05-14 06:46:29 | 8,155,628 | 16 | 2011-11-16 17:03:14 | 552,085 | 2011-11-17 21:10:15 | https://stackoverflow.com/q/8143132 | https://stackoverflow.com/a/8155628 | <p>I figured this out.</p>
<p>The batch file to open a NEW browser window, and then the intended websites:</p>
<pre><code>@echo off
"C:\Users\THEUSER\AppData\Local\Google\Chrome\Application\chrome.exe"
sleep1
start "webpage name" "http://someurl.com/"
start "webpage name" "http://someurl.com/"
start "webpage name" "h... | <p>I figured this out.</p> <p>The batch file to open a NEW browser window, and then the intended websites:</p> <pre><code>@echo off "C:\Users\THEUSER\AppData\Local\Google\Chrome\Application\chrome.exe" sleep1 start "webpage name" "http://someurl.com/" start "webpage name" "http://someurl.com/" start "webpage name" "h... | 27, 64, 7002 | batch-file, browser, windows | <h1>batch file to open tabs in a NEW browser window</h1>
<p>I need to modify batch file.</p>
<p>I have a batch file that opens many tabs when I click icon from desktop. These tabs are opened in my ALREADY OPENED default browser.</p>
<p>I would like to have a NEW WINDOW open for these tabs. </p>
<p>The batch file loo... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,134 | cmd | # batch file to open tabs in a NEW browser window
I need to modify batch file.
I have a batch file that opens many tabs when I click icon from desktop. These tabs are opened in my ALREADY OPENED default browser.
I would like to have a NEW WINDOW open for these tabs.
The batch file looks like this:
```
@echo off
st... | I figured this out.
The batch file to open a NEW browser window, and then the intended websites:
```
@echo off
"C:\Users\THEUSER\AppData\Local\Google\Chrome\Application\chrome.exe"
sleep1
start "webpage name" "http://someurl.com/"
start "webpage name" "http://someurl.com/"
start "webpage name" "http://someurl.com/"
s... |
5795430 | Error Handling with Batch File & Sqlcmd | 18 | 2011-04-26 19:28:52 | <p>I have a batch file that runs some SELECT queries using sqlcmd, puts the results into text files, and uploads those files onto an FTP server. That's all working just the way it should, which is how I like things to work.</p>
<p>I've been wondering about what I would do in the event of an error, though. Let's say so... | 42,712 | 332,544 | 2016-03-14 14:47:39 | 5,795,500 | 16 | 2011-04-26 19:36:51 | 109,360 | 2016-03-14 14:47:39 | https://stackoverflow.com/q/5795430 | https://stackoverflow.com/a/5795500 | <p>You can check <code>errorlevel</code> returned from <code>SQLCMD</code> to see if it failed.</p>
<pre><code> sqlcmd -b <yourscript>
IF ERRORLEVEL 1 goto err_handler
goto done
:err_handler
REM handle the error here
:done
REM script completion code here
</code></pre>
| <p>You can check <code>errorlevel</code> returned from <code>SQLCMD</code> to see if it failed.</p> <pre><code> sqlcmd -b <yourscript> IF ERRORLEVEL 1 goto err_handler goto done :err_handler REM handle the error here :done REM script completion code here </code></pre> | 64, 379, 7002, 7445 | batch-file, error-handling, sqlcmd, windows | <h1>Error Handling with Batch File & Sqlcmd</h1>
<p>I have a batch file that runs some SELECT queries using sqlcmd, puts the results into text files, and uploads those files onto an FTP server. That's all working just the way it should, which is how I like things to work.</p>
<p>I've been wondering about what I would ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,135 | cmd | # Error Handling with Batch File & Sqlcmd
I have a batch file that runs some SELECT queries using sqlcmd, puts the results into text files, and uploads those files onto an FTP server. That's all working just the way it should, which is how I like things to work.
I've been wondering about what I would do in the event ... | You can check `errorlevel` returned from `SQLCMD` to see if it failed.
```
sqlcmd -b <yourscript>
IF ERRORLEVEL 1 goto err_handler
goto done
:err_handler
REM handle the error here
:done
REM script completion code here
``` |
7773198 | How to cast List<? extends Foo> to List<Foo> | 17 | 2011-10-14 20:26:01 | <p>Spring Batch's <a href="http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/item/ItemWriter.html">ItemWriter</a> interface is this:</p>
<pre><code>write(List<? extends T> items);
</code></pre>
<p>I'd like the ItemWriter to call a Service but my service has this:</p>
<pre><code>pro... | 6,583 | 487,039 | 2017-12-20 19:42:47 | 7,774,068 | 16 | 2011-10-14 22:04:27 | 218,978 | 2017-12-20 19:42:47 | https://stackoverflow.com/q/7773198 | https://stackoverflow.com/a/7774068 | <p>Just go ahead and cast it. For reading, <code>List<? extends Foo></code> is certainly a <code>List<Foo></code>, the cast is absolutely safe. You can wrap it with <code>Collections.unmodifiableList()</code> if you are paranoid.</p>
<pre><code>List<? extends Foo> foos1 = ...;
@SuppressWarnings("unc... | <p>Just go ahead and cast it. For reading, <code>List<? extends Foo></code> is certainly a <code>List<Foo></code>, the cast is absolutely safe. You can wrap it with <code>Collections.unmodifiableList()</code> if you are paranoid.</p> <pre><code>List<? extends Foo> foos1 = ...; @SuppressWarnings("unc... | 17, 41895 | java, spring-batch | <h1>How to cast List<? extends Foo> to List<Foo></h1>
<p>Spring Batch's <a href="http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/item/ItemWriter.html">ItemWriter</a> interface is this:</p>
<pre><code>write(List<? extends T> items);
</code></pre>
<p>I'd like the ItemWriter to call ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,136 | cmd | # How to cast List extends Foo to List
Spring Batch's [ItemWriter](http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/item/ItemWriter.html) interface is this:
```
write(List<? extends T> items);
```
I'd like the ItemWriter to call a Service but my service has this:
```
process(List<T> ite... | Just go ahead and cast it. For reading, `List<? extends Foo>` is certainly a `List<Foo>`, the cast is absolutely safe. You can wrap it with `Collections.unmodifiableList()` if you are paranoid.
```
List<? extends Foo> foos1 = ...;
@SuppressWarnings("unchecked")
List<Foo> foos2 = (List<Foo>)(List<?>)foos1;
``` |
6616287 | Running a BAT file from ANT | 16 | 2011-07-07 19:51:58 | <p>I have gone through number of posts on the very forum but couldn't sort it out. I am trying to run a BAT file from ANT script. The folder hierarchy is like this</p>
<pre><code>- Project
| - build.xml
| - build-C
| | - test.bat
</code></pre>
<p>The ANT file that i wrote so for is</p>
<pre><code><project name="M... | 29,528 | 50,820 | 2022-06-18 21:05:43 | 6,616,353 | 16 | 2011-07-07 19:56:32 | 824,493 | 2011-07-07 19:56:32 | https://stackoverflow.com/q/6616287 | https://stackoverflow.com/a/6616353 | <pre><code><property name="buildC" value="${basedire}\build-C" />
</code></pre>
<p>This should be <code>${basedir}</code> I guess? Use </p>
<pre><code><echo>${buildC}</echo>
</code></pre>
<p>to make sure the dir is correct.</p>
<p>And shouldn't </p>
<pre><code><exec dir="${buildC}" executable=... | <pre><code><property name="buildC" value="${basedire}\build-C" /> </code></pre> <p>This should be <code>${basedir}</code> I guess? Use </p> <pre><code><echo>${buildC}</echo> </code></pre> <p>to make sure the dir is correct.</p> <p>And shouldn't </p> <pre><code><exec dir="${buildC}" executable=... | 142, 1362, 7002 | ant, automation, batch-file | <h1>Running a BAT file from ANT</h1>
<p>I have gone through number of posts on the very forum but couldn't sort it out. I am trying to run a BAT file from ANT script. The folder hierarchy is like this</p>
<pre><code>- Project
| - build.xml
| - build-C
| | - test.bat
</code></pre>
<p>The ANT file that i wrote so for i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,137 | cmd | # Running a BAT file from ANT
I have gone through number of posts on the very forum but couldn't sort it out. I am trying to run a BAT file from ANT script. The folder hierarchy is like this
```
- Project
| - build.xml
| - build-C
| | - test.bat
```
The ANT file that i wrote so for is
```
<project name="MyProject" ... | ```
<property name="buildC" value="${basedire}\build-C" />
```
This should be `${basedir}` I guess? Use
```
<echo>${buildC}</echo>
```
to make sure the dir is correct.
And shouldn't
```
<exec dir="${buildC}" executable="test.bat" os="Windows XP" />
```
do the job? |
2451861 | How to NOT wait for a process to complete in batch script? | 15 | 2010-03-16 03:03:19 | <p>I have a batch script that calls a process and currently it waits for the process to complete before going to the next line. Is there a way (or a switch) for it NOT to wait and just spawn the process and continue? I am using Windows 2008.</p>
| 37,511 | 235,334 | 2020-11-09 15:21:06 | 2,451,875 | 16 | 2010-03-16 03:06:49 | 118,703 | 2015-08-03 12:07:09 | https://stackoverflow.com/q/2451861 | https://stackoverflow.com/a/2451875 | <p>Use</p>
<pre><code>START c:\wherever\whatever.exe
</code></pre>
| <p>Use</p> <pre><code>START c:\wherever\whatever.exe </code></pre> | 64, 1231, 7002 | batch-file, command-line, windows | <h1>How to NOT wait for a process to complete in batch script?</h1>
<p>I have a batch script that calls a process and currently it waits for the process to complete before going to the next line. Is there a way (or a switch) for it NOT to wait and just spawn the process and continue? I am using Windows 2008.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,139 | cmd | # How to NOT wait for a process to complete in batch script?
I have a batch script that calls a process and currently it waits for the process to complete before going to the next line. Is there a way (or a switch) for it NOT to wait and just spawn the process and continue? I am using Windows 2008. | Use
```
START c:\wherever\whatever.exe
``` |
22352793 | Reading a registry value to a batch variable, handling spaces in value | 14 | 2014-03-12 13:18:06 | <p>I'm struggling to read the value of a registry key into a variable. The registry value may, or may not, contain spaces. In this case I'm trying to look up SDK paths.</p>
<p>It's easy to get the value with <code>reg query</code>, but it's returned in a remarkably unhelpful format:</p>
<pre><code>C:\Users\Administra... | 19,583 | 398,670 | 2019-11-19 19:28:20 | 22,353,131 | 16 | 2014-03-12 13:32:03 | 891,976 | 2014-03-12 13:37:18 | https://stackoverflow.com/q/22352793 | https://stackoverflow.com/a/22353131 | <p>Ah this is one of the annoying details about the <code>for /f</code> command. In order to read all the characters including the spaces with the <code>*</code> the <strong>previous</strong> token needs to be declared. <code>tokens=2,*</code> The functional reason is stated in the documentation.</p>
<blockquote>
... | <p>Ah this is one of the annoying details about the <code>for /f</code> command. In order to read all the characters including the spaces with the <code>*</code> the <strong>previous</strong> token needs to be declared. <code>tokens=2,*</code> The functional reason is stated in the documentation.</p> <blockquote> ... | 64, 7002 | batch-file, windows | <h1>Reading a registry value to a batch variable, handling spaces in value</h1>
<p>I'm struggling to read the value of a registry key into a variable. The registry value may, or may not, contain spaces. In this case I'm trying to look up SDK paths.</p>
<p>It's easy to get the value with <code>reg query</code>, but it'... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,140 | cmd | # Reading a registry value to a batch variable, handling spaces in value
I'm struggling to read the value of a registry key into a variable. The registry value may, or may not, contain spaces. In this case I'm trying to look up SDK paths.
It's easy to get the value with `reg query`, but it's returned in a remarkably ... | Ah this is one of the annoying details about the `for /f` command. In order to read all the characters including the spaces with the `*` the **previous** token needs to be declared. `tokens=2,*` The functional reason is stated in the documentation.
> If the last character in the tokens= string is an asterisk (*), an *... |
30611803 | How to set the title of a Windows console while npm is running? | 13 | 2015-06-03 05:49:44 | <p>I have started to develop a web application project on my Windows machine, for which I use <a href="https://www.npmjs.com/" rel="noreferrer">npm</a>, <a href="http://bower.io/" rel="noreferrer">bower</a>, and the <a href="https://nodejs.org/" rel="noreferrer">nodejs</a> HTTP server.</p>
<p>For easier start of the HT... | 8,445 | 664,033 | 2025-01-29 20:14:58 | 30,611,970 | 16 | 2015-06-03 06:01:22 | 4,276,650 | 2023-04-16 22:49:16 | https://stackoverflow.com/q/30611803 | https://stackoverflow.com/a/30611970 | <p>Set the title in your <code>package.json</code> file:</p>
<pre><code>"start": "title HTTP Server && http-server -a localhost -p 8000 -c-1"
</code></pre>
<p> </p>
| <p>Set the title in your <code>package.json</code> file:</p> <pre><code>"start": "title HTTP Server && http-server -a localhost -p 8000 -c-1" </code></pre> <p> </p> | 64, 7002, 46426, 61387 | batch-file, node.js, npm, windows | <h1>How to set the title of a Windows console while npm is running?</h1>
<p>I have started to develop a web application project on my Windows machine, for which I use <a href="https://www.npmjs.com/" rel="noreferrer">npm</a>, <a href="http://bower.io/" rel="noreferrer">bower</a>, and the <a href="https://nodejs.org/" r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,141 | cmd | # How to set the title of a Windows console while npm is running?
I have started to develop a web application project on my Windows machine, for which I use [npm](https://www.npmjs.com/), [bower](http://bower.io/), and the [nodejs](https://nodejs.org/) HTTP server.
For easier start of the HTTP server, I created the b... | Set the title in your `package.json` file:
```
"start": "title HTTP Server && http-server -a localhost -p 8000 -c-1"
``` |
31518737 | Can I search for multiple strings in one "find" command in batch script? | 12 | 2015-07-20 14:10:16 | <p>I have a windows batch script that will look for a string within a file</p>
<pre><code>find /i "WD6" %Inputpath%file.txt
if %errorlevel% == 0 GOTO somestuff
</code></pre>
<p>Currently this is what my code looks like. I've come across a new string I want to search for in the same file and do the same action if it ... | 88,952 | 1,088,796 | 2025-08-26 01:19:28 | 31,518,829 | 16 | 2015-07-20 14:14:27 | 2,152,082 | 2015-07-20 15:17:34 | https://stackoverflow.com/q/31518737 | https://stackoverflow.com/a/31518829 | <p><code>find</code> isn't very powerful. It searches for one string only (even if it is two words): <code>find "my string" file.txt</code> looks for the string <code>my string</code>.</p>
<p><code>findstr</code> has much more power, but you have to be careful how to use it:</p>
<pre><code>findstr "hello world" file.... | <p><code>find</code> isn't very powerful. It searches for one string only (even if it is two words): <code>find "my string" file.txt</code> looks for the string <code>my string</code>.</p> <p><code>findstr</code> has much more power, but you have to be careful how to use it:</p> <pre><code>findstr "hello world" file.... | 64, 7002, 10193, 18656 | batch-file, find, findinfiles, windows | <h1>Can I search for multiple strings in one "find" command in batch script?</h1>
<p>I have a windows batch script that will look for a string within a file</p>
<pre><code>find /i "WD6" %Inputpath%file.txt
if %errorlevel% == 0 GOTO somestuff
</code></pre>
<p>Currently this is what my code looks like. I've come acros... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,142 | cmd | # Can I search for multiple strings in one "find" command in batch script?
I have a windows batch script that will look for a string within a file
```
find /i "WD6" %Inputpath%file.txt
if %errorlevel% == 0 GOTO somestuff
```
Currently this is what my code looks like. I've come across a new string I want to search f... | `find` isn't very powerful. It searches for one string only (even if it is two words): `find "my string" file.txt` looks for the string `my string`.
`findstr` has much more power, but you have to be careful how to use it:
```
findstr "hello world" file.txt
```
finds any line, that contains either `hello` or `world` ... |
20646860 | Batch file; Replace variable's spaces with hyphens | 12 | 2013-12-17 23:34:37 | <p>I've started another small Batch project, however I've encountered a bit of a dilemma. I use <code>set name=</code> followed by <code>set /p name=</code>, to allow the user to give the input desired. However, I want the variable entered with spaces to then have the spaces replaced with hyphens (e.g. <em>"hello world... | 21,461 | null | 2016-12-25 03:16:19 | 20,646,977 | 16 | 2013-12-17 23:43:45 | 1,518,974 | 2013-12-17 23:43:45 | https://stackoverflow.com/q/20646860 | https://stackoverflow.com/a/20646977 | <p>You're close.</p>
<pre><code>@echo off
cls
echo Insert a string with spaces?
set string=
set /p string=
set string=%string: =-%
echo String is now %string%
</code></pre>
<p>See <code>set /?</code> for details on variable manipulation.</p>
| <p>You're close.</p> <pre><code>@echo off cls echo Insert a string with spaces? set string= set /p string= set string=%string: =-% echo String is now %string% </code></pre> <p>See <code>set /?</code> for details on variable manipulation.</p> | 276, 2498, 7002 | batch-file, replace, variables | <h1>Batch file; Replace variable's spaces with hyphens</h1>
<p>I've started another small Batch project, however I've encountered a bit of a dilemma. I use <code>set name=</code> followed by <code>set /p name=</code>, to allow the user to give the input desired. However, I want the variable entered with spaces to then ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,143 | cmd | # Batch file; Replace variable's spaces with hyphens
I've started another small Batch project, however I've encountered a bit of a dilemma. I use `set name=` followed by `set /p name=`, to allow the user to give the input desired. However, I want the variable entered with spaces to then have the spaces replaced with h... | You're close.
```
@echo off
cls
echo Insert a string with spaces?
set string=
set /p string=
set string=%string: =-%
echo String is now %string%
```
See `set /?` for details on variable manipulation. |
17246558 | What is the windows equivalent to the ln -s <target folder> <link folder> unix symbolic link command? | 12 | 2013-06-22 01:46:23 | <p>I'm attempting to follow the following tutorial for creating a program environment for the Twilio and App Engine library.</p>
<p><a href="https://developers.google.com/appengine/articles/twilio" rel="noreferrer">https://developers.google.com/appengine/articles/twilio</a></p>
<p>I'm good up until the point it says:... | 16,740 | 2,510,752 | 2016-07-26 10:50:45 | 17,246,581 | 16 | 2013-06-22 01:50:31 | 1,715,716 | 2013-06-22 05:31:30 | https://stackoverflow.com/q/17246558 | https://stackoverflow.com/a/17246581 | <p>Try this :</p>
<pre><code>mklink /D .\ venv\lib\python2.7\site-packages\httplib2
</code></pre>
<p><strong>Note : mklink [OPTION] LINK TARGET</strong> (link and target are flipped compared to linux's <code>ln -s</code>)</p>
<blockquote>
<p><strong>Mklink Command Syntax :</strong></p>
<p>MKLINK has 3 options... | <p>Try this :</p> <pre><code>mklink /D .\ venv\lib\python2.7\site-packages\httplib2 </code></pre> <p><strong>Note : mklink [OPTION] LINK TARGET</strong> (link and target are flipped compared to linux's <code>ln -s</code>)</p> <blockquote> <p><strong>Mklink Command Syntax :</strong></p> <p>MKLINK has 3 options... | 34, 64, 1122, 2631 | cmd, symlink, unix, windows | <h1>What is the windows equivalent to the ln -s <target folder> <link folder> unix symbolic link command?</h1>
<p>I'm attempting to follow the following tutorial for creating a program environment for the Twilio and App Engine library.</p>
<p><a href="https://developers.google.com/appengine/articles/twilio" rel="noref... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,144 | cmd | # What is the windows equivalent to the ln -s unix symbolic link command?
I'm attempting to follow the following tutorial for creating a program environment for the Twilio and App Engine library.
<https://developers.google.com/appengine/articles/twilio>
I'm good up until the point it says:
> Link the Twilio library... | Try this :
```
mklink /D .\ venv\lib\python2.7\site-packages\httplib2
```
**Note : mklink [OPTION] LINK TARGET** (link and target are flipped compared to linux's `ln -s`)
> **Mklink Command Syntax :**
>
> MKLINK has 3 options /D, /H and /J. You also need to specify the path
> to the new symbolic link and the path to... |
14498206 | Running batch file with arguments from C# | 12 | 2013-01-24 09:44:36 | <p>I have a batch file like this</p>
<pre><code>@echo off
xcopy /e %1 %2
</code></pre>
<p>I have my C# code as follows:</p>
<pre><code>string MyBatchFile = @"C:\Program Files (x86)\MybatchFile.bat";
string _sourcePath = @"C:\FolderToCopy";
string _tempTargetPath = @"C:\TargetFolder\";
var process = new Process {
... | 43,741 | 815,600 | 2025-02-12 15:50:52 | 14,498,704 | 16 | 2013-01-24 10:10:16 | 45,003 | 2013-01-24 10:10:16 | https://stackoverflow.com/q/14498206 | https://stackoverflow.com/a/14498704 | <p>What about quoting argument?</p>
<pre><code>Arguments = String.Format("\"{0}\" \"{1}\"", _sourcePath, _tempTargetPath) …
</code></pre>
| <p>What about quoting argument?</p> <pre><code>Arguments = String.Format("\"{0}\" \"{1}\"", _sourcePath, _tempTargetPath) … </code></pre> | 9, 2313, 4710, 7002 | arguments, batch-file, c#, xcopy | <h1>Running batch file with arguments from C#</h1>
<p>I have a batch file like this</p>
<pre><code>@echo off
xcopy /e %1 %2
</code></pre>
<p>I have my C# code as follows:</p>
<pre><code>string MyBatchFile = @"C:\Program Files (x86)\MybatchFile.bat";
string _sourcePath = @"C:\FolderToCopy";
string _tempTargetPath = @... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,145 | cmd | # Running batch file with arguments from C#
I have a batch file like this
```
@echo off
xcopy /e %1 %2
```
I have my C# code as follows:
```
string MyBatchFile = @"C:\Program Files (x86)\MybatchFile.bat";
string _sourcePath = @"C:\FolderToCopy";
string _tempTargetPath = @"C:\TargetFolder\";
var process = new Proce... | What about quoting argument?
```
Arguments = String.Format("\"{0}\" \"{1}\"", _sourcePath, _tempTargetPath) …
``` |
982295 | Saving 1000+ records to the database at a time | 12 | 2009-06-11 16:53:21 | <p>I'm using NHibernate currently. I have a situation where I need to save a bunch of records to the database like this:</p>
<pre><code>var relatedTopics = GetRelatedTopics(topic);
foreach (var relatedTopic in relatedTopics /* could be anywhere from 10 - 1000+ */)
{
var newRelatedTopic = new RelatedTopic { Related... | 16,429 | 17,744 | 2015-11-18 12:45:51 | 982,305 | 16 | 2009-06-11 16:54:52 | 33,827 | 2009-06-11 16:54:52 | https://stackoverflow.com/q/982295 | https://stackoverflow.com/a/982305 | <p>setting adonet.batch_size could improve the situation.</p>
<p>For that you have to </p>
<ul>
<li>set adonet.batch_size in the NH configuration</li>
</ul>
<p>Example:</p>
<pre><code> m_sessionFactory = Fluently
.Configure()
.Database(MsSqlConfiguration
.MsSql2005
.Co... | <p>setting adonet.batch_size could improve the situation.</p> <p>For that you have to </p> <ul> <li>set adonet.batch_size in the NH configuration</li> </ul> <p>Example:</p> <pre><code> m_sessionFactory = Fluently .Configure() .Database(MsSqlConfiguration .MsSql2005 .Co... | 352, 729, 30645 | ado.net, batch-processing, nhibernate | <h1>Saving 1000+ records to the database at a time</h1>
<p>I'm using NHibernate currently. I have a situation where I need to save a bunch of records to the database like this:</p>
<pre><code>var relatedTopics = GetRelatedTopics(topic);
foreach (var relatedTopic in relatedTopics /* could be anywhere from 10 - 1000+ */... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,146 | cmd | # Saving 1000+ records to the database at a time
I'm using NHibernate currently. I have a situation where I need to save a bunch of records to the database like this:
```
var relatedTopics = GetRelatedTopics(topic);
foreach (var relatedTopic in relatedTopics /* could be anywhere from 10 - 1000+ */)
{
var newRelat... | setting adonet.batch_size could improve the situation.
For that you have to
- set adonet.batch_size in the NH configuration
Example:
```
m_sessionFactory = Fluently
.Configure()
.Database(MsSqlConfiguration
.MsSql2005
.ConnectionString(c => c.FromConnectionStringWithK... |
694203 | Controlling psftp in a Windows Batch File | 12 | 2009-03-29 06:24:14 | <p>How do I write a batch file to control psftp, but with a dynamic filename? Overall I'm trying to convert a video file and then upload it to my Apple TV. Here's what I have, it generally works, but the commands don't control psftp, psftp just waits for user input:</p>
<pre><code>echo Convert and Upload to Apple TV f... | 70,200 | 5,464 | 2015-08-26 17:37:37 | 873,434 | 16 | 2009-05-16 22:15:09 | 5,464 | 2009-05-16 22:15:09 | https://stackoverflow.com/q/694203 | https://stackoverflow.com/a/873434 | <p>I ended up creating a new batch file from the main one that I then told psftp to use:</p>
<pre><code>echo cd downloads/boxee > psftp.bat
echo put "%1.avi" >> psftp.bat
echo quit >> psftp.bat
psftp frontrow@192.168.1.50 -pw aaa -b psftp.bat
</code></pre>
| <p>I ended up creating a new batch file from the main one that I then told psftp to use:</p> <pre><code>echo cd downloads/boxee > psftp.bat echo put "%1.avi" >> psftp.bat echo quit >> psftp.bat psftp frontrow@192.168.1.50 -pw aaa -b psftp.bat </code></pre> | 64, 7002 | batch-file, windows | <h1>Controlling psftp in a Windows Batch File</h1>
<p>How do I write a batch file to control psftp, but with a dynamic filename? Overall I'm trying to convert a video file and then upload it to my Apple TV. Here's what I have, it generally works, but the commands don't control psftp, psftp just waits for user input:</p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,147 | cmd | # Controlling psftp in a Windows Batch File
How do I write a batch file to control psftp, but with a dynamic filename? Overall I'm trying to convert a video file and then upload it to my Apple TV. Here's what I have, it generally works, but the commands don't control psftp, psftp just waits for user input:
```
echo C... | I ended up creating a new batch file from the main one that I then told psftp to use:
```
echo cd downloads/boxee > psftp.bat
echo put "%1.avi" >> psftp.bat
echo quit >> psftp.bat
psftp frontrow@192.168.1.50 -pw aaa -b psftp.bat
``` |
29970897 | CMD: File tasks, open directory and select file | 11 | 2015-04-30 14:49:23 | <p>I want to open a folder and automatically select a file from the command line:</p>
<pre><code>>> explorer C:\Windows\system32\selected_file.txt
</code></pre>
<p>Once Windows Explorer has opened <code>C:\Windows\system32</code> I want <code>selected_file.txt</code> to be highlighted automatically. Is that pos... | 10,898 | 3,322,384 | 2015-04-30 15:05:34 | 29,971,276 | 16 | 2015-04-30 15:05:34 | 4,801,920 | 2015-04-30 15:05:34 | https://stackoverflow.com/q/29970897 | https://stackoverflow.com/a/29971276 | <pre><code>explorer.exe /select,c:\windows\system32\selected_file.txt
</code></pre>
<p>See <a href="https://support.microsoft.com/en-us/kb/130510" rel="noreferrer">https://support.microsoft.com/en-us/kb/130510</a></p>
| <pre><code>explorer.exe /select,c:\windows\system32\selected_file.txt </code></pre> <p>See <a href="https://support.microsoft.com/en-us/kb/130510" rel="noreferrer">https://support.microsoft.com/en-us/kb/130510</a></p> | 638, 2631, 7002 | batch-file, cmd, explorer | <h1>CMD: File tasks, open directory and select file</h1>
<p>I want to open a folder and automatically select a file from the command line:</p>
<pre><code>>> explorer C:\Windows\system32\selected_file.txt
</code></pre>
<p>Once Windows Explorer has opened <code>C:\Windows\system32</code> I want <code>selected_fil... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,148 | cmd | # CMD: File tasks, open directory and select file
I want to open a folder and automatically select a file from the command line:
```
>> explorer C:\Windows\system32\selected_file.txt
```
Once Windows Explorer has opened `C:\Windows\system32` I want `selected_file.txt` to be highlighted automatically. Is that possibl... | ```
explorer.exe /select,c:\windows\system32\selected_file.txt
```
See <https://support.microsoft.com/en-us/kb/130510> |
8921253 | Why doesn't this FINDSTR example with multiple literal search strings find a match? | 11 | 2012-01-19 05:01:57 | <p>Sometimes FINDSTR with multiple literal search strings fails to find all matches. For example, the following FINDSTR example fails to find a match.</p>
<pre><code>echo ffffaaa|findstr /l "ffffaaa faffaffddd"
</code></pre>
<p>Why?</p>
| 19,594 | 1,012,053 | 2023-02-24 17:41:58 | 8,921,279 | 16 | 2012-01-19 05:05:27 | 1,012,053 | 2016-01-05 21:03:06 | https://stackoverflow.com/q/8921253 | https://stackoverflow.com/a/8921279 | <p>Apparantly this is a long standing FINDSTR bug. I think it can be a crippling bug, depending on the circumstances.</p>
<p>I have confirmed the command fails on two different Vista machines, a Windows 7 machine, and an XP machine.
I found this <a href="http://www.pcreview.co.uk/forums/findstr-broken-t2691450.html" r... | <p>Apparantly this is a long standing FINDSTR bug. I think it can be a crippling bug, depending on the circumstances.</p> <p>I have confirmed the command fails on two different Vista machines, a Windows 7 machine, and an XP machine. I found this <a href="http://www.pcreview.co.uk/forums/findstr-broken-t2691450.html" r... | 2631, 7002, 21229 | batch-file, cmd, findstr | <h1>Why doesn't this FINDSTR example with multiple literal search strings find a match?</h1>
<p>Sometimes FINDSTR with multiple literal search strings fails to find all matches. For example, the following FINDSTR example fails to find a match.</p>
<pre><code>echo ffffaaa|findstr /l "ffffaaa faffaffddd"
</code... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,149 | cmd | # Why doesn't this FINDSTR example with multiple literal search strings find a match?
Sometimes FINDSTR with multiple literal search strings fails to find all matches. For example, the following FINDSTR example fails to find a match.
```
echo ffffaaa|findstr /l "ffffaaa faffaffddd"
```
Why? | Apparantly this is a long standing FINDSTR bug. I think it can be a crippling bug, depending on the circumstances.
I have confirmed the command fails on two different Vista machines, a Windows 7 machine, and an XP machine.
I found this [findstr - broken ???](http://www.pcreview.co.uk/forums/findstr-broken-t2691450.htm... |
4215405 | how to run a cmd.exe batch file in a sub shell | 11 | 2010-11-18 13:48:37 | <p>I have a batch file that I usually invoke like this:</p>
<pre><code> longjob.cmd >result.txt 2>&1
</code></pre>
<p>This works fine, but the script changes directory during its execution leaving my shell in that directory - which is a nuisance.</p>
<p>Is there a way to run the command within a sub-shell ... | 36,803 | 37,367 | 2010-11-18 16:44:22 | 4,215,587 | 16 | 2010-11-18 14:05:05 | null | 2010-11-18 16:44:22 | https://stackoverflow.com/q/4215405 | https://stackoverflow.com/a/4215587 | <p>Try</p>
<pre><code>CMD /C longjob.cmd >result.txt 2>&1
</code></pre>
<p>Not sure how it'll deal with the redirection, but CMD /C lets you tell CMD what to run and that it should exit when done. (CMD /K lets you tell it to run something but stick around when done.) It will re-use the existing console wind... | <p>Try</p> <pre><code>CMD /C longjob.cmd >result.txt 2>&1 </code></pre> <p>Not sure how it'll deal with the redirection, but CMD /C lets you tell CMD what to run and that it should exit when done. (CMD /K lets you tell it to run something but stick around when done.) It will re-use the existing console wind... | 64, 2631 | cmd, windows | <h1>how to run a cmd.exe batch file in a sub shell</h1>
<p>I have a batch file that I usually invoke like this:</p>
<pre><code> longjob.cmd >result.txt 2>&1
</code></pre>
<p>This works fine, but the script changes directory during its execution leaving my shell in that directory - which is a nuisance.</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,150 | cmd | # how to run a cmd.exe batch file in a sub shell
I have a batch file that I usually invoke like this:
```
longjob.cmd >result.txt 2>&1
```
This works fine, but the script changes directory during its execution leaving my shell in that directory - which is a nuisance.
Is there a way to run the command within a sub-... | Try
```
CMD /C longjob.cmd >result.txt 2>&1
```
Not sure how it'll deal with the redirection, but CMD /C lets you tell CMD what to run and that it should exit when done. (CMD /K lets you tell it to run something but stick around when done.) It will re-use the existing console window if run within one. |
65059250 | SSH and SCP failed with "CreateProcessW failed error:2 posix_spawn: No such file or directory" | 10 | 2020-11-29 10:45:27 | <p>I am trying to do SSH and SCP to AWS managed instance. The public key of my machine is stored at that managed instance. There is no .pem file required. I am using the following commands.</p>
<pre><code> scp -r username@instance-id:/pathtoremotefile localpath
scp localfilepath username@instance-id:~
ssh us... | 16,078 | 14,302,006 | 2024-02-07 05:52:12 | 65,087,746 | 16 | 2020-12-01 09:21:11 | 463,115 | 2020-12-01 10:48:07 | https://stackoverflow.com/q/65059250 | https://stackoverflow.com/a/65087746 | <p>This seems to be a problem of the Windows openSSH package.
In ProxyCommands it requests full path qualifiers, but better use forward slashes there!</p>
<pre><code>ProxyCommand C:/somepath/sh.exe -c "aws ssm ...
</code></pre>
<p>I don't use the windows openSSH anymore, instead I'm using the ssh command from git-... | <p>This seems to be a problem of the Windows openSSH package. In ProxyCommands it requests full path qualifiers, but better use forward slashes there!</p> <pre><code>ProxyCommand C:/somepath/sh.exe -c "aws ssm ... </code></pre> <p>I don't use the windows openSSH anymore, instead I'm using the ssh command from git-... | 64, 386, 2631, 3149, 33388 | amazon-web-services, cmd, scp, ssh, windows | <h1>SSH and SCP failed with "CreateProcessW failed error:2 posix_spawn: No such file or directory"</h1>
<p>I am trying to do SSH and SCP to AWS managed instance. The public key of my machine is stored at that managed instance. There is no .pem file required. I am using the following commands.</p>
<pre><code> scp -r ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,151 | cmd | # SSH and SCP failed with "CreateProcessW failed error:2 posix_spawn: No such file or directory"
I am trying to do SSH and SCP to AWS managed instance. The public key of my machine is stored at that managed instance. There is no .pem file required. I am using the following commands.
```
scp -r username@instance-i... | This seems to be a problem of the Windows openSSH package.
In ProxyCommands it requests full path qualifiers, but better use forward slashes there!
```
ProxyCommand C:/somepath/sh.exe -c "aws ssm ...
```
I don't use the windows openSSH anymore, instead I'm using the ssh command from git-bash to avoid all the windows ... |
38935882 | sleep function in a batch script | 10 | 2016-08-13 18:44:53 | <p>I am creating a batch file to run a program on my desktop <code>xyz.exe</code> for 4 hours, then close it for 1 hour and repeat the process. Here is my script.</p>
<pre><code>:a
START C:\Users\Mukul\Desktop\xyz.exe
SLEEP 14400
taskkill /F /IM xyz.exe
SLEEP 3600
goto :a
</code></pre>
<p>According to <a href="http:/... | 83,401 | 6,365,587 | 2024-05-14 12:27:14 | 42,602,995 | 16 | 2017-03-05 00:26:02 | 7,589,775 | 2024-05-14 12:27:14 | https://stackoverflow.com/q/38935882 | https://stackoverflow.com/a/42602995 | <p>You can use batch's <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/timeout" rel="nofollow noreferrer"><code>timeout</code></a> command.</p>
<p>For example:</p>
<pre><code>@echo off
echo Hi
timeout /t 1 /nobreak > nul
</code></pre>
<ul>
<li><p><code>/t</code> is not manda... | <p>You can use batch's <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/timeout" rel="nofollow noreferrer"><code>timeout</code></a> command.</p> <p>For example:</p> <pre><code>@echo off echo Hi timeout /t 1 /nobreak > nul </code></pre> <ul> <li><p><code>/t</code> is not manda... | 2221, 7002, 21289 | batch-file, sleep, wait | <h1>sleep function in a batch script</h1>
<p>I am creating a batch file to run a program on my desktop <code>xyz.exe</code> for 4 hours, then close it for 1 hour and repeat the process. Here is my script.</p>
<pre><code>:a
START C:\Users\Mukul\Desktop\xyz.exe
SLEEP 14400
taskkill /F /IM xyz.exe
SLEEP 3600
goto :a
</co... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,152 | cmd | # sleep function in a batch script
I am creating a batch file to run a program on my desktop `xyz.exe` for 4 hours, then close it for 1 hour and repeat the process. Here is my script.
```
:a
START C:\Users\Mukul\Desktop\xyz.exe
SLEEP 14400
taskkill /F /IM xyz.exe
SLEEP 3600
goto :a
```
According to [here](http://www... | You can use batch's [`timeout`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/timeout) command.
For example:
```
@echo off
echo Hi
timeout /t 1 /nobreak > nul
```
- `/t` is not mandatory
- 1 is the amount of second(s) to wait
- `/nobreak` ensures the user can't skip the wait
- `> n... |
41517201 | Making a node.js service using NSSM | 10 | 2017-01-07 02:29:31 | <p>I want to create a nodejs service, so that the node server starts as my computer starts, and i do not have to keep the command prompt open all the time. I m tryng to achieve this by using NSSM.</p>
<p>Here is the command to create the service:</p>
<pre><code>nssm.exe install jewel-server C:\Program Files\nodejs\no... | 22,397 | 5,699,775 | 2017-09-11 00:23:13 | 41,517,643 | 16 | 2017-01-07 03:59:33 | 5,699,775 | 2017-01-07 03:59:33 | https://stackoverflow.com/q/41517201 | https://stackoverflow.com/a/41517643 | <p>The way parameters were passed was not correct, So used the NSSM GUI to set the parametes:</p>
<pre><code>Open GUI: nssm.exe install jewel-server
</code></pre>
<p>Once the GUI is open give in the following values.</p>
<pre><code>Path: C:\Program Files\nodejs\node.exe
Arguments: D:\jewel\server.js
Press Install se... | <p>The way parameters were passed was not correct, So used the NSSM GUI to set the parametes:</p> <pre><code>Open GUI: nssm.exe install jewel-server </code></pre> <p>Once the GUI is open give in the following values.</p> <pre><code>Path: C:\Program Files\nodejs\node.exe Arguments: D:\jewel\server.js Press Install se... | 2631, 4963, 46426, 107577 | cmd, node.js, nssm, window | <h1>Making a node.js service using NSSM</h1>
<p>I want to create a nodejs service, so that the node server starts as my computer starts, and i do not have to keep the command prompt open all the time. I m tryng to achieve this by using NSSM.</p>
<p>Here is the command to create the service:</p>
<pre><code>nssm.exe in... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,153 | cmd | # Making a node.js service using NSSM
I want to create a nodejs service, so that the node server starts as my computer starts, and i do not have to keep the command prompt open all the time. I m tryng to achieve this by using NSSM.
Here is the command to create the service:
```
nssm.exe install jewel-server C:\Progr... | The way parameters were passed was not correct, So used the NSSM GUI to set the parametes:
```
Open GUI: nssm.exe install jewel-server
```
Once the GUI is open give in the following values.
```
Path: C:\Program Files\nodejs\node.exe
Arguments: D:\jewel\server.js
Press Install service
```
Done!
You can start the ser... |
14612824 | cmd: if exist A and B then | 10 | 2013-01-30 20:14:17 | <p>What is the simplest and/or most readable method to <code>IF</code> with <code>AND</code> in a CMD shell? In pseudo code:</p>
<pre><code>IF EXIST file1 AND file2:
then do stuff
ELSE:
do something else
</code></pre>
<p><em>this Q has to be somewhere on SO but my search-fu isn't working for this one. sorry</e... | 67,967 | 14,420 | 2016-02-29 22:13:04 | 14,613,247 | 16 | 2013-01-30 20:36:43 | 974,063 | 2013-01-30 20:36:43 | https://stackoverflow.com/q/14612824 | https://stackoverflow.com/a/14613247 | <p>Assuming you are talking about DOS/Windows batch files, I think you want something like this:</p>
<pre><code>SET do_stuff=false
IF EXIST file1 IF EXIST file2 SET do_stuff=true
IF "%do_stuff%"=="true" (
REM do stuff
) ELSE (
REM do something else
)
</code></pre>
<p>The source of the ugliness is that DOS bat... | <p>Assuming you are talking about DOS/Windows batch files, I think you want something like this:</p> <pre><code>SET do_stuff=false IF EXIST file1 IF EXIST file2 SET do_stuff=true IF "%do_stuff%"=="true" ( REM do stuff ) ELSE ( REM do something else ) </code></pre> <p>The source of the ugliness is that DOS bat... | 2631, 2773, 7002 | batch-file, cmd, if-statement | <h1>cmd: if exist A and B then</h1>
<p>What is the simplest and/or most readable method to <code>IF</code> with <code>AND</code> in a CMD shell? In pseudo code:</p>
<pre><code>IF EXIST file1 AND file2:
then do stuff
ELSE:
do something else
</code></pre>
<p><em>this Q has to be somewhere on SO but my search-fu ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,154 | cmd | # cmd: if exist A and B then
What is the simplest and/or most readable method to `IF` with `AND` in a CMD shell? In pseudo code:
```
IF EXIST file1 AND file2:
then do stuff
ELSE:
do something else
```
*this Q has to be somewhere on SO but my search-fu isn't working for this one. sorry* | Assuming you are talking about DOS/Windows batch files, I think you want something like this:
```
SET do_stuff=false
IF EXIST file1 IF EXIST file2 SET do_stuff=true
IF "%do_stuff%"=="true" (
REM do stuff
) ELSE (
REM do something else
)
```
The source of the ugliness is that DOS batch file `if` statements do ... |
49050611 | Start multiple tasks in parallel and wait for them in windows? | 9 | 2018-03-01 13:21:00 | <p>How do I execute some tasks in parallel in batch script and wait for them?</p>
<pre><code>command1;
# command3, command4 and command5 should execute in sequence say task1
# command6, command7 and command8 should execute in sequence say task2
# both task1 and task2 should run independently
command3; command4; comm... | 18,016 | 452,102 | 2020-04-07 23:07:16 | 49,051,876 | 16 | 2018-03-01 14:30:07 | 778,560 | 2018-03-01 14:30:07 | https://stackoverflow.com/q/49050611 | https://stackoverflow.com/a/49051876 | <p>I think <a href="https://stackoverflow.com/a/43762349/778560">this is</a> the simplest way to do that:</p>
<pre><code>command1
(
start "task1" cmd /C "command3 & command4 & command5"
start "task2" cmd /C "command6 & command7 & command8"
) | pause
command9
</code></pre>
<p>Further details in... | <p>I think <a href="https://stackoverflow.com/a/43762349/778560">this is</a> the simplest way to do that:</p> <pre><code>command1 ( start "task1" cmd /C "command3 & command4 & command5" start "task2" cmd /C "command6 & command7 & command8" ) | pause command9 </code></pre> <p>Further details in... | 64, 353, 2631, 7002 | batch-file, cmd, parallel-processing, windows | <h1>Start multiple tasks in parallel and wait for them in windows?</h1>
<p>How do I execute some tasks in parallel in batch script and wait for them?</p>
<pre><code>command1;
# command3, command4 and command5 should execute in sequence say task1
# command6, command7 and command8 should execute in sequence say task2
#... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,155 | cmd | # Start multiple tasks in parallel and wait for them in windows?
How do I execute some tasks in parallel in batch script and wait for them?
```
command1;
# command3, command4 and command5 should execute in sequence say task1
# command6, command7 and command8 should execute in sequence say task2
# both task1 and task... | I think [this is](https://stackoverflow.com/a/43762349/778560) the simplest way to do that:
```
command1
(
start "task1" cmd /C "command3 & command4 & command5"
start "task2" cmd /C "command6 & command7 & command8"
) | pause
command9
```
Further details in *the comments* below [this answer](https://stackoverf... |
47426129 | Difference between %~1 and %1 in batch? | 9 | 2017-11-22 03:01:17 | <p>In batch i sometimes see <code>%~1</code> used for switches and also <code>%1</code>. What's the difference? They both seem to work for me.</p>
<p>Example:</p>
<pre><code>if "%~1"=="" echo No variable specified.
</code></pre>
<p>and</p>
<pre><code>if "%1"=="" echo No variable specified.
</code></pre>
<p>seem to... | 15,333 | 7,498,582 | 2017-11-22 03:45:14 | 47,426,429 | 16 | 2017-11-22 03:45:14 | 8,968,593 | 2017-11-22 03:45:14 | https://stackoverflow.com/q/47426129 | https://stackoverflow.com/a/47426429 | <p>The explanation is in both <code>For /?</code> and <code>call /?</code> <em>expands %1 removing any surrounding quotes (")</em>.</p>
<pre><code> %~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter ... | <p>The explanation is in both <code>For /?</code> and <code>call /?</code> <em>expands %1 removing any surrounding quotes (")</em>.</p> <pre><code> %~1 - expands %1 removing any surrounding quotes (") %~f1 - expands %1 to a fully qualified path name %~d1 - expands %1 to a drive letter ... | 276, 7002 | batch-file, variables | <h1>Difference between %~1 and %1 in batch?</h1>
<p>In batch i sometimes see <code>%~1</code> used for switches and also <code>%1</code>. What's the difference? They both seem to work for me.</p>
<p>Example:</p>
<pre><code>if "%~1"=="" echo No variable specified.
</code></pre>
<p>and</p>
<pre><code>if "%1"=="" echo... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,156 | cmd | # Difference between %~1 and %1 in batch?
In batch i sometimes see `%~1` used for switches and also `%1`. What's the difference? They both seem to work for me.
Example:
```
if "%~1"=="" echo No variable specified.
```
and
```
if "%1"=="" echo No variable specified.
```
seem to work interchangibly. | The explanation is in both `For /?` and `call /?` *expands %1 removing any surrounding quotes (")*.
```
%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path... |
43349134 | How can I add greater than and less than into a batch file variable | 9 | 2017-04-11 14:41:00 | <p>When I try</p>
<pre><code>@echo off
set PTag=^<BR^>
echo %PTag%
</code></pre>
<p>I get nothing.</p>
<p>Now what's interesting is that if there's an empty line after the last echo, I get:</p>
<pre><code>The syntax of the command is incorrect.
</code></pre>
<p>If I remove the @echo off, then it actually out... | 10,008 | 230,430 | 2021-01-11 11:07:26 | 43,349,607 | 16 | 2017-04-11 15:01:10 | 995,714 | 2021-01-11 11:07:26 | https://stackoverflow.com/q/43349134 | https://stackoverflow.com/a/43349607 | <p><code>set PTag=^<BR^></code> sets the value <code><BR></code> to <code>PTag</code></p>
<p>When you run <code>echo %PTag%</code> it expands to <code>echo <BR></code> which is an invalid redirection. You need to escape the <code><</code> and <code>></code> inside <code>PTag</code> by using this... | <p><code>set PTag=^<BR^></code> sets the value <code><BR></code> to <code>PTag</code></p> <p>When you run <code>echo %PTag%</code> it expands to <code>echo <BR></code> which is an invalid redirection. You need to escape the <code><</code> and <code>></code> inside <code>PTag</code> by using this... | 7002 | batch-file | <h1>How can I add greater than and less than into a batch file variable</h1>
<p>When I try</p>
<pre><code>@echo off
set PTag=^<BR^>
echo %PTag%
</code></pre>
<p>I get nothing.</p>
<p>Now what's interesting is that if there's an empty line after the last echo, I get:</p>
<pre><code>The syntax of the command is... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,157 | cmd | # How can I add greater than and less than into a batch file variable
When I try
```
@echo off
set PTag=^<BR^>
echo %PTag%
```
I get nothing.
Now what's interesting is that if there's an empty line after the last echo, I get:
```
The syntax of the command is incorrect.
```
If I remove the @echo off, then it actua... | `set PTag=^<BR^>` sets the value `<BR>` to `PTag`
When you run `echo %PTag%` it expands to `echo <BR>` which is an invalid redirection. You need to escape the `<` and `>` inside `PTag` by using this
```
set PTag=^^^<BR^^^>
```
The first `^` escapes itself, then the next one escapes `<` or `>`
You can also use this
... |
35060669 | Xcopy with excluding folders (sub-directories) | 9 | 2016-01-28 11:47:16 | <p>I want to copy files and folders in a directory to another folder excluding sub-folders with files contains it, as for example I have a large number of files for <code>node_modules</code> directory which like 100Mb with 50K+ files, that I don't need to copy.</p>
<p>I tried using xcopy like this : </p>
<pre><code>... | 18,212 | 765,965 | 2019-03-18 11:00:22 | 35,060,670 | 16 | 2016-01-28 11:47:16 | 765,965 | 2019-03-18 10:58:59 | https://stackoverflow.com/q/35060669 | https://stackoverflow.com/a/35060670 | <p>Well, after searching I found a similar question in StackOverflow but was not so helpful for my case: </p>
<ul>
<li><a href="https://stackoverflow.com/questions/12356646/xcopy-command-excluding-files-and-folders">Xcopy Command excluding files and folders</a> ( its marked as duplicated but actually it's not really d... | <p>Well, after searching I found a similar question in StackOverflow but was not so helpful for my case: </p> <ul> <li><a href="https://stackoverflow.com/questions/12356646/xcopy-command-excluding-files-and-folders">Xcopy Command excluding files and folders</a> ( its marked as duplicated but actually it's not really d... | 2631, 4710, 9938 | cmd, command-prompt, xcopy | <h1>Xcopy with excluding folders (sub-directories)</h1>
<p>I want to copy files and folders in a directory to another folder excluding sub-folders with files contains it, as for example I have a large number of files for <code>node_modules</code> directory which like 100Mb with 50K+ files, that I don't need to copy.</p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,158 | cmd | # Xcopy with excluding folders (sub-directories)
I want to copy files and folders in a directory to another folder excluding sub-folders with files contains it, as for example I have a large number of files for `node_modules` directory which like 100Mb with 50K+ files, that I don't need to copy.
I tried using xcopy l... | Well, after searching I found a similar question in StackOverflow but was not so helpful for my case:
- [Xcopy Command excluding files and folders](https://stackoverflow.com/questions/12356646/xcopy-command-excluding-files-and-folders) ( its marked as duplicated but actually it's not really duplicated, it is the diffe... |
21437787 | schtasks /create (Have a task that runs every day and repeats every hour | 9 | 2014-01-29 17:06:17 | <p>Sorry if this or similar has been asked, and I hope I'm missing something stupid and this is easy, but. How do I make a task using the <code>schtasks /create</code> command that will start say every day at 7 and repeat every hour either indefinitely or for the duration of a day?</p>
<p>If I do</p>
<pre><code>scht... | 35,247 | 487,645 | 2014-02-05 11:35:54 | 21,464,952 | 16 | 2014-01-30 18:44:33 | 487,645 | 2014-01-30 18:44:33 | https://stackoverflow.com/q/21437787 | https://stackoverflow.com/a/21464952 | <p>Figured it out, Repeat Interval is essentially what I needed along with duration</p>
<p>Below is how to schedule something to run at 7:00 every day every 1 hour for a duration of 1 day.</p>
<pre><code>schtasks /create /tn "test" /tr "\"test.exe"" /sc DAILY /st 07:00 /f /RI 60 /du 24:00
</code></pre>
| <p>Figured it out, Repeat Interval is essentially what I needed along with duration</p> <p>Below is how to schedule something to run at 7:00 every day every 1 hour for a duration of 1 day.</p> <pre><code>schtasks /create /tn "test" /tr "\"test.exe"" /sc DAILY /st 07:00 /f /RI 60 /du 24:00 </code></pre> | 7002, 9299, 25235 | batch-file, scheduled-tasks, windows-task-scheduler | <h1>schtasks /create (Have a task that runs every day and repeats every hour</h1>
<p>Sorry if this or similar has been asked, and I hope I'm missing something stupid and this is easy, but. How do I make a task using the <code>schtasks /create</code> command that will start say every day at 7 and repeat every hour eith... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,159 | cmd | # schtasks /create (Have a task that runs every day and repeats every hour
Sorry if this or similar has been asked, and I hope I'm missing something stupid and this is easy, but. How do I make a task using the `schtasks /create` command that will start say every day at 7 and repeat every hour either indefinitely or fo... | Figured it out, Repeat Interval is essentially what I needed along with duration
Below is how to schedule something to run at 7:00 every day every 1 hour for a duration of 1 day.
```
schtasks /create /tn "test" /tr "\"test.exe"" /sc DAILY /st 07:00 /f /RI 60 /du 24:00
``` |
18140240 | Autohotkey script to open command prompt | 9 | 2013-08-09 04:56:22 | <p>I've collected a script from the <code>AutoHotKey</code> forum which lets me open a command prompt at the location I'm open in windows explorer. If the current window is not a explorer window then the prompt opens at the location where the script is present. I would like to change this behavior and make it open from... | 20,273 | 238,631 | 2019-04-17 20:16:56 | 18,141,035 | 16 | 2013-08-09 06:16:32 | 2,335,020 | 2013-08-13 12:54:17 | https://stackoverflow.com/q/18140240 | https://stackoverflow.com/a/18141035 | <p>The command to run cmd.exe in the c:\ path is</p>
<p>run, cmd.exe, c:\</p>
<p>A full script that would run the cmd window every time would look like this</p>
<pre><code>SetTitleMatchMode, 2
ifwinactive, ahk_class CabinetWClass
ControlGetText, address , edit1, ahk_class CabinetWClass
else
address =
; Exclude ... | <p>The command to run cmd.exe in the c:\ path is</p> <p>run, cmd.exe, c:\</p> <p>A full script that would run the cmd window every time would look like this</p> <pre><code>SetTitleMatchMode, 2 ifwinactive, ahk_class CabinetWClass ControlGetText, address , edit1, ahk_class CabinetWClass else address = ; Exclude ... | 2631, 2838, 9938 | autohotkey, cmd, command-prompt | <h1>Autohotkey script to open command prompt</h1>
<p>I've collected a script from the <code>AutoHotKey</code> forum which lets me open a command prompt at the location I'm open in windows explorer. If the current window is not a explorer window then the prompt opens at the location where the script is present. I would ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,160 | cmd | # Autohotkey script to open command prompt
I've collected a script from the `AutoHotKey` forum which lets me open a command prompt at the location I'm open in windows explorer. If the current window is not a explorer window then the prompt opens at the location where the script is present. I would like to change this ... | The command to run cmd.exe in the c:\ path is
run, cmd.exe, c:\
A full script that would run the cmd window every time would look like this
```
SetTitleMatchMode, 2
ifwinactive, ahk_class CabinetWClass
ControlGetText, address , edit1, ahk_class CabinetWClass
else
address =
; Exclude specific windows
ifwinactiv... |
10474488 | Why does signtool in command-prompt return "Windows cannot find 'signtool'. Make sure you typed the name correctly..." | 9 | 2012-05-06 21:30:50 | <p>I do have that file. (In "...\Program Files\Microsoft SDKs..."). And I went to installed-programs (in Control Panel) and "reinstalled" it.</p>
<p>So why doesn't the command prompt recognize it?</p>
| 22,378 | 939,213 | 2012-05-06 21:50:51 | 10,474,610 | 16 | 2012-05-06 21:50:51 | 62,576 | 2012-05-06 21:50:51 | https://stackoverflow.com/q/10474488 | https://stackoverflow.com/a/10474610 | <p>Because the folder isn't in the system <code>PATH</code>. (From the command prompt, type <code>PATH</code> and hit enter to see what the current PATH contains.)</p>
<p>You can add the folder by adding the folder to the existing <code>PATH</code> from the command prompt (of course, replace the folder with the proper... | <p>Because the folder isn't in the system <code>PATH</code>. (From the command prompt, type <code>PATH</code> and hit enter to see what the current PATH contains.)</p> <p>You can add the folder by adding the folder to the existing <code>PATH</code> from the command prompt (of course, replace the folder with the proper... | 759, 2631, 29787, 50005 | assembly-signing, cmd, sdk, signtool | <h1>Why does signtool in command-prompt return "Windows cannot find 'signtool'. Make sure you typed the name correctly..."</h1>
<p>I do have that file. (In "...\Program Files\Microsoft SDKs..."). And I went to installed-programs (in Control Panel) and "reinstalled" it.</p>
<p>So why doesn't the command prompt recogniz... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,162 | cmd | # Why does signtool in command-prompt return "Windows cannot find 'signtool'. Make sure you typed the name correctly..."
I do have that file. (In "...\Program Files\Microsoft SDKs..."). And I went to installed-programs (in Control Panel) and "reinstalled" it.
So why doesn't the command prompt recognize it? | Because the folder isn't in the system `PATH`. (From the command prompt, type `PATH` and hit enter to see what the current PATH contains.)
You can add the folder by adding the folder to the existing `PATH` from the command prompt (of course, replace the folder with the proper location for the SDK version and location ... |
7503944 | Can we run a batch file (.bat) from the shared path | 9 | 2011-09-21 17:23:29 | <p>I have a <strong>shared path (like //servername/c$/batches/)</strong> where all my batch files are located now I am writing an <strong>web application in C# to run .bat files</strong> from that application. I know way to do it when I have a physical path.
But here I dont have a physical path. Is it possible to do it... | 23,701 | 336,767 | 2011-09-21 18:12:48 | 7,504,011 | 16 | 2011-09-21 17:28:15 | 118,068 | 2011-09-21 17:37:33 | https://stackoverflow.com/q/7503944 | https://stackoverflow.com/a/7504011 | <p>Batch files don't support UNC paths as their "current directory". There's a hackish work around of doing:</p>
<pre><code>pushd "%~dp0"
your batch stuff
popd
</code></pre>
<p>%~dp0 expands to the current (d)rive/(p)ath/(0)batchfilename</p>
<hr>
<p>example:</p>
<p>ok. a Simple batch file:</p>
<pre><code>pushd %... | <p>Batch files don't support UNC paths as their "current directory". There's a hackish work around of doing:</p> <pre><code>pushd "%~dp0" your batch stuff popd </code></pre> <p>%~dp0 expands to the current (d)rive/(p)ath/(0)batchfilename</p> <hr> <p>example:</p> <p>ok. a Simple batch file:</p> <pre><code>pushd %... | 1, 9, 64, 96, 7002 | .net, asp.net, batch-file, c#, windows | <h1>Can we run a batch file (.bat) from the shared path</h1>
<p>I have a <strong>shared path (like //servername/c$/batches/)</strong> where all my batch files are located now I am writing an <strong>web application in C# to run .bat files</strong> from that application. I know way to do it when I have a physical path.
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,163 | cmd | # Can we run a batch file (.bat) from the shared path
I have a **shared path (like //servername/c$/batches/)** where all my batch files are located now I am writing an **web application in C# to run .bat files** from that application. I know way to do it when I have a physical path.
But here I dont have a physical pat... | Batch files don't support UNC paths as their "current directory". There's a hackish work around of doing:
```
pushd "%~dp0"
your batch stuff
popd
```
%~dp0 expands to the current (d)rive/(p)ath/(0)batchfilename
---
example:
ok. a Simple batch file:
```
pushd %~dp0
echo "Hello from batch land"
echo %~dp0
popd
```
... |
7273433 | Using an OR in an IF statement WinXP Batch Script | 9 | 2011-09-01 16:34:53 | <p>Is there a way to pass an OR through an IF statement?</p>
<p>Such as:</p>
<pre><code>SET var=two
IF "%var%"=="one" OR "two" OR "three" ECHO The number is between zero and four.
</code></pre>
| 23,746 | 781,339 | 2019-03-21 12:25:22 | 7,273,470 | 16 | 2011-09-01 16:37:44 | 73,070 | 2011-09-01 16:40:52 | https://stackoverflow.com/q/7273433 | https://stackoverflow.com/a/7273470 | <p>No.</p>
<pre><code>if "%var%"=="one" goto foo
if "%var%"=="two" goto foo
if "%var%"=="three" goto foo
goto afterfoo
:foo
echo The number is between one and three (technically incorrect, since it includes the end points and thus is not between).
:afterfoo
</code></pre>
<p>If you need a more structured approach:</p>... | <p>No.</p> <pre><code>if "%var%"=="one" goto foo if "%var%"=="two" goto foo if "%var%"=="three" goto foo goto afterfoo :foo echo The number is between one and three (technically incorrect, since it includes the end points and thus is not between). :afterfoo </code></pre> <p>If you need a more structured approach:</p>... | 64, 2631, 2773, 7002, 39271 | batch-file, cmd, conditional-statements, if-statement, windows | <h1>Using an OR in an IF statement WinXP Batch Script</h1>
<p>Is there a way to pass an OR through an IF statement?</p>
<p>Such as:</p>
<pre><code>SET var=two
IF "%var%"=="one" OR "two" OR "three" ECHO The number is between zero and four.
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,164 | cmd | # Using an OR in an IF statement WinXP Batch Script
Is there a way to pass an OR through an IF statement?
Such as:
```
SET var=two
IF "%var%"=="one" OR "two" OR "three" ECHO The number is between zero and four.
``` | No.
```
if "%var%"=="one" goto foo
if "%var%"=="two" goto foo
if "%var%"=="three" goto foo
goto afterfoo
:foo
echo The number is between one and three (technically incorrect, since it includes the end points and thus is not between).
:afterfoo
```
If you need a more structured approach:
```
if "%var%"=="one" set One... |
6500314 | Do MS-DOS built-in commands return an error\exit code? | 9 | 2011-06-28 00:08:16 | <p>I have not found a way to get the error code, if returned, of rmdir. It seems like the MS-DOS internal commands do not return an error code. Can someone confirm that? </p>
<p>How does a script that uses these commands know if the commands succeed or fail in order to decide the next step? The easiest way is to read ... | 12,118 | 274,933 | 2016-02-05 01:18:11 | 6,500,400 | 16 | 2011-06-28 00:24:00 | 14,860 | 2016-02-05 01:18:11 | https://stackoverflow.com/q/6500314 | https://stackoverflow.com/a/6500400 | <p>No, it appears not to. If you <code>echo %errorlevel%</code> after either a successful or failed <code>rmdir</code>, you get <code>0</code> in both cases:</p>
<pre><code>c:\pax> mkdir qqq
c:\pax> rmdir qqq
c:\pax> echo %errorlevel%
0
c:\pax> rmdir qqq
The system cannot find the file specified.
c:\pax>... | <p>No, it appears not to. If you <code>echo %errorlevel%</code> after either a successful or failed <code>rmdir</code>, you get <code>0</code> in both cases:</p> <pre><code>c:\pax> mkdir qqq c:\pax> rmdir qqq c:\pax> echo %errorlevel% 0 c:\pax> rmdir qqq The system cannot find the file specified. c:\pax>... | 5370, 7002, 25844 | batch-file, dos, windows-scripting | <h1>Do MS-DOS built-in commands return an error\exit code?</h1>
<p>I have not found a way to get the error code, if returned, of rmdir. It seems like the MS-DOS internal commands do not return an error code. Can someone confirm that? </p>
<p>How does a script that uses these commands know if the commands succeed or fa... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,165 | cmd | # Do MS-DOS built-in commands return an error\exit code?
I have not found a way to get the error code, if returned, of rmdir. It seems like the MS-DOS internal commands do not return an error code. Can someone confirm that?
How does a script that uses these commands know if the commands succeed or fail in order to de... | No, it appears not to. If you `echo %errorlevel%` after either a successful or failed `rmdir`, you get `0` in both cases:
```
c:\pax> mkdir qqq
c:\pax> rmdir qqq
c:\pax> echo %errorlevel%
0
c:\pax> rmdir qqq
The system cannot find the file specified.
c:\pax> echo %errorlevel%
0
```
For that *particular* use case, you... |
5691223 | windows batch file: calling executable in another directory | 9 | 2011-04-17 03:25:08 | <p>This seems like something simple, but I don't seem to be able to get it.
I have a directory called "test" with an executable hello.exe that basically prints "hello" onto the screen.</p>
<p>I want to execute this program from the current directory using relative paths.
So I write</p>
<pre>
test\hello.exe
</pre>
<p... | 17,415 | 536,607 | 2011-04-17 03:42:33 | 5,691,304 | 16 | 2011-04-17 03:42:33 | 322,697 | 2011-04-17 03:42:33 | https://stackoverflow.com/q/5691223 | https://stackoverflow.com/a/5691304 | <p>Try the following in the batch file:</p>
<pre><code>%~dp0test\hello.exe
</code></pre>
<p>The "%~dp0" is a variable that gets replaced with the full path of the batch file, so that it should work even if you don't set the current directory of the batch file.</p>
| <p>Try the following in the batch file:</p> <pre><code>%~dp0test\hello.exe </code></pre> <p>The "%~dp0" is a variable that gets replaced with the full path of the batch file, so that it should work even if you don't set the current directory of the batch file.</p> | 7002, 28223 | batch-file, windows-vista | <h1>windows batch file: calling executable in another directory</h1>
<p>This seems like something simple, but I don't seem to be able to get it.
I have a directory called "test" with an executable hello.exe that basically prints "hello" onto the screen.</p>
<p>I want to execute this program from the current directory ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,166 | cmd | # windows batch file: calling executable in another directory
This seems like something simple, but I don't seem to be able to get it.
I have a directory called "test" with an executable hello.exe that basically prints "hello" onto the screen.
I want to execute this program from the current directory using relative p... | Try the following in the batch file:
```
%~dp0test\hello.exe
```
The "%~dp0" is a variable that gets replaced with the full path of the batch file, so that it should work even if you don't set the current directory of the batch file. |
4805799 | How to get a batch file to handle spaces in file names? | 9 | 2011-01-26 14:42:08 | <p>I am using the following batch file to make a zip file for each xml in a folder:</p>
<pre><code>FOR %%f in ("C:\files\*.xml") DO 7za.exe a C:\files\zips\%%~nf.zip (%%f)
</code></pre>
<p>However if the file name has a space in it (<code>test plop.xml</code>) then the batch file does not work. It seems to split the ... | 58,679 | 380,437 | 2014-05-05 07:54:17 | 4,805,841 | 16 | 2011-01-26 14:46:20 | 586,140 | 2011-01-26 14:46:20 | https://stackoverflow.com/q/4805799 | https://stackoverflow.com/a/4805841 | <p>Try placing quotes around the output file name.</p>
<p>Change</p>
<pre><code>FOR %%f in ("C:\files*.xml") DO 7za.exe a C:\files\zips\%%~nf.zip (%%f)
</code></pre>
<p>to:</p>
<pre><code>FOR %%f in ("C:\files*.xml") DO 7za.exe a "C:\files\zips\%%~nf.zip" (%%f)
</code></pre>
<p>May also be the variable %%f, may ne... | <p>Try placing quotes around the output file name.</p> <p>Change</p> <pre><code>FOR %%f in ("C:\files*.xml") DO 7za.exe a C:\files\zips\%%~nf.zip (%%f) </code></pre> <p>to:</p> <pre><code>FOR %%f in ("C:\files*.xml") DO 7za.exe a "C:\files\zips\%%~nf.zip" (%%f) </code></pre> <p>May also be the variable %%f, may ne... | 1062, 7002 | batch-file, filenames | <h1>How to get a batch file to handle spaces in file names?</h1>
<p>I am using the following batch file to make a zip file for each xml in a folder:</p>
<pre><code>FOR %%f in ("C:\files\*.xml") DO 7za.exe a C:\files\zips\%%~nf.zip (%%f)
</code></pre>
<p>However if the file name has a space in it (<code>test plop.xml<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,167 | cmd | # How to get a batch file to handle spaces in file names?
I am using the following batch file to make a zip file for each xml in a folder:
```
FOR %%f in ("C:\files\*.xml") DO 7za.exe a C:\files\zips\%%~nf.zip (%%f)
```
However if the file name has a space in it (`test plop.xml`) then the batch file does not work. I... | Try placing quotes around the output file name.
Change
```
FOR %%f in ("C:\files*.xml") DO 7za.exe a C:\files\zips\%%~nf.zip (%%f)
```
to:
```
FOR %%f in ("C:\files*.xml") DO 7za.exe a "C:\files\zips\%%~nf.zip" (%%f)
```
May also be the variable %%f, may need to place quotes around this as well. |
3258975 | How do I run a script using a BAT file? | 9 | 2010-07-15 19:00:46 | <p>I would like to have a BAT file open a sql server script. Currently I have this code in the sql file:</p>
<pre><code>declare @path varchar(255), @mydb varchar(50)
SELECT @mydb = 'timeclockplus'
select @path = 'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backup\'
+ @mydb + '-' + convert(varchar(... | 18,188 | 117,700 | 2017-04-06 20:48:34 | 3,258,991 | 16 | 2010-07-15 19:02:28 | 13,627 | 2010-07-15 19:07:38 | https://stackoverflow.com/q/3258975 | https://stackoverflow.com/a/3258991 | <p>You should invoke the <a href="http://msdn.microsoft.com/en-us/library/ms162773.aspx" rel="noreferrer">sqlcmd</a> command-line tool from your batch file. Assuming your sql file is "backup.sql", the command line would be something like:</p>
<pre><code>sqlcmd -E -S yoursqlinstance -i backup.sql
</code></pre>
<p><cod... | <p>You should invoke the <a href="http://msdn.microsoft.com/en-us/library/ms162773.aspx" rel="noreferrer">sqlcmd</a> command-line tool from your batch file. Assuming your sql file is "backup.sql", the command line would be something like:</p> <pre><code>sqlcmd -E -S yoursqlinstance -i backup.sql </code></pre> <p><cod... | 22, 64, 72, 7002, 7445 | batch-file, sql, sqlcmd, sql-server, windows | <h1>How do I run a script using a BAT file?</h1>
<p>I would like to have a BAT file open a sql server script. Currently I have this code in the sql file:</p>
<pre><code>declare @path varchar(255), @mydb varchar(50)
SELECT @mydb = 'timeclockplus'
select @path = 'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,168 | cmd | # How do I run a script using a BAT file?
I would like to have a BAT file open a sql server script. Currently I have this code in the sql file:
```
declare @path varchar(255), @mydb varchar(50)
SELECT @mydb = 'timeclockplus'
select @path = 'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backup\'
+ @... | You should invoke the [sqlcmd](http://msdn.microsoft.com/en-us/library/ms162773.aspx) command-line tool from your batch file. Assuming your sql file is "backup.sql", the command line would be something like:
```
sqlcmd -E -S yoursqlinstance -i backup.sql
```
`-E` uses trusted connection, replace with `-U` and `-P` if... |
538130 | Maven package .bat script: how to add a delay? | 9 | 2009-02-11 18:27:56 | <p>I have this .bat script which I use to maven package my application. Problem is, just after it ends execution, it closes the console window. The last 2 lines somehow are completely ignored.</p>
<p>Does anyone know the trick to make this work?
I just want to have a quick check if the build was successful.</p>
<pre>... | 4,963 | 64,784 | 2009-07-30 20:52:37 | 538,150 | 16 | 2009-02-11 18:32:43 | 34,065 | 2009-02-11 18:32:43 | https://stackoverflow.com/q/538130 | https://stackoverflow.com/a/538150 | <p>You could try to write</p>
<pre><code>call mvn package -o -P local
</code></pre>
| <p>You could try to write</p> <pre><code>call mvn package -o -P local </code></pre> | 531, 1912, 7002 | batch-file, maven-2, scripting | <h1>Maven package .bat script: how to add a delay?</h1>
<p>I have this .bat script which I use to maven package my application. Problem is, just after it ends execution, it closes the console window. The last 2 lines somehow are completely ignored.</p>
<p>Does anyone know the trick to make this work?
I just want to ha... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,169 | cmd | # Maven package .bat script: how to add a delay?
I have this .bat script which I use to maven package my application. Problem is, just after it ends execution, it closes the console window. The last 2 lines somehow are completely ignored.
Does anyone know the trick to make this work?
I just want to have a quick check... | You could try to write
```
call mvn package -o -P local
``` |
53779177 | How to get error message from exec command | 8 | 2018-12-14 11:47:27 | <p>I am using Go to create a CLI. I am executing a command and if there is an error thrown from the OS I want to print it.</p>
<pre><code>cmd := exec.Command("abc", "run", pathToFile)
err := cmd.Start()
if err != nil {
fmt.Printf("Error : %v \n", err)
os.Exit(1)
}
err = cmd.Wait()
if err != nil {
fmt.Print... | 7,372 | 10,391,130 | 2018-12-14 12:54:57 | 53,780,225 | 16 | 2018-12-14 12:54:57 | 4,010,835 | 2018-12-14 12:54:57 | https://stackoverflow.com/q/53779177 | https://stackoverflow.com/a/53780225 | <p><code>StderrPipe</code> returns a pipe that will be connected to the command's standard error when the command starts.</p>
<pre><code>cmd := exec.Command("abc", "run", pathToFile)
stderr, _ := cmd.StderrPipe()
if err := cmd.Start(); err != nil {
log.Fatal(err)
}
scanner := bufio.NewScanner(stderr)
for scanner.... | <p><code>StderrPipe</code> returns a pipe that will be connected to the command's standard error when the command starts.</p> <pre><code>cmd := exec.Command("abc", "run", pathToFile) stderr, _ := cmd.StderrPipe() if err := cmd.Start(); err != nil { log.Fatal(err) } scanner := bufio.NewScanner(stderr) for scanner.... | 1987, 2631, 7932, 15627 | cmd, exec, go, operating-system | <h1>How to get error message from exec command</h1>
<p>I am using Go to create a CLI. I am executing a command and if there is an error thrown from the OS I want to print it.</p>
<pre><code>cmd := exec.Command("abc", "run", pathToFile)
err := cmd.Start()
if err != nil {
fmt.Printf("Error : %v \n", err)
os.Exit... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,170 | cmd | # How to get error message from exec command
I am using Go to create a CLI. I am executing a command and if there is an error thrown from the OS I want to print it.
```
cmd := exec.Command("abc", "run", pathToFile)
err := cmd.Start()
if err != nil {
fmt.Printf("Error : %v \n", err)
os.Exit(1)
}
err = cmd.Wait... | `StderrPipe` returns a pipe that will be connected to the command's standard error when the command starts.
```
cmd := exec.Command("abc", "run", pathToFile)
stderr, _ := cmd.StderrPipe()
if err := cmd.Start(); err != nil {
log.Fatal(err)
}
scanner := bufio.NewScanner(stderr)
for scanner.Scan() {
fmt.Println(... |
43852961 | (error) ERR unknown command 'redis-cli' | 8 | 2017-05-08 16:41:46 | <p>We have installed the <a href="https://github.com/rgl/redis/downloads" rel="noreferrer">redis client</a>.</p>
<p>When we type the following command inside <code>C:\Program Files\Redis\redis-cli.exe</code>:</p>
<pre><code>redis-cli -h redis-server.example.com -p 6390 ping
</code></pre>
<p>It throws the following e... | 35,353 | 2,404,470 | 2022-12-26 11:35:31 | 43,854,425 | 16 | 2017-05-08 18:02:38 | 1,242,684 | 2021-01-11 17:16:05 | https://stackoverflow.com/q/43852961 | https://stackoverflow.com/a/43854425 | <p>Your PATH should be set to directory, not to the file</p>
<pre><code>"C:\Program Files\Redis\"
</code></pre>
| <p>Your PATH should be set to directory, not to the file</p> <pre><code>"C:\Program Files\Redis\" </code></pre> | 281, 2631, 43464, 46426, 109138 | cmd, connection, node.js, redis, redis-cli | <h1>(error) ERR unknown command 'redis-cli'</h1>
<p>We have installed the <a href="https://github.com/rgl/redis/downloads" rel="noreferrer">redis client</a>.</p>
<p>When we type the following command inside <code>C:\Program Files\Redis\redis-cli.exe</code>:</p>
<pre><code>redis-cli -h redis-server.example.com -p 6390... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,171 | cmd | # (error) ERR unknown command 'redis-cli'
We have installed the [redis client](https://github.com/rgl/redis/downloads).
When we type the following command inside `C:\Program Files\Redis\redis-cli.exe`:
```
redis-cli -h redis-server.example.com -p 6390 ping
```
It throws the following error:
> (error) ERR unknown c... | Your PATH should be set to directory, not to the file
```
"C:\Program Files\Redis\"
``` |
27130050 | batch script if user press Ctrl+C do a command before exiting | 8 | 2014-11-25 15:02:45 | <p>I wrote a script which is doing <code>net use</code> at the beginning and <code>net use /DELETE</code> at the end.</p>
<p>But if user decides to press <kbd>Ctrl</kbd> + <kbd>C</kbd> and exits the script, I need to do a <code>net use /DELETE</code>.</p>
<p>Is that possible? I can't find anything on google.</p>
| 17,058 | 2,522,966 | 2017-10-28 19:23:57 | 27,131,024 | 16 | 2014-11-25 15:46:31 | 1,012,053 | 2014-11-26 07:30:52 | https://stackoverflow.com/q/27130050 | https://stackoverflow.com/a/27131024 | <p>Sure, simply execute most of your script in a new CMD session:</p>
<pre><code>@echo off
if "%~1" neq "_start_" (
net use ...
cmd /c "%~f0" _start_ %*
net use /delete ...
exit /b
)
shift /1
REM rest of script goes here
</code></pre>
<p>As long as your console window remains open, the <code>net use /delete</... | <p>Sure, simply execute most of your script in a new CMD session:</p> <pre><code>@echo off if "%~1" neq "_start_" ( net use ... cmd /c "%~f0" _start_ %* net use /delete ... exit /b ) shift /1 REM rest of script goes here </code></pre> <p>As long as your console window remains open, the <code>net use /delete</... | 2631, 7002, 10871 | batch-file, cmd, exit | <h1>batch script if user press Ctrl+C do a command before exiting</h1>
<p>I wrote a script which is doing <code>net use</code> at the beginning and <code>net use /DELETE</code> at the end.</p>
<p>But if user decides to press <kbd>Ctrl</kbd> + <kbd>C</kbd> and exits the script, I need to do a <code>net use /DELETE</cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,173 | cmd | # batch script if user press Ctrl+C do a command before exiting
I wrote a script which is doing `net use` at the beginning and `net use /DELETE` at the end.
But if user decides to press `Ctrl` + `C` and exits the script, I need to do a `net use /DELETE`.
Is that possible? I can't find anything on google. | Sure, simply execute most of your script in a new CMD session:
```
@echo off
if "%~1" neq "_start_" (
net use ...
cmd /c "%~f0" _start_ %*
net use /delete ...
exit /b
)
shift /1
REM rest of script goes here
```
As long as your console window remains open, the `net use /delete` command will always fire after t... |
17624921 | How to stop a process automatically via a batch script | 8 | 2013-07-12 22:22:35 | <p>How can I check if a process is running from a batch/cmd file? And If process is running, how do I stop the process automatically?</p>
<p>Like a cmd script thingy, can someone give me some hints or help me make that kind of script.</p>
<p>Example (pseudo code):</p>
<pre><code>If calc.exe is running ... | 72,516 | 2,578,034 | 2015-11-04 17:20:24 | 17,626,920 | 16 | 2013-07-13 04:16:31 | 1,012,053 | 2013-07-13 04:16:31 | https://stackoverflow.com/q/17624921 | https://stackoverflow.com/a/17626920 | <p>First off, you have the wrong command to stop a process like calc.exe. NET STOP will stop a service, but not a normal program process. You want TASKKILL instead.</p>
<p>Second - If you know you want to kill the process if it exists, then why do you think you have to check if it is running first before you kill it? ... | <p>First off, you have the wrong command to stop a process like calc.exe. NET STOP will stop a service, but not a normal program process. You want TASKKILL instead.</p> <p>Second - If you know you want to kill the process if it exists, then why do you think you have to check if it is running first before you kill it? ... | 2631, 5910 | cmd, process | <h1>How to stop a process automatically via a batch script</h1>
<p>How can I check if a process is running from a batch/cmd file? And If process is running, how do I stop the process automatically?</p>
<p>Like a cmd script thingy, can someone give me some hints or help me make that kind of script.</p>
<p>Example (pse... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,174 | cmd | # How to stop a process automatically via a batch script
How can I check if a process is running from a batch/cmd file? And If process is running, how do I stop the process automatically?
Like a cmd script thingy, can someone give me some hints or help me make that kind of script.
Example (pseudo code):
```
If calc... | First off, you have the wrong command to stop a process like calc.exe. NET STOP will stop a service, but not a normal program process. You want TASKKILL instead.
Second - If you know you want to kill the process if it exists, then why do you think you have to check if it is running first before you kill it? You can si... |
12637683 | Run multiple bat files which has "pause" in it | 8 | 2012-09-28 09:52:34 | <p>I have the following 2 bat files:</p>
<pre><code>1.bat
------
//a line which does something
pause
2.bat
------
//a line which does the other something
pause
</code></pre>
<p>Now, how do I run these bat files within a new bat file, by ignoring the pause(s)?</p>
| 5,168 | 762,730 | 2012-09-28 09:57:44 | 12,637,757 | 16 | 2012-09-28 09:57:29 | 463,115 | 2012-09-28 09:57:29 | https://stackoverflow.com/q/12637683 | https://stackoverflow.com/a/12637757 | <p>Simple: Remove the <code>PAUSE</code>! </p>
<p>But I assume, one of your restrictions of the problem could be, that you can't remove the <code>pause</code>.</p>
<p>Then you could use redirection to the called batch file.</p>
<p>Something like </p>
<pre><code>call 1.bat < nul
call 2.bat < nul
</code></pre>... | <p>Simple: Remove the <code>PAUSE</code>! </p> <p>But I assume, one of your restrictions of the problem could be, that you can't remove the <code>pause</code>.</p> <p>Then you could use redirection to the called batch file.</p> <p>Something like </p> <pre><code>call 1.bat < nul call 2.bat < nul </code></pre>... | 64, 7002 | batch-file, windows | <h1>Run multiple bat files which has "pause" in it</h1>
<p>I have the following 2 bat files:</p>
<pre><code>1.bat
------
//a line which does something
pause
2.bat
------
//a line which does the other something
pause
</code></pre>
<p>Now, how do I run these bat files within a new bat file, by ignoring the pause(s)?</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,175 | cmd | # Run multiple bat files which has "pause" in it
I have the following 2 bat files:
```
1.bat
------
//a line which does something
pause
2.bat
------
//a line which does the other something
pause
```
Now, how do I run these bat files within a new bat file, by ignoring the pause(s)? | Simple: Remove the `PAUSE`!
But I assume, one of your restrictions of the problem could be, that you can't remove the `pause`.
Then you could use redirection to the called batch file.
Something like
```
call 1.bat < nul
call 2.bat < nul
``` |
12118810 | Arithmetic inside a for loop batch file | 8 | 2012-08-25 03:04:19 | <p>I have a for loop in a batch file that looks like this: </p>
<pre><code>for %%y in (100 200 300 400 500) do (
set /a x = y/25
echo %x%
)
</code></pre>
<p>The line:</p>
<pre><code>set /a x = y/25
</code></pre>
<p>Doesn't seem to be doing any division. What is the correct syntax for dividing each y by... | 18,443 | 1,205,019 | 2020-09-04 15:49:27 | 12,118,914 | 16 | 2012-08-25 03:24:42 | 1,012,053 | 2012-08-25 03:24:42 | https://stackoverflow.com/q/12118810 | https://stackoverflow.com/a/12118914 | <p>Environment variables need not be expanded to use in a SET /A statement. But FOR variables must be expanded.</p>
<p>Also, even if your computation worked, the ECHO would fail because percent expansion takes place when a statement is parsed, and the entire FOR construct is parsed at once. So the value of %x% would b... | <p>Environment variables need not be expanded to use in a SET /A statement. But FOR variables must be expanded.</p> <p>Also, even if your computation worked, the ECHO would fail because percent expansion takes place when a statement is parsed, and the entire FOR construct is parsed at once. So the value of %x% would b... | 2631, 7002 | batch-file, cmd | <h1>Arithmetic inside a for loop batch file</h1>
<p>I have a for loop in a batch file that looks like this: </p>
<pre><code>for %%y in (100 200 300 400 500) do (
set /a x = y/25
echo %x%
)
</code></pre>
<p>The line:</p>
<pre><code>set /a x = y/25
</code></pre>
<p>Doesn't seem to be doing any division. ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,176 | cmd | # Arithmetic inside a for loop batch file
I have a for loop in a batch file that looks like this:
```
for %%y in (100 200 300 400 500) do (
set /a x = y/25
echo %x%
)
```
The line:
```
set /a x = y/25
```
Doesn't seem to be doing any division. What is the correct syntax for dividing each y by 25? I on... | Environment variables need not be expanded to use in a SET /A statement. But FOR variables must be expanded.
Also, even if your computation worked, the ECHO would fail because percent expansion takes place when a statement is parsed, and the entire FOR construct is parsed at once. So the value of %x% would be the valu... |
4607390 | Is it possible to redirect the output of a batch file inside the script? | 8 | 2011-01-05 17:50:38 | <p>I would like to set the standard output of a batch script to go to a file. I would like to do this inside the script if possible.</p>
<p><strong>Note:</strong> I do <em>not</em> want to do this: <code>foo.bat > StdOut.txt</code></p>
<p>I would like to do something inside the script to redirect the output to a ... | 12,948 | 95,573 | 2014-07-29 15:22:09 | 4,607,580 | 16 | 2011-01-05 18:10:04 | 23,478 | 2012-05-31 20:59:48 | https://stackoverflow.com/q/4607390 | https://stackoverflow.com/a/4607580 | <p>One way of doing it is the following. Use the <code>call</code> command to execute a label in the script. <strong>Edit</strong> I realized the first version I posted does not seem to work in a cmd.exe prompt (I was using TCC). The following seems to work in both command processors:</p>
<pre><code>@echo off
call ... | <p>One way of doing it is the following. Use the <code>call</code> command to execute a label in the script. <strong>Edit</strong> I realized the first version I posted does not seem to work in a cmd.exe prompt (I was using TCC). The following seems to work in both command processors:</p> <pre><code>@echo off call ... | 64, 531, 7002 | batch-file, scripting, windows | <h1>Is it possible to redirect the output of a batch file inside the script?</h1>
<p>I would like to set the standard output of a batch script to go to a file. I would like to do this inside the script if possible.</p>
<p><strong>Note:</strong> I do <em>not</em> want to do this: <code>foo.bat > StdOut.txt</code></... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,177 | cmd | # Is it possible to redirect the output of a batch file inside the script?
I would like to set the standard output of a batch script to go to a file. I would like to do this inside the script if possible.
**Note:** I do *not* want to do this: `foo.bat > StdOut.txt`
I would like to do something inside the script to r... | One way of doing it is the following. Use the `call` command to execute a label in the script. **Edit** I realized the first version I posted does not seem to work in a cmd.exe prompt (I was using TCC). The following seems to work in both command processors:
```
@echo off
call :testitout > t.tmp
goto:eof
:testitout
e... |
3023543 | Execute batch file after another batch file completes | 8 | 2010-06-11 14:21:22 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/5490549/how-to-call-one-batch-file-after-another">How to call one batch file after another</a> </p>
</blockquote>
<p>I have a batch file coordinating the activity of two other batch file. How can I make it exec... | 23,556 | 1,360 | 2012-04-12 17:47:57 | 3,023,562 | 16 | 2010-06-11 14:23:38 | 52,444 | 2010-06-11 14:23:38 | https://stackoverflow.com/q/3023543 | https://stackoverflow.com/a/3023562 | <p>Use <a href="http://www.robvanderwoude.com/call.php" rel="noreferrer">call</a> to continue the execution of the first file, like:</p>
<pre><code>echo batch controller
call batch1.bat
call batch2.bat
echo batch controller running again
</code></pre>
| <p>Use <a href="http://www.robvanderwoude.com/call.php" rel="noreferrer">call</a> to continue the execution of the first file, like:</p> <pre><code>echo batch controller call batch1.bat call batch2.bat echo batch controller running again </code></pre> | 2631, 7002 | batch-file, cmd | <h1>Execute batch file after another batch file completes</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/5490549/how-to-call-one-batch-file-after-another">How to call one batch file after another</a> </p>
</blockquote>
<p>I have a batch file coordinati... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,178 | cmd | # Execute batch file after another batch file completes
> **Possible Duplicate:**
> [How to call one batch file after another](https://stackoverflow.com/questions/5490549/how-to-call-one-batch-file-after-another)
I have a batch file coordinating the activity of two other batch file. How can I make it execute the se... | Use [call](http://www.robvanderwoude.com/call.php) to continue the execution of the first file, like:
```
echo batch controller
call batch1.bat
call batch2.bat
echo batch controller running again
``` |
65640943 | How to simply list all files of a folder using dir to text with UTF-8 encoding? | 7 | 2021-01-09 09:06:39 | <p>Simple question:</p>
<p>On Windows 10, I found a quick and dirty solution to save the names of all the files in a folder by just simply:</p>
<ul>
<li>Creating a text file</li>
<li>Type and save <code>dir > 1.txt</code> within it</li>
<li>Rename the .txt file to .bat</li>
<li>Run it. Done.</li>
</ul>
<p>But, the t... | 16,676 | 4,308,096 | 2021-12-15 08:49:30 | 65,641,304 | 16 | 2021-01-09 09:55:36 | 3,080,770 | 2021-01-09 09:55:36 | https://stackoverflow.com/q/65640943 | https://stackoverflow.com/a/65641304 | <p>You should add this command <code>chcp 65001</code> before <code>dir</code> command to change code page to UTF-8</p>
<pre><code>@echo off
CHCP 65001>nul
dir>1.txt
</code></pre>
<p>Further reading about <a href="https://ss64.com/nt/chcp.html" rel="noreferrer">CHCP</a> command</p>
| <p>You should add this command <code>chcp 65001</code> before <code>dir</code> command to change code page to UTF-8</p> <pre><code>@echo off CHCP 65001>nul dir>1.txt </code></pre> <p>Further reading about <a href="https://ss64.com/nt/chcp.html" rel="noreferrer">CHCP</a> command</p> | 1469, 6486, 7002, 8944, 107329 | ansi, batch-file, text, utf-8, windows-10 | <h1>How to simply list all files of a folder using dir to text with UTF-8 encoding?</h1>
<p>Simple question:</p>
<p>On Windows 10, I found a quick and dirty solution to save the names of all the files in a folder by just simply:</p>
<ul>
<li>Creating a text file</li>
<li>Type and save <code>dir > 1.txt</code> within... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,179 | cmd | # How to simply list all files of a folder using dir to text with UTF-8 encoding?
Simple question:
On Windows 10, I found a quick and dirty solution to save the names of all the files in a folder by just simply:
- Creating a text file
- Type and save `dir > 1.txt` within it
- Rename the .txt file to .bat
- Run it. D... | You should add this command `chcp 65001` before `dir` command to change code page to UTF-8
```
@echo off
CHCP 65001>nul
dir>1.txt
```
Further reading about [CHCP](https://ss64.com/nt/chcp.html) command |
39284947 | SpringBoot JNDI datasource throws java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory | 7 | 2016-09-02 05:33:11 | <p>Similar questions have been asked before and I went through all of those but not able to solve problem. Related Questions - <a href="https://stackoverflow.com/questions/14712308/ubuntu-tomcat7-java-lang-classnotfoundexception-org-apache-tomcat-dbcp-dbcp-bas/15880777#15880777">Q1</a>,<a href="https://stackoverflow.co... | 15,491 | 3,850,730 | 2021-08-20 16:46:19 | 39,285,554 | 16 | 2016-09-02 06:21:05 | 3,850,730 | 2016-09-06 11:24:32 | https://stackoverflow.com/q/39284947 | https://stackoverflow.com/a/39285554 | <p>I solved the problem by setting <code>factory</code> attribute in my <code>Resource</code> Definition. <code>resource.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");</code></p>
<pre><code>@Bean
public TomcatEmbeddedServletContainerFactory embeddedServletContainerFactory(){
return new To... | <p>I solved the problem by setting <code>factory</code> attribute in my <code>Resource</code> Definition. <code>resource.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");</code></p> <pre><code>@Bean public TomcatEmbeddedServletContainerFactory embeddedServletContainerFactory(){ return new To... | 1603, 41895, 69848, 95875 | spring-batch, spring-boot, spring-data, tomcat | <h1>SpringBoot JNDI datasource throws java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory</h1>
<p>Similar questions have been asked before and I went through all of those but not able to solve problem. Related Questions - <a href="https://stackoverflow.com/questions/14712308/ubuntu-tom... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,180 | cmd | # SpringBoot JNDI datasource throws java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory
Similar questions have been asked before and I went through all of those but not able to solve problem. Related Questions - [Q1](https://stackoverflow.com/questions/14712308/ubuntu-tomcat7-java-lan... | I solved the problem by setting `factory` attribute in my `Resource` Definition. `resource.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");`
```
@Bean
public TomcatEmbeddedServletContainerFactory embeddedServletContainerFactory(){
return new TomcatEmbeddedServletContainerFactory() {
... |
27675842 | How to add a folder to 7z archive using 7za? | 7 | 2014-12-28 11:08:40 | <p>I am having a bad time with the standalone version of 7-Zip. I want to compress a folder with a password. I tried: <code>7za a my_folder -pmy_password</code>. It's compressing all the files in which <strong>7za.exe</strong> is located with file name of <strong>my_folder</strong>.</p>
<p>BTW: I am using a scripting ... | 22,607 | 3,815,591 | 2019-11-18 17:23:40 | 27,676,314 | 16 | 2014-12-28 12:20:46 | 3,074,564 | 2019-02-12 16:46:19 | https://stackoverflow.com/q/27675842 | https://stackoverflow.com/a/27676314 | <p>As per <strong>Command Line Syntax</strong> (<strong>7zip.chm</strong>) > <strong>Contents</strong> > <strong>Command Line Version</strong> > <strong>Syntax</strong> :</p>
<pre><code>7za <command> [<switch>...] <base_archive_name> [<arguments>...]
<arguments> ::= <switch> | <... | <p>As per <strong>Command Line Syntax</strong> (<strong>7zip.chm</strong>) > <strong>Contents</strong> > <strong>Command Line Version</strong> > <strong>Syntax</strong> :</p> <pre><code>7za <command> [<switch>...] <base_archive_name> [<arguments>...] <arguments> ::= <switch> | <... | 5680, 7002, 7240 | 7zip, autoit, batch-file | <h1>How to add a folder to 7z archive using 7za?</h1>
<p>I am having a bad time with the standalone version of 7-Zip. I want to compress a folder with a password. I tried: <code>7za a my_folder -pmy_password</code>. It's compressing all the files in which <strong>7za.exe</strong> is located with file name of <strong>my... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,181 | cmd | # How to add a folder to 7z archive using 7za?
I am having a bad time with the standalone version of 7-Zip. I want to compress a folder with a password. I tried: `7za a my_folder -pmy_password`. It's compressing all the files in which **7za.exe** is located with file name of **my_folder**.
BTW: I am using a scripting... | As per **Command Line Syntax** (**7zip.chm**) > **Contents** > **Command Line Version** > **Syntax** :
```
7za <command> [<switch>...] <base_archive_name> [<arguments>...]
<arguments> ::= <switch> | <wildcard> | <filename> | <list_file>
<switch>::= <switch_symbol><switch_characters>[<option>]
<switch_symbol> ::= '/' ... |
18083366 | Getting second line of text set as a variable using FOR in batch | 7 | 2013-08-06 14:44:50 | <p>I have a text file on my desktop named "1234.txt" and it contains four lines of text that looks like:</p>
<pre><code>Test
Test1
Test2
Test3
</code></pre>
<p>I want to echo the second line (aka Test1) using the FOR command. I am using this:</p>
<pre><code>@echo off
for /f "skip=1" %%G IN (1234.txt) DO @echo %%G
pa... | 29,719 | 2,654,489 | 2022-06-15 08:33:38 | 18,083,455 | 16 | 2013-08-06 14:48:22 | 2,098,699 | 2013-08-06 14:48:22 | https://stackoverflow.com/q/18083366 | https://stackoverflow.com/a/18083455 | <p>try this:</p>
<pre><code>@echo off
for /f "skip=1" %%G IN (1234.txt) DO if not defined line set "line=%%G"
echo %line%
pause
</code></pre>
<p>other example:</p>
<pre><code>for /f "tokens=1*delims=:" %%G in ('findstr /n "^" 1234.txt') do if %%G equ 2 echo %%H
</code></pre>
| <p>try this:</p> <pre><code>@echo off for /f "skip=1" %%G IN (1234.txt) DO if not defined line set "line=%%G" echo %line% pause </code></pre> <p>other example:</p> <pre><code>for /f "tokens=1*delims=:" %%G in ('findstr /n "^" 1234.txt') do if %%G equ 2 echo %%H </code></pre> | 1469, 2531, 7002 | batch-file, for-loop, text | <h1>Getting second line of text set as a variable using FOR in batch</h1>
<p>I have a text file on my desktop named "1234.txt" and it contains four lines of text that looks like:</p>
<pre><code>Test
Test1
Test2
Test3
</code></pre>
<p>I want to echo the second line (aka Test1) using the FOR command. I am using this:</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,182 | cmd | # Getting second line of text set as a variable using FOR in batch
I have a text file on my desktop named "1234.txt" and it contains four lines of text that looks like:
```
Test
Test1
Test2
Test3
```
I want to echo the second line (aka Test1) using the FOR command. I am using this:
```
@echo off
for /f "skip=1" %%G... | try this:
```
@echo off
for /f "skip=1" %%G IN (1234.txt) DO if not defined line set "line=%%G"
echo %line%
pause
```
other example:
```
for /f "tokens=1*delims=:" %%G in ('findstr /n "^" 1234.txt') do if %%G equ 2 echo %%H
``` |
17379448 | Could not Autowired JobLauncherTestUtils in Spring-Batch | 7 | 2013-06-29 10:54:44 | <p>I am getting below error while performing a functional test for a step in spring-batch .
Getting below error:</p>
<pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.batch.test.JobLauncherTestUtils] found for dependency: expected at le... | 11,502 | 2,422,070 | 2013-06-30 11:07:26 | 17,389,731 | 16 | 2013-06-30 11:07:26 | 2,422,070 | 2013-06-30 11:07:26 | https://stackoverflow.com/q/17379448 | https://stackoverflow.com/a/17389731 | <p>After some googling found out that a bean definition needs to be specified in the context.xml used for JUnit testing.</p>
<pre><code><bean id="jobLauncherTestUtils" class="org.springframework.batch.test.JobLauncherTestUtils" >
<property name="job" ref="custom.entities"/>
<property name="jobRe... | <p>After some googling found out that a bean definition needs to be specified in the context.xml used for JUnit testing.</p> <pre><code><bean id="jobLauncherTestUtils" class="org.springframework.batch.test.JobLauncherTestUtils" > <property name="job" ref="custom.entities"/> <property name="jobRe... | 41895 | spring-batch | <h1>Could not Autowired JobLauncherTestUtils in Spring-Batch</h1>
<p>I am getting below error while performing a functional test for a step in spring-batch .
Getting below error:</p>
<pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.bat... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,183 | cmd | # Could not Autowired JobLauncherTestUtils in Spring-Batch
I am getting below error while performing a functional test for a step in spring-batch .
Getting below error:
```
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.batch.test.JobLauncherT... | After some googling found out that a bean definition needs to be specified in the context.xml used for JUnit testing.
```
<bean id="jobLauncherTestUtils" class="org.springframework.batch.test.JobLauncherTestUtils" >
<property name="job" ref="custom.entities"/>
<property name="jobRepository" ref="jobRepository"... |
11153532 | How to iterate string in cmd for loop? | 7 | 2012-06-22 09:25:34 | <p>I am trying to iterate a string in batch script:</p>
<pre><code>set var="1 2 3"
for /F %%i in (%var%) do (
echo %%i
)
</code></pre>
<p>and getting this output:</p>
<pre><code>C:\>batch.bat
C:\>set var="1 2 3"
C:\>for /F %i in ("1 2 3") do (echo %i )
C:\>(echo 1 )
1
</code></pre>
<p>I expect ... | 21,265 | 72,178 | 2012-06-22 10:58:12 | 11,154,068 | 16 | 2012-06-22 10:00:21 | 463,115 | 2012-06-22 10:58:12 | https://stackoverflow.com/q/11153532 | https://stackoverflow.com/a/11154068 | <p>That's because FOR/F splits a each line into multiple tokens, but you need to define how many tokens you want to process. </p>
<pre><code>set var="1 2 3"
for /F "tokens=1-3" %%i in (%var%) do (
echo %%i
echo %%j
echo %%k
)
</code></pre>
<p><strong>EDIT:</strong> Other solutions</p>
<p>Like the answer of... | <p>That's because FOR/F splits a each line into multiple tokens, but you need to define how many tokens you want to process. </p> <pre><code>set var="1 2 3" for /F "tokens=1-3" %%i in (%var%) do ( echo %%i echo %%j echo %%k ) </code></pre> <p><strong>EDIT:</strong> Other solutions</p> <p>Like the answer of... | 64, 139, 2531, 2631, 7002 | batch-file, cmd, for-loop, string, windows | <h1>How to iterate string in cmd for loop?</h1>
<p>I am trying to iterate a string in batch script:</p>
<pre><code>set var="1 2 3"
for /F %%i in (%var%) do (
echo %%i
)
</code></pre>
<p>and getting this output:</p>
<pre><code>C:\>batch.bat
C:\>set var="1 2 3"
C:\>for /F %i in ("1 2 3") do (echo %i )... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,184 | cmd | # How to iterate string in cmd for loop?
I am trying to iterate a string in batch script:
```
set var="1 2 3"
for /F %%i in (%var%) do (
echo %%i
)
```
and getting this output:
```
C:\>batch.bat
C:\>set var="1 2 3"
C:\>for /F %i in ("1 2 3") do (echo %i )
C:\>(echo 1 )
1
```
I expect that all 3 numbers wi... | That's because FOR/F splits a each line into multiple tokens, but you need to define how many tokens you want to process.
```
set var="1 2 3"
for /F "tokens=1-3" %%i in (%var%) do (
echo %%i
echo %%j
echo %%k
)
```
**EDIT:** Other solutions
Like the answer of Ed harper:
You could also use a normal FOR-loo... |
33541375 | Windows Script to move files older than 30 days with a specific extension to another folder | 6 | 2015-11-05 09:53:50 | <p>I am in need of a script preferably a vbscript for a Windows Server which will archive files in a folder to another folder. Say from <code>\\folder1\</code> to <code>\\folder1\archive\</code></p>
<p>The files have the extensions of <code>.doc</code> and <code>.xls</code></p>
<p>But also I only want to move files o... | 37,633 | 5,525,431 | 2023-02-18 10:09:16 | 33,556,265 | 16 | 2015-11-05 22:47:48 | 5,047,996 | 2019-07-22 14:18:27 | https://stackoverflow.com/q/33541375 | https://stackoverflow.com/a/33556265 | <p>Since you tagged your question with <a href="/questions/tagged/batch-file" class="post-tag" title="show questions tagged 'batch-file'" rel="tag">batch-file</a>, I suppose you are accepting batch file solutions too.<br>
Here you are:</p>
<pre><code>pushd \\folder1
forfiles /M *.doc /D -30 /C "cmd /C if @isdi... | <p>Since you tagged your question with <a href="/questions/tagged/batch-file" class="post-tag" title="show questions tagged 'batch-file'" rel="tag">batch-file</a>, I suppose you are accepting batch file solutions too.<br> Here you are:</p> <pre><code>pushd \\folder1 forfiles /M *.doc /D -30 /C "cmd /C if @isdi... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Windows Script to move files older than 30 days with a specific extension to another folder</h1>
<p>I am in need of a script preferably a vbscript for a Windows Server which will archive files in a folder to another folder. Say from <code>\\folder1\</code> to <code>\\folder1\archive\</code></p>
<p>The files have t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,186 | cmd | # Windows Script to move files older than 30 days with a specific extension to another folder
I am in need of a script preferably a vbscript for a Windows Server which will archive files in a folder to another folder. Say from `\\folder1\` to `\\folder1\archive\`
The files have the extensions of `.doc` and `.xls`
Bu... | Since you tagged your question with [batch-file](/questions/tagged/batch-file "show questions tagged 'batch-file'"), I suppose you are accepting batch file solutions too.
Here you are:
```
pushd \\folder1
forfiles /M *.doc /D -30 /C "cmd /C if @isdir==FALSE move @file .\archive\"
forfiles /M *.xls /D -30 /C "cmd /C ... |
26044016 | Shutdown via batch file into infinite loop? | 6 | 2014-09-25 16:53:06 | <p><strong>Problem:</strong> </p>
<p>While running the batch file, it goes into infinite loop </p>
<p><strong>Code:</strong></p>
<pre><code>shutdown -s -t 050
</code></pre>
<p><strong>Output:</strong></p>
<p><strong>Ran the batch file</strong>
<a href="https://i.sstatic.net/VnHqY.png" rel="noreferrer"><img src="ht... | 8,564 | 3,829,706 | 2017-02-09 23:57:56 | 26,044,227 | 16 | 2014-09-25 17:05:00 | 2,299,431 | 2014-09-25 17:05:00 | https://stackoverflow.com/q/26044016 | https://stackoverflow.com/a/26044227 | <p>You called the batch file <code>shutdown</code></p>
<p>Use a name that is not a system command or internal command.</p>
| <p>You called the batch file <code>shutdown</code></p> <p>Use a name that is not a system command or internal command.</p> | 64, 2631, 4921, 7002 | batch-file, cmd, shutdown, windows | <h1>Shutdown via batch file into infinite loop?</h1>
<p><strong>Problem:</strong> </p>
<p>While running the batch file, it goes into infinite loop </p>
<p><strong>Code:</strong></p>
<pre><code>shutdown -s -t 050
</code></pre>
<p><strong>Output:</strong></p>
<p><strong>Ran the batch file</strong>
<a href="https://i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,187 | cmd | # Shutdown via batch file into infinite loop?
**Problem:**
While running the batch file, it goes into infinite loop
**Code:**
```
shutdown -s -t 050
```
**Output:**
**Ran the batch file**
[](https://i.sstatic.net/VnHqY.png)
**Output when i run in no... | You called the batch file `shutdown`
Use a name that is not a system command or internal command. |
18519645 | Spring Batch ItemReader list processed only once | 6 | 2013-08-29 19:39:14 | <p>I'm trying to create a Spring Batch job using a <code>ListItemReader<String></code>, <code>ItemProcessor<String, String></code> and <code>ItemWriter<String></code>.</p>
<p>The XML looks like the following,</p>
<pre><code><job id="sourceJob" xmlns="http://www.springframework.org/schema/batch"&g... | 28,838 | 272,159 | 2016-03-25 02:02:28 | 18,520,698 | 16 | 2013-08-29 20:49:18 | 2,587,166 | 2013-11-08 00:32:27 | https://stackoverflow.com/q/18519645 | https://stackoverflow.com/a/18520698 | <p>The problem is that you marked your reader as <code>scope="prototype"</code>. It should be <code>scope="step"</code>.</p>
<p>In Spring-batch there are only two scopes: <code>singleton</code> (the default) and <code>step</code>.</p>
<p>From the <a href="http://docs.spring.io/spring-batch/apidocs/org/springframework... | <p>The problem is that you marked your reader as <code>scope="prototype"</code>. It should be <code>scope="step"</code>.</p> <p>In Spring-batch there are only two scopes: <code>singleton</code> (the default) and <code>step</code>.</p> <p>From the <a href="http://docs.spring.io/spring-batch/apidocs/org/springframework... | 17, 1211, 41895 | java, spring, spring-batch | <h1>Spring Batch ItemReader list processed only once</h1>
<p>I'm trying to create a Spring Batch job using a <code>ListItemReader<String></code>, <code>ItemProcessor<String, String></code> and <code>ItemWriter<String></code>.</p>
<p>The XML looks like the following,</p>
<pre><code><job id="source... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,188 | cmd | # Spring Batch ItemReader list processed only once
I'm trying to create a Spring Batch job using a `ListItemReader<String>`, `ItemProcessor<String, String>` and `ItemWriter<String>`.
The XML looks like the following,
```
<job id="sourceJob" xmlns="http://www.springframework.org/schema/batch">
<step id="step1" ne... | The problem is that you marked your reader as `scope="prototype"`. It should be `scope="step"`.
In Spring-batch there are only two scopes: `singleton` (the default) and `step`.
From the [javadoc](http://docs.spring.io/spring-batch/apidocs/org/springframework/batch/core/scope/StepScope.html):
> **StepScope**:
> Sc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.