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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
25066360 | Equivalent to 'cut' on Windows | 8 | 2014-07-31 18:28:40 | <p>I have a file which has entries as below.</p>
<pre><code>/a/b/c/d/e/f
/a/b/c/g/k/l/f/j/h
/a/b/c/i/m/n/p
</code></pre>
<p>I need a command in Windows which would remove the <code>'/a/b/c'</code> part from the file.</p>
<p>The output file should look like</p>
<pre><code>d/e/f
g/k/l/f/j/h
i/m/n/p
</code></pre>
<p>... | 68,980 | 3,437,212 | 2018-11-05 21:20:34 | 25,067,069 | 13 | 2014-07-31 19:10:47 | 2,861,476 | 2018-11-05 21:20:34 | https://stackoverflow.com/q/25066360 | https://stackoverflow.com/a/25067069 | <pre><code>@echo off
(for /f "tokens=3,* delims=/" %%a in (input.txt) do echo %%b) > output.txt
</code></pre>
<p>And the "trick" is to ask for the third token and the rest of the line.</p>
<p>To use it directly from the command line:</p>
<pre><code>(for /f "tokens=3,* delims=/" %a in (input.txt) do @echo %b) >... | <pre><code>@echo off (for /f "tokens=3,* delims=/" %%a in (input.txt) do echo %%b) > output.txt </code></pre> <p>And the "trick" is to ask for the third token and the rest of the line.</p> <p>To use it directly from the command line:</p> <pre><code>(for /f "tokens=3,* delims=/" %a in (input.txt) do @echo %b) >... | 64, 7002 | batch-file, windows | <h1>Equivalent to 'cut' on Windows</h1>
<p>I have a file which has entries as below.</p>
<pre><code>/a/b/c/d/e/f
/a/b/c/g/k/l/f/j/h
/a/b/c/i/m/n/p
</code></pre>
<p>I need a command in Windows which would remove the <code>'/a/b/c'</code> part from the file.</p>
<p>The output file should look like</p>
<pre><code>d/e/... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,418 | cmd | # Equivalent to 'cut' on Windows
I have a file which has entries as below.
```
/a/b/c/d/e/f
/a/b/c/g/k/l/f/j/h
/a/b/c/i/m/n/p
```
I need a command in Windows which would remove the `'/a/b/c'` part from the file.
The output file should look like
```
d/e/f
g/k/l/f/j/h
i/m/n/p
```
I tried using the `for` command wit... | ```
@echo off
(for /f "tokens=3,* delims=/" %%a in (input.txt) do echo %%b) > output.txt
```
And the "trick" is to ask for the third token and the rest of the line.
To use it directly from the command line:
```
(for /f "tokens=3,* delims=/" %a in (input.txt) do @echo %b) > output.txt
```
The escaped percent signs ... |
24859437 | If a variable equals a number goto | 8 | 2014-07-21 07:10:03 | <p>If a variable equals, for example <code>1</code> then <code>goto</code> to <code>start1</code> BUT if the same variable equals <code>2</code> then <code>goto</code> to <code>start2</code>.</p>
<p>This is what i have so far:</p>
<pre><code>if %method% == "1" (goto start1)
if %method% == "2" (goto start2)
:start1
e... | 42,451 | 3,859,365 | 2021-04-15 23:53:14 | 24,859,482 | 13 | 2014-07-21 07:12:53 | 2,380,830 | 2014-07-21 07:12:53 | https://stackoverflow.com/q/24859437 | https://stackoverflow.com/a/24859482 | <p>You have to be careful with whitespace. Write</p>
<p><code>if "%method%"=="1" (goto start1)</code></p>
<p><em>etc</em> instead. You may or may not need the extra quotations around <code>%method%</code>, depending on how you've set up your envrionment variable.</p>
| <p>You have to be careful with whitespace. Write</p> <p><code>if "%method%"=="1" (goto start1)</code></p> <p><em>etc</em> instead. You may or may not need the extra quotations around <code>%method%</code>, depending on how you've set up your envrionment variable.</p> | 7002 | batch-file | <h1>If a variable equals a number goto</h1>
<p>If a variable equals, for example <code>1</code> then <code>goto</code> to <code>start1</code> BUT if the same variable equals <code>2</code> then <code>goto</code> to <code>start2</code>.</p>
<p>This is what i have so far:</p>
<pre><code>if %method% == "1" (goto start1)... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,419 | cmd | # If a variable equals a number goto
If a variable equals, for example `1` then `goto` to `start1` BUT if the same variable equals `2` then `goto` to `start2`.
This is what i have so far:
```
if %method% == "1" (goto start1)
if %method% == "2" (goto start2)
:start1
echo start1
pause
exit
:start2
echo start2
pause
... | You have to be careful with whitespace. Write
`if "%method%"=="1" (goto start1)`
*etc* instead. You may or may not need the extra quotations around `%method%`, depending on how you've set up your envrionment variable. |
22615228 | Running a py file from cmd that contain matplotlib plot | 8 | 2014-03-24 16:33:44 | <p>I am trying to run a python file (<code>test.py</code>) from command line in windows that contain a matplotlib plot. The file is running but the plot is only appearing for a fraction of second.</p>
<p>Here is the content of <code>test.py</code>:</p>
<pre><code>import matplotlib.pyplot as plt
plt.plot(range(10))
</co... | 16,109 | 1,970,329 | 2022-02-23 05:52:40 | 22,615,282 | 13 | 2014-03-24 16:36:11 | 674,039 | 2014-03-24 16:36:11 | https://stackoverflow.com/q/22615228 | https://stackoverflow.com/a/22615282 | <p>Modify like this:</p>
<pre><code>import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()
</code></pre>
<p>And run like this:</p>
<pre><code>python test.py
</code></pre>
| <p>Modify like this:</p> <pre><code>import matplotlib.pyplot as plt plt.plot(range(10)) plt.show() </code></pre> <p>And run like this:</p> <pre><code>python test.py </code></pre> | 16, 997, 2631, 7979 | cmd, matplotlib, plot, python | <h1>Running a py file from cmd that contain matplotlib plot</h1>
<p>I am trying to run a python file (<code>test.py</code>) from command line in windows that contain a matplotlib plot. The file is running but the plot is only appearing for a fraction of second.</p>
<p>Here is the content of <code>test.py</code>:</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,420 | cmd | # Running a py file from cmd that contain matplotlib plot
I am trying to run a python file (`test.py`) from command line in windows that contain a matplotlib plot. The file is running but the plot is only appearing for a fraction of second.
Here is the content of `test.py`:
```
import matplotlib.pyplot as plt
plt.pl... | Modify like this:
```
import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()
```
And run like this:
```
python test.py
``` |
15798930 | Batch script if else command | 8 | 2013-04-03 21:57:28 | <p>I'm trying to make a simple batch script to wipe/zero a flash drive and reformat it. It's for others, so i'm attempting to make it relatively safe, by blocking formatting to C:, D:, etc.</p>
<p>I'm looking for an IF ELSE type command i can use, to be an error catch-all.</p>
<p>Here's (the main portion of) what i h... | 56,404 | 2,242,454 | 2016-08-26 20:14:41 | 15,799,112 | 13 | 2013-04-03 22:08:58 | 1,630,171 | 2013-04-03 22:08:58 | https://stackoverflow.com/q/15798930 | https://stackoverflow.com/a/15799112 | <p>Try this:</p>
<pre><code>echo.%answer:~,1% | findstr /r /i "[e-h]"
if %errorlevel% equ 0 (
format %answer:~,1%: /x /fs:FAT32 /v:FORENSICS /p:2
) else (
echo Please provide a valid drive letter for flash drive.
goto again
)
</code></pre>
| <p>Try this:</p> <pre><code>echo.%answer:~,1% | findstr /r /i "[e-h]" if %errorlevel% equ 0 ( format %answer:~,1%: /x /fs:FAT32 /v:FORENSICS /p:2 ) else ( echo Please provide a valid drive letter for flash drive. goto again ) </code></pre> | 64, 2631, 7002, 9938 | batch-file, cmd, command-prompt, windows | <h1>Batch script if else command</h1>
<p>I'm trying to make a simple batch script to wipe/zero a flash drive and reformat it. It's for others, so i'm attempting to make it relatively safe, by blocking formatting to C:, D:, etc.</p>
<p>I'm looking for an IF ELSE type command i can use, to be an error catch-all.</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,421 | cmd | # Batch script if else command
I'm trying to make a simple batch script to wipe/zero a flash drive and reformat it. It's for others, so i'm attempting to make it relatively safe, by blocking formatting to C:, D:, etc.
I'm looking for an IF ELSE type command i can use, to be an error catch-all.
Here's (the main porti... | Try this:
```
echo.%answer:~,1% | findstr /r /i "[e-h]"
if %errorlevel% equ 0 (
format %answer:~,1%: /x /fs:FAT32 /v:FORENSICS /p:2
) else (
echo Please provide a valid drive letter for flash drive.
goto again
)
``` |
14978548 | Windows console width in environment variable | 8 | 2013-02-20 11:19:10 | <p>How can I get the <strong>current width</strong> of the windows console in an environment variable within a batch file?</p>
| 4,864 | 350,428 | 2019-12-19 14:41:46 | 14,981,267 | 13 | 2013-02-20 13:39:38 | 218,597 | 2013-02-20 13:50:43 | https://stackoverflow.com/q/14978548 | https://stackoverflow.com/a/14981267 | <p>I like the approach using the built-in <code>mode</code> command in Windows.
Try the following batch-file:</p>
<pre><code>@echo off
for /F "usebackq tokens=2* delims=: " %%W in (`mode con ^| findstr Columns`) do set CONSOLE_WIDTH=%%W
echo Console is %CONSOLE_WIDTH% characters wide
</code></pre>
<p>Note that this w... | <p>I like the approach using the built-in <code>mode</code> command in Windows. Try the following batch-file:</p> <pre><code>@echo off for /F "usebackq tokens=2* delims=: " %%W in (`mode con ^| findstr Columns`) do set CONSOLE_WIDTH=%%W echo Console is %CONSOLE_WIDTH% characters wide </code></pre> <p>Note that this w... | 64, 488, 1231, 2631, 7002 | batch-file, cmd, command-line, console, windows | <h1>Windows console width in environment variable</h1>
<p>How can I get the <strong>current width</strong> of the windows console in an environment variable within a batch file?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,422 | cmd | # Windows console width in environment variable
How can I get the **current width** of the windows console in an environment variable within a batch file? | I like the approach using the built-in `mode` command in Windows.
Try the following batch-file:
```
@echo off
for /F "usebackq tokens=2* delims=: " %%W in (`mode con ^| findstr Columns`) do set CONSOLE_WIDTH=%%W
echo Console is %CONSOLE_WIDTH% characters wide
```
Note that this will return the size of the console buf... |
14432637 | R CMD BATCH - output in terminal | 8 | 2013-01-21 04:37:34 | <p>Just learning R and I thought it would be great to use it in batch mode in the unix terminal instead of writing in the R terminal. </p>
<p>So I decided to write test.r</p>
<pre><code> x <- 2
print(x)
</code></pre>
<p>then in terminal I did</p>
<pre><code> R CMD BATCH test.r
</code></pre>
<p>it runs... | 8,396 | 1,404,663 | 2015-05-31 06:21:17 | 14,433,478 | 13 | 2013-01-21 06:36:24 | 1,404,663 | 2013-01-21 06:36:24 | https://stackoverflow.com/q/14432637 | https://stackoverflow.com/a/14433478 | <p>Sebastian-C posted: </p>
<pre><code> Rscript test.r
</code></pre>
<p>This worked in the terminal and produced the desired output</p>
<p>Thanks Sebastian-C</p>
| <p>Sebastian-C posted: </p> <pre><code> Rscript test.r </code></pre> <p>This worked in the terminal and produced the desired output</p> <p>Thanks Sebastian-C</p> | 4452, 30645 | batch-processing, r | <h1>R CMD BATCH - output in terminal</h1>
<p>Just learning R and I thought it would be great to use it in batch mode in the unix terminal instead of writing in the R terminal. </p>
<p>So I decided to write test.r</p>
<pre><code> x <- 2
print(x)
</code></pre>
<p>then in terminal I did</p>
<pre><code> R ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,423 | cmd | # R CMD BATCH - output in terminal
Just learning R and I thought it would be great to use it in batch mode in the unix terminal instead of writing in the R terminal.
So I decided to write test.r
```
x <- 2
print(x)
```
then in terminal I did
```
R CMD BATCH test.r
```
it runs, But outputs a test.r.Rou... | Sebastian-C posted:
```
Rscript test.r
```
This worked in the terminal and produced the desired output
Thanks Sebastian-C |
14215756 | Windows command for CPU utilization % for particular service | 8 | 2013-01-08 13:13:01 | <p>Is there any way to get CPU utilization for particular service from a script on Windows? I know <code>wmic cpu get LoadPercentage</code> will give CPU utilization for the entire system, but is it possible to get it for a particular program like winword.exe?</p>
| 36,986 | 1,954,762 | 2019-05-14 19:33:10 | 14,221,688 | 13 | 2013-01-08 18:30:56 | 19,719 | 2019-05-13 16:58:43 | https://stackoverflow.com/q/14215756 | https://stackoverflow.com/a/14221688 | <p><a href="https://stackoverflow.com/questions/206805/tasklist-cpu-usage">Yes, it's possible</a>.</p>
<p>This wmic command prints the CPU usage for all processes. Then you can pipe it to <code>findstr</code> to filter for a particular process (using the flag <code>/c:<process name></code>).</p>
<pre><code>wmi... | <p><a href="https://stackoverflow.com/questions/206805/tasklist-cpu-usage">Yes, it's possible</a>.</p> <p>This wmic command prints the CPU usage for all processes. Then you can pipe it to <code>findstr</code> to filter for a particular process (using the flag <code>/c:<process name></code>).</p> <pre><code>wmi... | 7002, 30645 | batch-file, batch-processing | <h1>Windows command for CPU utilization % for particular service</h1>
<p>Is there any way to get CPU utilization for particular service from a script on Windows? I know <code>wmic cpu get LoadPercentage</code> will give CPU utilization for the entire system, but is it possible to get it for a particular program like wi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,424 | cmd | # Windows command for CPU utilization % for particular service
Is there any way to get CPU utilization for particular service from a script on Windows? I know `wmic cpu get LoadPercentage` will give CPU utilization for the entire system, but is it possible to get it for a particular program like winword.exe? | [Yes, it's possible](https://stackoverflow.com/questions/206805/tasklist-cpu-usage).
This wmic command prints the CPU usage for all processes. Then you can pipe it to `findstr` to filter for a particular process (using the flag `/c:<process name>`).
```
wmic path Win32_PerfFormattedData_PerfProc_Process get Name,Perc... |
12005318 | Post build SET command and %variable% error | 8 | 2012-08-17 11:56:31 | <p>I am a batch newbie and I might have made a mistake. But I have the following post-build event:</p>
<pre><code>IF $(ConfigurationName) == Release (
SET RELEASEPATH = "C:\Users\Synercoder\Documents\Visual Studio 2010\Releases\$(ProjectName)"
IF NOT EXIST %RELEASEPATH% (
GOTO MAKEDIR
) ELSE (
... | 16,391 | 637,425 | 2018-06-13 09:09:19 | 12,005,498 | 13 | 2012-08-17 12:08:05 | 578,411 | 2018-06-13 09:09:19 | https://stackoverflow.com/q/12005318 | https://stackoverflow.com/a/12005498 | <p>First of all, spaces do matter! I would remove the " if I were you and only add them when the var is used.</p>
<pre><code>SET RELEASEPATH=C:\Users\Synercoder\Documents\Visual Studio 2010\Releases\$(ProjectName)
IF NOT EXIST "%RELEASEPATH%" MKDIR "%RELEASEPATH%"
</code></pre>
| <p>First of all, spaces do matter! I would remove the " if I were you and only add them when the var is used.</p> <pre><code>SET RELEASEPATH=C:\Users\Synercoder\Documents\Visual Studio 2010\Releases\$(ProjectName) IF NOT EXIST "%RELEASEPATH%" MKDIR "%RELEASEPATH%" </code></pre> | 1231, 7002, 14456, 31225 | batch-file, command-line, post-build-event, visual-studio-2010 | <h1>Post build SET command and %variable% error</h1>
<p>I am a batch newbie and I might have made a mistake. But I have the following post-build event:</p>
<pre><code>IF $(ConfigurationName) == Release (
SET RELEASEPATH = "C:\Users\Synercoder\Documents\Visual Studio 2010\Releases\$(ProjectName)"
IF NOT EXIST ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,425 | cmd | # Post build SET command and %variable% error
I am a batch newbie and I might have made a mistake. But I have the following post-build event:
```
IF $(ConfigurationName) == Release (
SET RELEASEPATH = "C:\Users\Synercoder\Documents\Visual Studio 2010\Releases\$(ProjectName)"
IF NOT EXIST %RELEASEPATH% (
... | First of all, spaces do matter! I would remove the " if I were you and only add them when the var is used.
```
SET RELEASEPATH=C:\Users\Synercoder\Documents\Visual Studio 2010\Releases\$(ProjectName)
IF NOT EXIST "%RELEASEPATH%" MKDIR "%RELEASEPATH%"
``` |
11793441 | Purge MSMQ queue and reset IIS from a bat file | 8 | 2012-08-03 09:57:33 | <p>Is it possible to purge a msmq queue from a bat file?</p>
<p>Essentially I want to make a bat file or at least something quick and easy so that an untrained employee can click and fix without knowing any shell or admin tools</p>
<p>Could someone please help me in the right direction?</p>
| 13,124 | 219,443 | 2014-10-14 12:42:14 | 11,793,579 | 13 | 2012-08-03 10:06:27 | 225,555 | 2014-07-29 08:39:36 | https://stackoverflow.com/q/11793441 | https://stackoverflow.com/a/11793579 | <p>Take a look on <a href="http://msdn.microsoft.com/en-us/library/ms885786.aspx">MSMQAdm Utility</a></p>
<p>Tasks administered through the utility programs include the following:</p>
<ul>
<li>Browsing local queues</li>
<li><strong>Purging messages</strong></li>
<li>Deleting individual messages</li>
<li>Stopping and ... | <p>Take a look on <a href="http://msdn.microsoft.com/en-us/library/ms885786.aspx">MSMQAdm Utility</a></p> <p>Tasks administered through the utility programs include the following:</p> <ul> <li>Browsing local queues</li> <li><strong>Purging messages</strong></li> <li>Deleting individual messages</li> <li>Stopping and ... | 3068, 7002 | batch-file, msmq | <h1>Purge MSMQ queue and reset IIS from a bat file</h1>
<p>Is it possible to purge a msmq queue from a bat file?</p>
<p>Essentially I want to make a bat file or at least something quick and easy so that an untrained employee can click and fix without knowing any shell or admin tools</p>
<p>Could someone please help m... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,426 | cmd | # Purge MSMQ queue and reset IIS from a bat file
Is it possible to purge a msmq queue from a bat file?
Essentially I want to make a bat file or at least something quick and easy so that an untrained employee can click and fix without knowing any shell or admin tools
Could someone please help me in the right directio... | Take a look on [MSMQAdm Utility](http://msdn.microsoft.com/en-us/library/ms885786.aspx)
Tasks administered through the utility programs include the following:
- Browsing local queues
- **Purging messages**
- Deleting individual messages
- Stopping and starting MSMQ service
- Connecting and disconnecting from the netw... |
2738673 | In Windows shell scripting (cmd.exe) how do you assign the stdout of a program to an environment variable? | 8 | 2010-04-29 15:41:20 | <p>In UNIX you can assign the output of a script to an environment variable using the technique explained <a href="https://stackoverflow.com/questions/2115615/assigning-value-to-shell-variable-using-a-function-return-value-from-python">here</a> - but what is the Windows equivalent?</p>
<p>I have a python utility which... | 3,533 | 46,411 | 2011-01-24 00:44:15 | 2,738,763 | 13 | 2010-04-29 15:54:01 | 116,166 | 2010-04-29 15:54:01 | https://stackoverflow.com/q/2738673 | https://stackoverflow.com/a/2738763 | <p>Use:</p>
<pre><code>for /f "delims=" %A in ('<insert command here>') do @set <variable name>=%A
</code></pre>
<p>For example: </p>
<pre><code>for /f "delims=" %A in ('time /t') do @set my_env_var=%A
</code></pre>
<p>...will run the command "time /t" and set the env variable "my_env_var" to the resul... | <p>Use:</p> <pre><code>for /f "delims=" %A in ('<insert command here>') do @set <variable name>=%A </code></pre> <p>For example: </p> <pre><code>for /f "delims=" %A in ('time /t') do @set my_env_var=%A </code></pre> <p>...will run the command "time /t" and set the env variable "my_env_var" to the resul... | 16, 64, 2631 | cmd, python, windows | <h1>In Windows shell scripting (cmd.exe) how do you assign the stdout of a program to an environment variable?</h1>
<p>In UNIX you can assign the output of a script to an environment variable using the technique explained <a href="https://stackoverflow.com/questions/2115615/assigning-value-to-shell-variable-using-a-fun... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,427 | cmd | # In Windows shell scripting (cmd.exe) how do you assign the stdout of a program to an environment variable?
In UNIX you can assign the output of a script to an environment variable using the technique explained [here](https://stackoverflow.com/questions/2115615/assigning-value-to-shell-variable-using-a-function-retur... | Use:
```
for /f "delims=" %A in ('<insert command here>') do @set <variable name>=%A
```
For example:
```
for /f "delims=" %A in ('time /t') do @set my_env_var=%A
```
...will run the command "time /t" and set the env variable "my_env_var" to the result.
Remember to use %%A instead of %A if you're running this insi... |
879023 | Honoring exit codes from batch files invoked by msbuild | 8 | 2009-05-18 18:02:45 | <p>I have a batch file that is using the <code>exit</code> command to return an exit code.</p>
<p>This batch file may, in some cases, be invoked interactively from a commandline, or in other cases, may be run as part of an MSBuild project, using the <code>Exec</code> task.</p>
<ul>
<li>If I use <code>exit %errorlevel... | 9,857 | 5,975 | 2021-11-12 14:21:47 | 880,783 | 13 | 2009-05-19 03:02:41 | 105,999 | 2021-11-12 14:21:47 | https://stackoverflow.com/q/879023 | https://stackoverflow.com/a/880783 | <p>One way to handle this could be to have MSBuild pass a parameter to the batch file so that it knows that MSBuild is calling it instead of from a command prompt.
For example I have created the sample file test.bat shown below</p>
<pre><code>ECHO OFF
IF (%1)==() goto Start
SET fromMSBuild=1
:Start
ECHO fromMSBuild:... | <p>One way to handle this could be to have MSBuild pass a parameter to the batch file so that it knows that MSBuild is calling it instead of from a command prompt. For example I have created the sample file test.bat shown below</p> <pre><code>ECHO OFF IF (%1)==() goto Start SET fromMSBuild=1 :Start ECHO fromMSBuild:... | 265, 7002, 13243 | batch-file, msbuild, msbuild-task | <h1>Honoring exit codes from batch files invoked by msbuild</h1>
<p>I have a batch file that is using the <code>exit</code> command to return an exit code.</p>
<p>This batch file may, in some cases, be invoked interactively from a commandline, or in other cases, may be run as part of an MSBuild project, using the <cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,428 | cmd | # Honoring exit codes from batch files invoked by msbuild
I have a batch file that is using the `exit` command to return an exit code.
This batch file may, in some cases, be invoked interactively from a commandline, or in other cases, may be run as part of an MSBuild project, using the `Exec` task.
- If I use `exit ... | One way to handle this could be to have MSBuild pass a parameter to the batch file so that it knows that MSBuild is calling it instead of from a command prompt.
For example I have created the sample file test.bat shown below
```
ECHO OFF
IF (%1)==() goto Start
SET fromMSBuild=1
:Start
ECHO fromMSBuild:%fromMSBuild%... |
63547473 | Error when trying to rum npm start command | 7 | 2020-08-23 13:26:42 | <p>I am trying to create a react project i have run <code>npx create-react-app my-app</code> then <code>cd my-app</code> but when I've <code>npm start</code>
this error has been shown:</p>
<pre><code>> my-app@0.1.0 start C:\Users\USER\my-app
> react-scripts start
i 「wds」: Project is running at http://192.168.13... | 8,931 | null | 2025-08-18 05:01:06 | 63,547,712 | 13 | 2020-08-23 13:49:18 | 12,830,866 | 2020-08-23 14:03:17 | https://stackoverflow.com/q/63547473 | https://stackoverflow.com/a/63547712 | <p>I've found some possible solutions. Seems that you are using powershell, check firstly that you have it in your PATH as %SystemRoot%/system32/WindowsPowerShell/v1.0. After that open powershell as admin and write</p>
<pre><code>Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
</code></pre>
<p>It should help... | <p>I've found some possible solutions. Seems that you are using powershell, check firstly that you have it in your PATH as %SystemRoot%/system32/WindowsPowerShell/v1.0. After that open powershell as admin and write</p> <pre><code>Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force </code></pre> <p>It should help... | 2631, 61387, 78230, 92497, 120783 | cmd, node-modules, npm, npm-start, reactjs | <h1>Error when trying to rum npm start command</h1>
<p>I am trying to create a react project i have run <code>npx create-react-app my-app</code> then <code>cd my-app</code> but when I've <code>npm start</code>
this error has been shown:</p>
<pre><code>> my-app@0.1.0 start C:\Users\USER\my-app
> react-scripts sta... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,429 | cmd | # Error when trying to rum npm start command
I am trying to create a react project i have run `npx create-react-app my-app` then `cd my-app` but when I've `npm start`
this error has been shown:
```
> my-app@0.1.0 start C:\Users\USER\my-app
> react-scripts start
i 「wds」: Project is running at http://192.168.137.1/
i ... | I've found some possible solutions. Seems that you are using powershell, check firstly that you have it in your PATH as %SystemRoot%/system32/WindowsPowerShell/v1.0. After that open powershell as admin and write
```
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
```
It should help in case there is problem... |
62984477 | Running python scripts in Anaconda environment through Windows cmd | 7 | 2020-07-19 19:01:54 | <p>I have the following goal: I have a python script, which should be running in my custom Anaconda environment. And this process needs to be automatizated.</p>
<p>The first thing I've tried was to create an .exe file of my script using pyinstaller in the Anaconda command prompt, opened in my environment. And put the .... | 12,413 | 12,234,535 | 2020-07-21 17:39:30 | 62,984,582 | 13 | 2020-07-19 19:12:25 | 3,015,186 | 2020-07-20 14:46:29 | https://stackoverflow.com/q/62984477 | https://stackoverflow.com/a/62984582 | <p>You could</p>
<ol>
<li>Create a <code>.bat</code> file (e.g. <code>run_python_script.bat</code>) with contents shown below.</li>
<li>Create task in "Task Scheduler" to run the <code>.bat</code> file.</li>
</ol>
<h3>1.a. The .bat file contents with conda environments</h3>
<ol>
<li>Check your <code><conda... | <p>You could</p> <ol> <li>Create a <code>.bat</code> file (e.g. <code>run_python_script.bat</code>) with contents shown below.</li> <li>Create task in "Task Scheduler" to run the <code>.bat</code> file.</li> </ol> <h3>1.a. The .bat file contents with conda environments</h3> <ol> <li>Check your <code><conda... | 16, 2631, 9299, 14766, 92746 | anaconda, cmd, pyinstaller, python, scheduled-tasks | <h1>Running python scripts in Anaconda environment through Windows cmd</h1>
<p>I have the following goal: I have a python script, which should be running in my custom Anaconda environment. And this process needs to be automatizated.</p>
<p>The first thing I've tried was to create an .exe file of my script using pyinsta... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,430 | cmd | # Running python scripts in Anaconda environment through Windows cmd
I have the following goal: I have a python script, which should be running in my custom Anaconda environment. And this process needs to be automatizated.
The first thing I've tried was to create an .exe file of my script using pyinstaller in the Ana... | You could
1. Create a `.bat` file (e.g. `run_python_script.bat`) with contents shown below.
2. Create task in "Task Scheduler" to run the `.bat` file.
### 1.a. The .bat file contents with conda environments
1. Check your `<condapath>`. Your `conda.exe` is located at `<condapath>/Scripts`.
2. Put into your .bat file
... |
45809295 | Batch File : Read File Names from a Directory and Store in Array | 7 | 2017-08-22 05:09:04 | <p>I'm creating a batch file in which I need to list all the text file name of the specified folder then store and retrieve the same from an array. Is it possible in Batch Files? My current code to list the test files is as below </p>
<pre><code> dir *.txt /b
</code></pre>
<p>any help is much appreciated.</p>
| 49,507 | 5,106,154 | 2019-02-07 14:18:58 | 45,811,503 | 13 | 2017-08-22 07:31:59 | null | 2019-02-07 14:18:58 | https://stackoverflow.com/q/45809295 | https://stackoverflow.com/a/45811503 | <p><strong>Simulating Array</strong></p>
<p>String is the only variable type in batch file. However, arrays can be simulated with several variables of identical name except a trailing numerical ID such as:</p>
<pre><code>Array[1] Array[2] Array[3] Array[4] etc...
</code></pre>
<p>We can store each file ... | <p><strong>Simulating Array</strong></p> <p>String is the only variable type in batch file. However, arrays can be simulated with several variables of identical name except a trailing numerical ID such as:</p> <pre><code>Array[1] Array[2] Array[3] Array[4] etc... </code></pre> <p>We can store each file ... | 7002 | batch-file | <h1>Batch File : Read File Names from a Directory and Store in Array</h1>
<p>I'm creating a batch file in which I need to list all the text file name of the specified folder then store and retrieve the same from an array. Is it possible in Batch Files? My current code to list the test files is as below </p>
<pre><code... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,431 | cmd | # Batch File : Read File Names from a Directory and Store in Array
I'm creating a batch file in which I need to list all the text file name of the specified folder then store and retrieve the same from an array. Is it possible in Batch Files? My current code to list the test files is as below
```
dir *.txt /b
```
a... | **Simulating Array**
String is the only variable type in batch file. However, arrays can be simulated with several variables of identical name except a trailing numerical ID such as:
```
Array[1] Array[2] Array[3] Array[4] etc...
```
We can store each file name into these variables.
---
**Retrieving c... |
40575339 | Using NSFetchedResultsController w/NSBatchDeleteRequest | 7 | 2016-11-13 15:11:29 | <p>I'm having an issue getting accurate updates from an NSFetchedResultsControllerDelegate after using an NSBatchDeleteRequest, the changes come through as an update type and not the delete type on the didChange delegate method. Is there a way to get the changes to come in as a delete? (I have different scenarios for d... | 1,973 | 4,096,655 | 2020-09-23 14:24:08 | 40,583,926 | 13 | 2016-11-14 07:39:48 | 826,716 | 2016-11-14 07:45:21 | https://stackoverflow.com/q/40575339 | https://stackoverflow.com/a/40583926 | <p>From Apple's <a href="https://developer.apple.com/library/content/featuredarticles/CoreData_Batch_Guide/BatchDeletes/BatchDeletes.html" rel="noreferrer">documentation</a>:</p>
<blockquote>
<p>Batch deletes run faster than deleting the Core Data entities yourself in code because they operate in the persistent store i... | <p>From Apple's <a href="https://developer.apple.com/library/content/featuredarticles/CoreData_Batch_Guide/BatchDeletes/BatchDeletes.html" rel="noreferrer">documentation</a>:</p> <blockquote> <p>Batch deletes run faster than deleting the Core Data entities yourself in code because they operate in the persistent store i... | 5263, 37495, 58338, 104797, 123051 | core-data, ios, nsbatchdeleterequest, nsfetchedresultscontroller, swift | <h1>Using NSFetchedResultsController w/NSBatchDeleteRequest</h1>
<p>I'm having an issue getting accurate updates from an NSFetchedResultsControllerDelegate after using an NSBatchDeleteRequest, the changes come through as an update type and not the delete type on the didChange delegate method. Is there a way to get the ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,432 | cmd | # Using NSFetchedResultsController w/NSBatchDeleteRequest
I'm having an issue getting accurate updates from an NSFetchedResultsControllerDelegate after using an NSBatchDeleteRequest, the changes come through as an update type and not the delete type on the didChange delegate method. Is there a way to get the changes t... | From Apple's [documentation](https://developer.apple.com/library/content/featuredarticles/CoreData_Batch_Guide/BatchDeletes/BatchDeletes.html):
> Batch deletes run faster than deleting the Core Data entities yourself in code because they operate in the persistent store itself, at the SQL level. As part of this differe... |
33292353 | Batch: what is the pipe | used for? | 7 | 2015-10-22 23:16:12 | <p>Hello stackoverflow users!</p>
<p>I'm not really new to batch. I just never used pipes <code>|</code> in batch and even after I read reference on ss64.com I don't understand what's the pipe used for.</p>
<p>At first I thought it is OR operator or something (obviously I know now it's not).</p>
<p>I only know that ... | 21,323 | 5,477,609 | 2022-07-05 20:39:21 | 33,292,435 | 13 | 2015-10-22 23:24:03 | 2,414,894 | 2022-07-05 20:39:21 | https://stackoverflow.com/q/33292353 | https://stackoverflow.com/a/33292435 | <p>Pipe [|]: Redirect standard output of commandA to standard input of commandB</p>
<p><a href="http://www.robvanderwoude.com/redirection.php" rel="nofollow noreferrer">http://www.robvanderwoude.com/redirection.php</a></p>
<p>example :</p>
<pre class="lang-dos prettyprint-override"><code>echo KKZiomek | find "KKZ&... | <p>Pipe [|]: Redirect standard output of commandA to standard input of commandB</p> <p><a href="http://www.robvanderwoude.com/redirection.php" rel="nofollow noreferrer">http://www.robvanderwoude.com/redirection.php</a></p> <p>example :</p> <pre class="lang-dos prettyprint-override"><code>echo KKZiomek | find "KKZ&... | 367, 2631, 7002, 7992 | batch-file, cmd, operators, syntax | <h1>Batch: what is the pipe | used for?</h1>
<p>Hello stackoverflow users!</p>
<p>I'm not really new to batch. I just never used pipes <code>|</code> in batch and even after I read reference on ss64.com I don't understand what's the pipe used for.</p>
<p>At first I thought it is OR operator or something (obviously I ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,433 | cmd | # Batch: what is the pipe | used for?
Hello stackoverflow users!
I'm not really new to batch. I just never used pipes `|` in batch and even after I read reference on ss64.com I don't understand what's the pipe used for.
At first I thought it is OR operator or something (obviously I know now it's not).
I only know t... | Pipe [|]: Redirect standard output of commandA to standard input of commandB
<http://www.robvanderwoude.com/redirection.php>
example :
```
echo KKZiomek | find "KKZ"
```
will redirect the `echo KKZiomek` in the input of the `FIND` and be used as second parameter of it.
Like well commented by **@aschipfl** the spac... |
27729999 | grunt execution stops batch script | 7 | 2015-01-01 10:33:52 | <p>I am doing development with cordova and yeoman + angularjs. I have adopted a folder structure as follows (output of dir command on windows):</p>
<pre><code>C:\code\cordova\pg-droid-app>dir
Volume in drive C is OSDisk
Volume Serial Number is 404D-C81B
Directory of C:\code\cordova\pg-droid-app
01/01/2015 03:... | 1,314 | 145,682 | 2015-04-20 06:34:44 | 29,740,747 | 13 | 2015-04-20 06:34:44 | 145,682 | 2015-04-20 06:34:44 | https://stackoverflow.com/q/27729999 | https://stackoverflow.com/a/29740747 | <p><code>grunt</code> is somewhat behaves like a <code>.bat</code> (windows batch) file or a <em>batch</em> program. Hence within a batch program, if you want to execute another batch program, you have to prefix <code>call</code> before it.</p>
<pre><code>call grunt --force
</code></pre>
| <p><code>grunt</code> is somewhat behaves like a <code>.bat</code> (windows batch) file or a <em>batch</em> program. Hence within a batch program, if you want to execute another batch program, you have to prefix <code>call</code> before it.</p> <pre><code>call grunt --force </code></pre> | 64, 1231, 7002, 78331, 83890 | batch-file, command-line, cordova, windows, yeoman | <h1>grunt execution stops batch script</h1>
<p>I am doing development with cordova and yeoman + angularjs. I have adopted a folder structure as follows (output of dir command on windows):</p>
<pre><code>C:\code\cordova\pg-droid-app>dir
Volume in drive C is OSDisk
Volume Serial Number is 404D-C81B
Directory of C... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,434 | cmd | # grunt execution stops batch script
I am doing development with cordova and yeoman + angularjs. I have adopted a folder structure as follows (output of dir command on windows):
```
C:\code\cordova\pg-droid-app>dir
Volume in drive C is OSDisk
Volume Serial Number is 404D-C81B
Directory of C:\code\cordova\pg-droid... | `grunt` is somewhat behaves like a `.bat` (windows batch) file or a *batch* program. Hence within a batch program, if you want to execute another batch program, you have to prefix `call` before it.
```
call grunt --force
``` |
16429780 | Inno Setup Run Extracted Batch File As Administrator | 7 | 2013-05-07 22:42:51 | <p>I am building an installer with Inno Setup and would like for the extracted files to be run as an administrator. Is there a way to force the extracted files (i.e. batch file) to run as an administrator? If so, what code elements do I need to include to perform this.</p>
<p>The setup log shows something like the fol... | 14,464 | 570,402 | 2015-12-15 17:27:31 | 16,433,854 | 13 | 2013-05-08 06:13:27 | 765,955 | 2013-05-10 16:06:49 | https://stackoverflow.com/q/16429780 | https://stackoverflow.com/a/16433854 | <p>If you are using <code>[Run]</code> section then make sure you use <code>runascurrentuser</code> flag (If this flag is specified, the spawned process will inherit Setup/Uninstall's user credentials (typically, full administrative privileges))</p>
<p>Else there are three ways how to run applications programatically ... | <p>If you are using <code>[Run]</code> section then make sure you use <code>runascurrentuser</code> flag (If this flag is specified, the spawned process will inherit Setup/Uninstall's user credentials (typically, full administrative privileges))</p> <p>Else there are three ways how to run applications programatically ... | 529, 3942, 7002 | batch-file, inno-setup, installation | <h1>Inno Setup Run Extracted Batch File As Administrator</h1>
<p>I am building an installer with Inno Setup and would like for the extracted files to be run as an administrator. Is there a way to force the extracted files (i.e. batch file) to run as an administrator? If so, what code elements do I need to include to pe... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,435 | cmd | # Inno Setup Run Extracted Batch File As Administrator
I am building an installer with Inno Setup and would like for the extracted files to be run as an administrator. Is there a way to force the extracted files (i.e. batch file) to run as an administrator? If so, what code elements do I need to include to perform thi... | If you are using `[Run]` section then make sure you use `runascurrentuser` flag (If this flag is specified, the spawned process will inherit Setup/Uninstall's user credentials (typically, full administrative privileges))
Else there are three ways how to run applications programatically (recommended way):
```
function... |
15209559 | copy all files recursively into a single folder (without recreating folders) | 7 | 2013-03-04 19:31:47 | <p>With a batch (.bat), I want to copy all mp3 files that are in 1 subdirectory of D:\TEMP</p>
<pre><code>D:\TEMP\\(anyfolder)\\(anyfile.mp3)
</code></pre>
<p>to</p>
<pre><code>E:\MYFOLDER\
</code></pre>
<p>I tried with xcopy but</p>
<ul>
<li><p>I don't know how to tell "just recurse subfolders of D:\TEMP and not ... | 14,942 | 1,422,096 | 2022-03-27 03:53:40 | 15,209,714 | 13 | 2013-03-04 19:39:06 | 30,447 | 2014-07-31 17:40:17 | https://stackoverflow.com/q/15209559 | https://stackoverflow.com/a/15209714 | <p><code>for</code> command is your friend. Read <code>help for</code> and then try this in the command prompt</p>
<pre><code>for /d %a in (*) do @echo %a
</code></pre>
<p>as you see, it follows all subfolders in the current directory.</p>
<p>thus, </p>
<pre><code>for /d %a in (*) do @copy %a\*.mp3 e:\myfolder
</co... | <p><code>for</code> command is your friend. Read <code>help for</code> and then try this in the command prompt</p> <pre><code>for /d %a in (*) do @echo %a </code></pre> <p>as you see, it follows all subfolders in the current directory.</p> <p>thus, </p> <pre><code>for /d %a in (*) do @copy %a\*.mp3 e:\myfolder </co... | 218, 4710, 7002 | batch-file, directory, xcopy | <h1>copy all files recursively into a single folder (without recreating folders)</h1>
<p>With a batch (.bat), I want to copy all mp3 files that are in 1 subdirectory of D:\TEMP</p>
<pre><code>D:\TEMP\\(anyfolder)\\(anyfile.mp3)
</code></pre>
<p>to</p>
<pre><code>E:\MYFOLDER\
</code></pre>
<p>I tried with xcopy but</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,436 | cmd | # copy all files recursively into a single folder (without recreating folders)
With a batch (.bat), I want to copy all mp3 files that are in 1 subdirectory of D:\TEMP
```
D:\TEMP\\(anyfolder)\\(anyfile.mp3)
```
to
```
E:\MYFOLDER\
```
I tried with xcopy but
- I don't know how to tell "just recurse subfolders of D... | `for` command is your friend. Read `help for` and then try this in the command prompt
```
for /d %a in (*) do @echo %a
```
as you see, it follows all subfolders in the current directory.
thus,
```
for /d %a in (*) do @copy %a\*.mp3 e:\myfolder
```
will copy all your mp3 to the destination folder. |
43538082 | How to go to a subdirectory in CMD? | 6 | 2017-04-21 08:49:47 | <p>How can I go to a subdirectory without specifying its whole path?</p>
<p>So when I am in </p>
<pre><code>C:/users/USERNAME/desktop/project/build/
</code></pre>
<p>How can I then navigate to </p>
<pre><code>C:/users/USERNAME/desktop/project/build/directory 1/
</code></pre>
<p>I tried</p>
<pre><code>cd /director... | 43,945 | 6,018,747 | 2022-02-09 10:43:42 | 43,539,414 | 13 | 2017-04-21 09:47:26 | 3,074,564 | 2022-02-09 10:43:42 | https://stackoverflow.com/q/43538082 | https://stackoverflow.com/a/43539414 | <p>On Windows the directory separator is <code>\</code> ... the backslash character. The slash character <code>/</code> is used on Windows for parameters/options of a command/executable/script.</p>
<p>For compatibility reasons like <code>#include</code> instructions in C/C++/C# with a relative path using <code>/</code>... | <p>On Windows the directory separator is <code>\</code> ... the backslash character. The slash character <code>/</code> is used on Windows for parameters/options of a command/executable/script.</p> <p>For compatibility reasons like <code>#include</code> instructions in C/C++/C# with a relative path using <code>/</code>... | 64, 2631 | cmd, windows | <h1>How to go to a subdirectory in CMD?</h1>
<p>How can I go to a subdirectory without specifying its whole path?</p>
<p>So when I am in </p>
<pre><code>C:/users/USERNAME/desktop/project/build/
</code></pre>
<p>How can I then navigate to </p>
<pre><code>C:/users/USERNAME/desktop/project/build/directory 1/
</code></... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,438 | cmd | # How to go to a subdirectory in CMD?
How can I go to a subdirectory without specifying its whole path?
So when I am in
```
C:/users/USERNAME/desktop/project/build/
```
How can I then navigate to
```
C:/users/USERNAME/desktop/project/build/directory 1/
```
I tried
```
cd /directory 1
```
But this results in
> ... | On Windows the directory separator is `\` ... the backslash character. The slash character `/` is used on Windows for parameters/options of a command/executable/script.
For compatibility reasons like `#include` instructions in C/C++/C# with a relative path using `/` as directory separator Windows accepts also paths wi... |
34619289 | How to get Python location using Windows batch file? | 6 | 2016-01-05 18:58:46 | <p>I need to create a windows batch script which creates and moves one specific file to <code>PYTHONPATH\Lib\distutils</code> folder.</p>
<p>Here is what I am attempting to do:</p>
<pre><code>ECHO [build] >> distutils.cfg
ECHO compiler=mingw32 >> distutils.cfg
MOVE distutils.cfg PYTHONPATH\Lib\distutils
<... | 10,010 | 1,984,680 | 2023-11-02 14:22:34 | 34,619,649 | 13 | 2016-01-05 19:22:15 | 4,241,180 | 2016-01-05 19:22:15 | https://stackoverflow.com/q/34619289 | https://stackoverflow.com/a/34619649 | <p>Since python is in your <code>PATH</code> you can use function <code>where</code>, which is a Windows analogue of Linux <code>whereis</code> function:</p>
<pre><code>> where python.exe
</code></pre>
<p>See details <a href="https://superuser.com/questions/21067/windows-equivalent-of-whereis">here</a>. You can se... | <p>Since python is in your <code>PATH</code> you can use function <code>where</code>, which is a Windows analogue of Linux <code>whereis</code> function:</p> <pre><code>> where python.exe </code></pre> <p>See details <a href="https://superuser.com/questions/21067/windows-equivalent-of-whereis">here</a>. You can se... | 16, 6268, 7002, 35113 | batch-file, path, python, pythonpath | <h1>How to get Python location using Windows batch file?</h1>
<p>I need to create a windows batch script which creates and moves one specific file to <code>PYTHONPATH\Lib\distutils</code> folder.</p>
<p>Here is what I am attempting to do:</p>
<pre><code>ECHO [build] >> distutils.cfg
ECHO compiler=mingw32 >&g... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,439 | cmd | # How to get Python location using Windows batch file?
I need to create a windows batch script which creates and moves one specific file to `PYTHONPATH\Lib\distutils` folder.
Here is what I am attempting to do:
```
ECHO [build] >> distutils.cfg
ECHO compiler=mingw32 >> distutils.cfg
MOVE distutils.cfg PYTHONPATH\Lib... | Since python is in your `PATH` you can use function `where`, which is a Windows analogue of Linux `whereis` function:
```
> where python.exe
```
See details [here](https://superuser.com/questions/21067/windows-equivalent-of-whereis). You can set output of `where` command to a variable and then use it (see [this post]... |
30877797 | How to control the number of parallel Spring Batch jobs | 6 | 2015-06-16 20:43:03 | <p>I have a report generating application. As preparation of such reports is heavyweight, they are prepared asynchronously with Spring Batch. Requests for such reports are created via REST interface using HTTP.</p>
<p>The goal is that the REST resource simply queues report execution and completes (<a href="http://docs... | 14,291 | 5,016,980 | 2015-06-17 08:47:06 | 30,878,217 | 13 | 2015-06-16 21:07:30 | 618,059 | 2015-06-16 21:07:30 | https://stackoverflow.com/q/30877797 | https://stackoverflow.com/a/30878217 | <p><code>SimpleAsyncTaskExecutor</code> isn't recommended for heavy use since it spawns a new thread with each task. It also does not support more robust concepts like thread pooling and queueing of tasks.</p>
<p>If you take a look at the <code>ThreadPoolTaskExecutor</code>, it supports a more robust task execution p... | <p><code>SimpleAsyncTaskExecutor</code> isn't recommended for heavy use since it spawns a new thread with each task. It also does not support more robust concepts like thread pooling and queueing of tasks.</p> <p>If you take a look at the <code>ThreadPoolTaskExecutor</code>, it supports a more robust task execution p... | 1211, 16537, 41895 | spring, spring-batch, spring-integration | <h1>How to control the number of parallel Spring Batch jobs</h1>
<p>I have a report generating application. As preparation of such reports is heavyweight, they are prepared asynchronously with Spring Batch. Requests for such reports are created via REST interface using HTTP.</p>
<p>The goal is that the REST resource s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,440 | cmd | # How to control the number of parallel Spring Batch jobs
I have a report generating application. As preparation of such reports is heavyweight, they are prepared asynchronously with Spring Batch. Requests for such reports are created via REST interface using HTTP.
The goal is that the REST resource simply queues rep... | `SimpleAsyncTaskExecutor` isn't recommended for heavy use since it spawns a new thread with each task. It also does not support more robust concepts like thread pooling and queueing of tasks.
If you take a look at the `ThreadPoolTaskExecutor`, it supports a more robust task execution paradigm with things like queueing... |
30136210 | Running multiple commands simultaneously | 6 | 2015-05-09 05:02:19 | <p>I have a script that will run open multiple cmd windows and run different php commands in each window. Unfortunately, my current code waits for the first set of PHP commands to finish before the second set of PHP commands starts, defeating the purpose of opening multiple windows.</p>
<p>Is it possible to run all se... | 18,450 | 4,650,778 | 2015-05-09 13:07:42 | 30,138,152 | 13 | 2015-05-09 09:15:47 | 3,439,404 | 2015-05-09 09:15:47 | https://stackoverflow.com/q/30136210 | https://stackoverflow.com/a/30138152 | <pre><code>start "" /d "c:\users\administrator\desktop\chps\chp1" php checker.php
start "" /d "c:\users\administrator\desktop\chps\chp2" php checker.php
start "" /d "c:\users\administrator\desktop\chps\chp3" php checker.php
</code></pre>
<p>In above code snippet:</p>
<ul>
<li><a href="https://technet.microsoft.com/en... | <pre><code>start "" /d "c:\users\administrator\desktop\chps\chp1" php checker.php start "" /d "c:\users\administrator\desktop\chps\chp2" php checker.php start "" /d "c:\users\administrator\desktop\chps\chp3" php checker.php </code></pre> <p>In above code snippet:</p> <ul> <li><a href="https://technet.microsoft.com/en... | 2631, 7002 | batch-file, cmd | <h1>Running multiple commands simultaneously</h1>
<p>I have a script that will run open multiple cmd windows and run different php commands in each window. Unfortunately, my current code waits for the first set of PHP commands to finish before the second set of PHP commands starts, defeating the purpose of opening mult... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,441 | cmd | # Running multiple commands simultaneously
I have a script that will run open multiple cmd windows and run different php commands in each window. Unfortunately, my current code waits for the first set of PHP commands to finish before the second set of PHP commands starts, defeating the purpose of opening multiple wind... | ```
start "" /d "c:\users\administrator\desktop\chps\chp1" php checker.php
start "" /d "c:\users\administrator\desktop\chps\chp2" php checker.php
start "" /d "c:\users\administrator\desktop\chps\chp3" php checker.php
```
In above code snippet:
- [`start` command](https://technet.microsoft.com/en-us/library/cc770297.a... |
27739585 | ExtJS 5.1 Build Error (Yui Parse Error) | 6 | 2015-01-02 08:52:28 | <p>I use eclipse for ExtJS development,
I am using ant build in eclipse, it uses Sencha cmd.
My project details are</p>
<p>app.framework.version=5.1.0.107</p>
<p>app.cmd.version=5.1.0.26</p>
<p>when I try to build project, it fails with Yui Parse errors, but I couldn't find any error in my workspace..
Can you explai... | 4,122 | 2,656,745 | 2015-01-07 22:15:33 | 27,743,784 | 13 | 2015-01-02 14:33:49 | 1,238,344 | 2015-01-07 22:15:33 | https://stackoverflow.com/q/27739585 | https://stackoverflow.com/a/27743784 | <p>I'm going to go out on a limb and suggest it's because you are using a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords" rel="noreferrer">reserved word</a> in your property name. While It's typically <em>"okay"</em> in javascript and your ExtJS application runs in ... | <p>I'm going to go out on a limb and suggest it's because you are using a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords" rel="noreferrer">reserved word</a> in your property name. While It's typically <em>"okay"</em> in javascript and your ExtJS application runs in ... | 4025, 87610, 103663, 106856 | extjs, extjs5, sencha-cmd, sencha-cmd5 | <h1>ExtJS 5.1 Build Error (Yui Parse Error)</h1>
<p>I use eclipse for ExtJS development,
I am using ant build in eclipse, it uses Sencha cmd.
My project details are</p>
<p>app.framework.version=5.1.0.107</p>
<p>app.cmd.version=5.1.0.26</p>
<p>when I try to build project, it fails with Yui Parse errors, but I couldn'... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,443 | cmd | # ExtJS 5.1 Build Error (Yui Parse Error)
I use eclipse for ExtJS development,
I am using ant build in eclipse, it uses Sencha cmd.
My project details are
app.framework.version=5.1.0.107
app.cmd.version=5.1.0.26
when I try to build project, it fails with Yui Parse errors, but I couldn't find any error in my workspa... | I'm going to go out on a limb and suggest it's because you are using a [reserved word](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords) in your property name. While It's typically *"okay"* in javascript and your ExtJS application runs in development mode, I've found when minif... |
22695230 | Spring Batch javaConfig: Conditional Flow | 6 | 2014-03-27 17:41:15 | <p>Is there any suggestions to the way to transfrom this xml config to javaconfig:</p>
<pre><code><job id="job">
<step id="step1" >
<next on="FAILED" to="step2"/>
<next on="*" to="step3"/>
</step>
<step id="step2"/>
<step id="step3"next="step4"/&g... | 5,724 | 3,469,745 | 2016-07-08 08:12:59 | 22,695,844 | 13 | 2014-03-27 18:10:52 | 1,259,109 | 2016-07-08 08:12:59 | https://stackoverflow.com/q/22695230 | https://stackoverflow.com/a/22695844 | <p>Maybe like this:</p>
<pre><code>jobs.get("job")
.start(step1())
.on("FAILED").to(step2())
.next(step3())
.from(step1())
.next(step3())
.next(step4())
.build().build();
</code></pre>
<p>(Step 2 is only executed if step 1 finished with status 'FAILED'. All other steps are exec... | <p>Maybe like this:</p> <pre><code>jobs.get("job") .start(step1()) .on("FAILED").to(step2()) .next(step3()) .from(step1()) .next(step3()) .next(step4()) .build().build(); </code></pre> <p>(Step 2 is only executed if step 1 finished with status 'FAILED'. All other steps are exec... | 955, 1211, 30645 | batch-processing, jobs, spring | <h1>Spring Batch javaConfig: Conditional Flow</h1>
<p>Is there any suggestions to the way to transfrom this xml config to javaconfig:</p>
<pre><code><job id="job">
<step id="step1" >
<next on="FAILED" to="step2"/>
<next on="*" to="step3"/>
</step>
<step id=... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,444 | cmd | # Spring Batch javaConfig: Conditional Flow
Is there any suggestions to the way to transfrom this xml config to javaconfig:
```
<job id="job">
<step id="step1" >
<next on="FAILED" to="step2"/>
<next on="*" to="step3"/>
</step>
<step id="step2"/>
<step id="step3"next="step4"/>
<ste... | Maybe like this:
```
jobs.get("job")
.start(step1())
.on("FAILED").to(step2())
.next(step3())
.from(step1())
.next(step3())
.next(step4())
.build().build();
```
(Step 2 is only executed if step 1 finished with status 'FAILED'. All other steps are executed in order. Is that what... |
21479062 | Merge all .txt files in all subdirectories in one txt file | 6 | 2014-01-31 11:32:32 | <p>I want to merge content of all .txt files in my directory (containing subdirectories) to one txt file.
I need to do this:</p>
<pre><code>xcopy text1.txt + text2.txt text3.txt
</code></pre>
<p>but in a for loop which takes all text files in current directory. i assume something like this:</p>
<pre><code>for \r __... | 8,004 | 2,405,737 | 2014-01-31 13:14:42 | 21,480,965 | 13 | 2014-01-31 13:14:42 | 2,299,431 | 2014-01-31 13:14:42 | https://stackoverflow.com/q/21479062 | https://stackoverflow.com/a/21480965 | <p>Use one % instead of two %% to run it from the command line.</p>
<pre><code>for /r "c:\folder" %%a in (*.txt) do type "%%a" >>"bigfile.txt"
</code></pre>
| <p>Use one % instead of two %% to run it from the command line.</p> <pre><code>for /r "c:\folder" %%a in (*.txt) do type "%%a" >>"bigfile.txt" </code></pre> | 717, 1469, 4710, 7002 | batch-file, merge, text, xcopy | <h1>Merge all .txt files in all subdirectories in one txt file</h1>
<p>I want to merge content of all .txt files in my directory (containing subdirectories) to one txt file.
I need to do this:</p>
<pre><code>xcopy text1.txt + text2.txt text3.txt
</code></pre>
<p>but in a for loop which takes all text files in curren... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,445 | cmd | # Merge all .txt files in all subdirectories in one txt file
I want to merge content of all .txt files in my directory (containing subdirectories) to one txt file.
I need to do this:
```
xcopy text1.txt + text2.txt text3.txt
```
but in a for loop which takes all text files in current directory. i assume something li... | Use one % instead of two %% to run it from the command line.
```
for /r "c:\folder" %%a in (*.txt) do type "%%a" >>"bigfile.txt"
``` |
1487214 | How to grab the names of all sub-folders in a batch script? | 6 | 2009-09-28 14:02:33 | <p>I just want to know how can I get all the names of the folders in a current directory. For example in my current directory I have three folders:</p>
<pre>
stackoverflow
reddit
codinghorror
</pre>
<p>Then when I execute my batch script all the three folders will print in the screen.</p>
<p>How can I achieve this?<... | 22,795 | 130,278 | 2016-11-10 12:28:20 | 1,487,366 | 13 | 2009-09-28 14:32:19 | 137,624 | 2009-09-28 14:32:19 | https://stackoverflow.com/q/1487214 | https://stackoverflow.com/a/1487366 | <p>Using batch files:</p>
<pre><code>for /d %%d in (*.*) do echo %%d
</code></pre>
<p>If you want to test that on the command line, use only one % sign in both cases.</p>
| <p>Using batch files:</p> <pre><code>for /d %%d in (*.*) do echo %%d </code></pre> <p>If you want to test that on the command line, use only one % sign in both cases.</p> | 64, 7002 | batch-file, windows | <h1>How to grab the names of all sub-folders in a batch script?</h1>
<p>I just want to know how can I get all the names of the folders in a current directory. For example in my current directory I have three folders:</p>
<pre>
stackoverflow
reddit
codinghorror
</pre>
<p>Then when I execute my batch script all the thr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,447 | cmd | # How to grab the names of all sub-folders in a batch script?
I just want to know how can I get all the names of the folders in a current directory. For example in my current directory I have three folders:
```
stackoverflow
reddit
codinghorror
```
Then when I execute my batch script all the three folders will print... | Using batch files:
```
for /d %%d in (*.*) do echo %%d
```
If you want to test that on the command line, use only one % sign in both cases. |
44604027 | Running interactive command line code from Jupyter notebook | 54 | 2017-06-17 11:24:57 | <p>There is an interesting option in Ipython Jupyter Notebook to execute command line statements directly from the notebook. For example:</p>
<pre><code>! mkdir ...
! python file.py
</code></pre>
<p>Moreover - this code can be run using <code>os</code>:</p>
<pre><code>import os
os.system('cmd command')
</code></pre>... | 144,267 | 3,861,108 | 2024-01-24 05:18:48 | 48,787,335 | 12 | 2018-02-14 12:32:43 | 7,916,438 | 2018-02-14 12:32:43 | https://stackoverflow.com/q/44604027 | https://stackoverflow.com/a/48787335 | <p>Assuming you are asking about interactivity, there is something you can try.</p>
<p>If you ever wondered how Jupyter knows when the output of a cell ends: well, it apparently does not know, it just dumps any captured output into the most recently active cell:</p>
<pre><code>import threading,time
a=5
threading.Thre... | <p>Assuming you are asking about interactivity, there is something you can try.</p> <p>If you ever wondered how Jupyter knows when the output of a cell ends: well, it apparently does not know, it just dumps any captured output into the most recently active cell:</p> <pre><code>import threading,time a=5 threading.Thre... | 2631, 14670, 110585 | cmd, ipython, jupyter | <h1>Running interactive command line code from Jupyter notebook</h1>
<p>There is an interesting option in Ipython Jupyter Notebook to execute command line statements directly from the notebook. For example:</p>
<pre><code>! mkdir ...
! python file.py
</code></pre>
<p>Moreover - this code can be run using <code>os</co... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,448 | cmd | # Running interactive command line code from Jupyter notebook
There is an interesting option in Ipython Jupyter Notebook to execute command line statements directly from the notebook. For example:
```
! mkdir ...
! python file.py
```
Moreover - this code can be run using `os`:
```
import os
os.system('cmd command')... | Assuming you are asking about interactivity, there is something you can try.
If you ever wondered how Jupyter knows when the output of a cell ends: well, it apparently does not know, it just dumps any captured output into the most recently active cell:
```
import threading,time
a=5
threading.Thread(target=lambda:[pri... |
4998549 | git on UNC path | 33 | 2011-02-14 23:32:06 | <p>I have computer with Windows XP and no Internet connection, only access to network drive. I'd like to set up a git repository on the network drive and then push to it from my local repository, so I can at the end of the day go to a computer with Internet connection and push from network drive to github.</p>
<p>My p... | 20,986 | 178,331 | 2020-01-13 11:40:25 | 5,431,998 | 12 | 2011-03-25 11:48:27 | 321,973 | 2016-09-18 17:42:47 | https://stackoverflow.com/q/4998549 | https://stackoverflow.com/a/5431998 | <p>Just use the UNC path - <code>git</code> doesn't care what <code>cmd</code> can and cannot do.</p>
<hr>
<p>Old answer: Bind the UNC path to a drive letter (or use a directory symlink).</p>
| <p>Just use the UNC path - <code>git</code> doesn't care what <code>cmd</code> can and cannot do.</p> <hr> <p>Old answer: Bind the UNC path to a drive letter (or use a directory symlink).</p> | 119, 2631 | cmd, git | <h1>git on UNC path</h1>
<p>I have computer with Windows XP and no Internet connection, only access to network drive. I'd like to set up a git repository on the network drive and then push to it from my local repository, so I can at the end of the day go to a computer with Internet connection and push from network driv... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,449 | cmd | # git on UNC path
I have computer with Windows XP and no Internet connection, only access to network drive. I'd like to set up a git repository on the network drive and then push to it from my local repository, so I can at the end of the day go to a computer with Internet connection and push from network drive to gith... | Just use the UNC path - `git` doesn't care what `cmd` can and cannot do.
---
Old answer: Bind the UNC path to a drive letter (or use a directory symlink). |
17158719 | How to loop through comma separated string in batch? | 29 | 2013-06-18 00:01:05 | <p>Windows</p>
<p>Based on the post (<a href="https://stackoverflow.com/questions/2524928/dos-batch-iterate-through-a-delimited-string">dos batch iterate through a delimited string</a>), I wrote a script below but not working as expected.</p>
<p><strong>Goal</strong>: Given string "Sun,Granite,Twilight", I want to ge... | 71,998 | 355,044 | 2016-07-07 11:07:18 | 17,158,801 | 12 | 2013-06-18 00:14:16 | 2,093,352 | 2016-07-07 11:07:18 | https://stackoverflow.com/q/17158719 | https://stackoverflow.com/a/17158801 | <p>I made a few modifications to your code.</p>
<ol>
<li>Need goto :eof at end of subroutines and at end of main routine so you don't fall into subroutines.</li>
<li>tokens=1* (%%f is first token; %%g is rest of the line)</li>
<li><p>~ in set list=%~1 to remove quotes so quotes don't accumulate</p>
<pre><code>@echo o... | <p>I made a few modifications to your code.</p> <ol> <li>Need goto :eof at end of subroutines and at end of main routine so you don't fall into subroutines.</li> <li>tokens=1* (%%f is first token; %%g is rest of the line)</li> <li><p>~ in set list=%~1 to remove quotes so quotes don't accumulate</p> <pre><code>@echo o... | 7002 | batch-file | <h1>How to loop through comma separated string in batch?</h1>
<p>Windows</p>
<p>Based on the post (<a href="https://stackoverflow.com/questions/2524928/dos-batch-iterate-through-a-delimited-string">dos batch iterate through a delimited string</a>), I wrote a script below but not working as expected.</p>
<p><strong>Go... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,450 | cmd | # How to loop through comma separated string in batch?
Windows
Based on the post ([dos batch iterate through a delimited string](https://stackoverflow.com/questions/2524928/dos-batch-iterate-through-a-delimited-string)), I wrote a script below but not working as expected.
**Goal**: Given string "Sun,Granite,Twilight... | I made a few modifications to your code.
1. Need goto :eof at end of subroutines and at end of main routine so you don't fall into subroutines.
2. tokens=1* (%%f is first token; %%g is rest of the line)
3. ~ in set list=%~1 to remove quotes so quotes don't accumulate
```
@echo off
set themes=Sun,Granite,Twil... |
56715476 | How do I test if Python is installed on Windows (10), and run an exe to install it if its not installed? | 24 | 2019-06-22 12:28:10 | <p>I need to run the 2nd command on windows cmd only if the 1st one fails,
in another scneario, I want to open python setup after checking if it is installed or not.</p>
<p>I used this command </p>
<p><code>python --version || path/to/python_install.exe</code></p>
<p>as I know the || means run if the last command f... | 359,097 | 9,494,140 | 2024-01-02 06:26:28 | 56,722,776 | 12 | 2019-06-23 09:57:26 | 9,494,140 | 2019-06-27 06:15:41 | https://stackoverflow.com/q/56715476 | https://stackoverflow.com/a/56722776 | <p>All of the comments guided me to the right way to do it.</p>
<p>I used this great working code:</p>
<pre><code>:: Check for Python Installation
python --version 3>NUL
if errorlevel 1 goto errorNoPython
:: Reaching here means Python is installed.
:: Execute stuff...
:: Once done, exit the batch file -- skips e... | <p>All of the comments guided me to the right way to do it.</p> <p>I used this great working code:</p> <pre><code>:: Check for Python Installation python --version 3>NUL if errorlevel 1 goto errorNoPython :: Reaching here means Python is installed. :: Execute stuff... :: Once done, exit the batch file -- skips e... | 64, 2631 | cmd, windows | <h1>How do I test if Python is installed on Windows (10), and run an exe to install it if its not installed?</h1>
<p>I need to run the 2nd command on windows cmd only if the 1st one fails,
in another scneario, I want to open python setup after checking if it is installed or not.</p>
<p>I used this command </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,451 | cmd | # How do I test if Python is installed on Windows (10), and run an exe to install it if its not installed?
I need to run the 2nd command on windows cmd only if the 1st one fails,
in another scneario, I want to open python setup after checking if it is installed or not.
I used this command
`python --version || path/t... | All of the comments guided me to the right way to do it.
I used this great working code:
```
:: Check for Python Installation
python --version 3>NUL
if errorlevel 1 goto errorNoPython
:: Reaching here means Python is installed.
:: Execute stuff...
:: Once done, exit the batch file -- skips executing the errorNoPyth... |
20892882 | Set errorlevel in Windows batch file | 23 | 2014-01-02 22:11:21 | <p>I am writing a batch script that will loop through each line of a text file, (each line containing a filename) check if the file exists and then runs the file and moves it.</p>
<p>Here is my batch script:</p>
<pre><code>REM Loop through each line of input.txt
FOR /F "tokens=1-3 delims=, " %%i IN (./ready/input.txt... | 104,228 | 1,342,249 | 2023-12-12 00:35:43 | 20,894,271 | 12 | 2014-01-03 00:08:20 | 2,128,947 | 2014-01-03 00:08:20 | https://stackoverflow.com/q/20892882 | https://stackoverflow.com/a/20894271 | <pre class="lang-dos prettyprint-override"><code>@ECHO OFF
SETLOCAL
DEL output.txt 2>nul
REM Loop through each line of input.txt
FOR /F "tokens=1-3 delims=, " %%i IN (.\ready\input.txt) DO (
ECHO.
ECHO.
ECHO.
ECHO Check %%i exists, set error flag if it doesnt
if exist .\ready\%%i (set "errorflag=") ELSE (s... | <pre class="lang-dos prettyprint-override"><code>@ECHO OFF SETLOCAL DEL output.txt 2>nul REM Loop through each line of input.txt FOR /F "tokens=1-3 delims=, " %%i IN (.\ready\input.txt) DO ( ECHO. ECHO. ECHO. ECHO Check %%i exists, set error flag if it doesnt if exist .\ready\%%i (set "errorflag=") ELSE (s... | 7002 | batch-file | <h1>Set errorlevel in Windows batch file</h1>
<p>I am writing a batch script that will loop through each line of a text file, (each line containing a filename) check if the file exists and then runs the file and moves it.</p>
<p>Here is my batch script:</p>
<pre><code>REM Loop through each line of input.txt
FOR /F "t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,452 | cmd | # Set errorlevel in Windows batch file
I am writing a batch script that will loop through each line of a text file, (each line containing a filename) check if the file exists and then runs the file and moves it.
Here is my batch script:
```
REM Loop through each line of input.txt
FOR /F "tokens=1-3 delims=, " %%i IN... | ```
@ECHO OFF
SETLOCAL
DEL output.txt 2>nul
REM Loop through each line of input.txt
FOR /F "tokens=1-3 delims=, " %%i IN (.\ready\input.txt) DO (
ECHO.
ECHO.
ECHO.
ECHO Check %%i exists, set error flag if it doesnt
if exist .\ready\%%i (set "errorflag=") ELSE (set errorflag=2)
CALL echo return code is %%error... |
12142350 | CMD: How do I recursively remove the "Hidden"-Attribute of files and directories | 23 | 2012-08-27 12:51:00 | <p>I can't find a command or simple batch of commands to recursively remove the "Hidden"-Attribute from files and directories. All commands like "attrib" and "for" seem to skip hidden files. E.g.:</p>
<pre><code>attrib -H /S /D /L mydir
</code></pre>
<p>doesn't do anything at all, because it skips all hidden stuff. D... | 192,555 | 434,268 | 2017-12-19 07:52:00 | 12,150,188 | 12 | 2012-08-27 21:56:21 | 1,530,402 | 2012-08-27 21:56:21 | https://stackoverflow.com/q/12142350 | https://stackoverflow.com/a/12150188 | <p>Move the -h and specify that mydir is a directory</p>
<pre><code>attrib /S /D /L -H mydir\*.*
</code></pre>
| <p>Move the -h and specify that mydir is a directory</p> <pre><code>attrib /S /D /L -H mydir\*.* </code></pre> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>CMD: How do I recursively remove the "Hidden"-Attribute of files and directories</h1>
<p>I can't find a command or simple batch of commands to recursively remove the "Hidden"-Attribute from files and directories. All commands like "attrib" and "for" seem to skip hidden files. E.g.:</p>
<pre><code>attrib -H /S /D /... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,453 | cmd | # CMD: How do I recursively remove the "Hidden"-Attribute of files and directories
I can't find a command or simple batch of commands to recursively remove the "Hidden"-Attribute from files and directories. All commands like "attrib" and "for" seem to skip hidden files. E.g.:
```
attrib -H /S /D /L mydir
```
doesn't... | Move the -h and specify that mydir is a directory
```
attrib /S /D /L -H mydir\*.*
``` |
11928078 | Permanently Change Environment Variables in Windows | 22 | 2012-08-13 04:06:25 | <p>I found a way to change the default home directory of a user but I am having trouble with it. </p>
<p><img src="https://i.sstatic.net/sDfDO.jpg" alt="enter image description here"></p>
<p><img src="https://i.sstatic.net/x96CK.png" alt="enter image description here"></p>
<p><img src="https://i.sstatic.net/ekSyc.pn... | 67,268 | 1,294,207 | 2024-07-29 03:13:24 | 12,064,431 | 12 | 2012-08-21 23:20:01 | 1,368,730 | 2012-08-21 23:20:01 | https://stackoverflow.com/q/11928078 | https://stackoverflow.com/a/12064431 | <p>Nowhere does it mention a dependency between the HOMEDRIVE value and the HOMEDIRECTORY value, what was happening (I think) is that it was failing to map the home directory to the HOMEDRIVE and therefore defaulting back to a safe value (C:)</p>
<p>I wrote a script to update the local AD, replace the values in [] wit... | <p>Nowhere does it mention a dependency between the HOMEDRIVE value and the HOMEDIRECTORY value, what was happening (I think) is that it was failing to map the home directory to the HOMEDRIVE and therefore defaulting back to a safe value (C:)</p> <p>I wrote a script to update the local AD, replace the values in [] wit... | 64, 2631, 9013 | cmd, environment-variables, windows | <h1>Permanently Change Environment Variables in Windows</h1>
<p>I found a way to change the default home directory of a user but I am having trouble with it. </p>
<p><img src="https://i.sstatic.net/sDfDO.jpg" alt="enter image description here"></p>
<p><img src="https://i.sstatic.net/x96CK.png" alt="enter image descri... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,454 | cmd | # Permanently Change Environment Variables in Windows
I found a way to change the default home directory of a user but I am having trouble with it.


 is that it was failing to map the home directory to the HOMEDRIVE and therefore defaulting back to a safe value (C:)
I wrote a script to update the local AD, replace the values in [] with your val... |
15885338 | Using Batch file SHIFT command | 19 | 2013-04-08 17:31:19 | <p>I'm trying to display up to 9 parameters across the screen, and then display one fewer on each following line, until there are none left.</p>
<p>I tried this:</p>
<pre><code>@echo off
echo %*
shift
echo %*
shift
echo %*
</code></pre>
<p>Actual Result:</p>
<pre><code> a b c d e f
a b c d e f
</code></pre>
<p>Exp... | 33,389 | 2,251,341 | 2024-07-19 02:11:32 | 15,885,438 | 12 | 2013-04-08 17:38:41 | 479,869 | 2013-04-08 17:38:41 | https://stackoverflow.com/q/15885338 | https://stackoverflow.com/a/15885438 | <p>Shift doesn't change the actual order, just the index/pointer into the arguments.</p>
<p>Try this:</p>
<pre><code>@echo off
echo %1
shift
echo %1
shift
echo %1
echo %*
</code></pre>
<p>And you get this:</p>
<pre><code>a
b
c
a b c d
</code></pre>
| <p>Shift doesn't change the actual order, just the index/pointer into the arguments.</p> <p>Try this:</p> <pre><code>@echo off echo %1 shift echo %1 shift echo %1 echo %* </code></pre> <p>And you get this:</p> <pre><code>a b c a b c d </code></pre> | 2631, 7002 | batch-file, cmd | <h1>Using Batch file SHIFT command</h1>
<p>I'm trying to display up to 9 parameters across the screen, and then display one fewer on each following line, until there are none left.</p>
<p>I tried this:</p>
<pre><code>@echo off
echo %*
shift
echo %*
shift
echo %*
</code></pre>
<p>Actual Result:</p>
<pre><code> a b c d... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,455 | cmd | # Using Batch file SHIFT command
I'm trying to display up to 9 parameters across the screen, and then display one fewer on each following line, until there are none left.
I tried this:
```
@echo off
echo %*
shift
echo %*
shift
echo %*
```
Actual Result:
```
a b c d e f
a b c d e f
```
Expected Result:
```
... | Shift doesn't change the actual order, just the index/pointer into the arguments.
Try this:
```
@echo off
echo %1
shift
echo %1
shift
echo %1
echo %*
```
And you get this:
```
a
b
c
a b c d
``` |
18883892 | batch file (windows cmd.exe) test if a directory is a link (symlink) | 17 | 2013-09-18 23:17:55 | <p>I learned just now that this is a way to test in a batch file if a file is a link:</p>
<pre><code>dir %filename% | find "<SYMLINK>" && (
do stuff
)
</code></pre>
<p>How can I do a similar trick for testing if a directory is a symlink. It doesn't work to just replace <code><SYMLINK></code>... | 25,265 | 554,807 | 2021-08-31 20:47:03 | 18,884,678 | 12 | 2013-09-19 00:57:27 | 2,098,699 | 2013-09-19 00:57:27 | https://stackoverflow.com/q/18883892 | https://stackoverflow.com/a/18884678 | <p>general code:</p>
<pre><code>fsutil reparsepoint query "folder name" | find "Symbolic Link" >nul && echo symbolic link found || echo No symbolic link
</code></pre>
<hr>
<p>figure out, if the current folder is a symlink:</p>
<pre><code>fsutil reparsepoint query "." | find "Symbolic Link" >nul &&... | <p>general code:</p> <pre><code>fsutil reparsepoint query "folder name" | find "Symbolic Link" >nul && echo symbolic link found || echo No symbolic link </code></pre> <hr> <p>figure out, if the current folder is a symlink:</p> <pre><code>fsutil reparsepoint query "." | find "Symbolic Link" >nul &&... | 64, 218, 1122, 7002 | batch-file, directory, symlink, windows | <h1>batch file (windows cmd.exe) test if a directory is a link (symlink)</h1>
<p>I learned just now that this is a way to test in a batch file if a file is a link:</p>
<pre><code>dir %filename% | find "<SYMLINK>" && (
do stuff
)
</code></pre>
<p>How can I do a similar trick for testing if a director... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,456 | cmd | # batch file (windows cmd.exe) test if a directory is a link (symlink)
I learned just now that this is a way to test in a batch file if a file is a link:
```
dir %filename% | find "<SYMLINK>" && (
do stuff
)
```
How can I do a similar trick for testing if a directory is a symlink. It doesn't work to just replace... | general code:
```
fsutil reparsepoint query "folder name" | find "Symbolic Link" >nul && echo symbolic link found || echo No symbolic link
```
---
figure out, if the current folder is a symlink:
```
fsutil reparsepoint query "." | find "Symbolic Link" >nul && echo symbolic link found || echo No symbolic link
```
-... |
5951427 | Run Spring Batch Job programmatically? | 15 | 2011-05-10 14:14:41 | <p>I have a Spring Batch application, which I start with the <code>CommandLineJobRunner</code>. But now I have to embed this application into our corporate environment. There we have an own Launcher application which I have to use. For this launcher application I need a startup class with a main method which will be ca... | 39,010 | 465,223 | 2025-06-26 12:06:40 | 5,951,568 | 12 | 2011-05-10 14:24:45 | 719,292 | 2025-06-26 12:06:40 | https://stackoverflow.com/q/5951427 | https://stackoverflow.com/a/5951568 | <p>Yes, you can launch your job programmatically. If you see in the <a href="https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java" rel="nofollow noreferrer">source of <code>CommandLineJobRunner</code></a>, the m... | <p>Yes, you can launch your job programmatically. If you see in the <a href="https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java" rel="nofollow noreferrer">source of <code>CommandLineJobRunner</code></a>, the m... | 17, 41895 | java, spring-batch | <h1>Run Spring Batch Job programmatically?</h1>
<p>I have a Spring Batch application, which I start with the <code>CommandLineJobRunner</code>. But now I have to embed this application into our corporate environment. There we have an own Launcher application which I have to use. For this launcher application I need a s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,457 | cmd | # Run Spring Batch Job programmatically?
I have a Spring Batch application, which I start with the `CommandLineJobRunner`. But now I have to embed this application into our corporate environment. There we have an own Launcher application which I have to use. For this launcher application I need a startup class with a ... | Yes, you can launch your job programmatically. If you see in the [source of `CommandLineJobRunner`](https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java), the main method just create a Spring context and use the... |
4786301 | Double-Loop in msbuild? | 15 | 2011-01-24 19:39:09 | <p>I'm writing a script for msbuild which should make two batches in one step.<br>
Example: 2 ItemGroups</p>
<pre><code><ItemGroup>
<GroupOne Include="1" />
<GroupOne Include="2" />
</ItemGroup>
<ItemGroup>
<GroupTwo Include="A" />
<GroupTwo Include="B" />
</ItemGroup&... | 3,888 | 309,821 | 2017-12-04 12:48:06 | 4,787,582 | 12 | 2011-01-24 21:50:29 | 304,748 | 2011-01-24 21:50:29 | https://stackoverflow.com/q/4786301 | https://stackoverflow.com/a/4787582 | <p>Try this to create a new ItemGroup using the identity from group 1 and assigning metadata to the new item group from the identity (or any other metadata) of group 2. Then use batching to iterate over the new group.</p>
<pre><code><CreateItem Include="@(GroupOne)" AdditionalMetadata="Option1=%(GroupTwo.Identity)"... | <p>Try this to create a new ItemGroup using the identity from group 1 and assigning metadata to the new item group from the identity (or any other metadata) of group 2. Then use batching to iterate over the new group.</p> <pre><code><CreateItem Include="@(GroupOne)" AdditionalMetadata="Option1=%(GroupTwo.Identity)"... | 265, 3610, 7002 | batch-file, msbuild, nested | <h1>Double-Loop in msbuild?</h1>
<p>I'm writing a script for msbuild which should make two batches in one step.<br>
Example: 2 ItemGroups</p>
<pre><code><ItemGroup>
<GroupOne Include="1" />
<GroupOne Include="2" />
</ItemGroup>
<ItemGroup>
<GroupTwo Include="A" />
<GroupTwo ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,458 | cmd | # Double-Loop in msbuild?
I'm writing a script for msbuild which should make two batches in one step.
Example: 2 ItemGroups
```
<ItemGroup>
<GroupOne Include="1" />
<GroupOne Include="2" />
</ItemGroup>
<ItemGroup>
<GroupTwo Include="A" />
<GroupTwo Include="B" />
</ItemGroup>
```
These two groups should be l... | Try this to create a new ItemGroup using the identity from group 1 and assigning metadata to the new item group from the identity (or any other metadata) of group 2. Then use batching to iterate over the new group.
```
<CreateItem Include="@(GroupOne)" AdditionalMetadata="Option1=%(GroupTwo.Identity)">
<Output Ite... |
29496 | Automated script to zip IIS logs? | 15 | 2008-08-27 04:08:39 | <p>I'd like to write a script/batch that will bunch up my daily IIS logs and zip them up by month.</p>
<p>ex080801.log which is in the format of ex<em>yymmdd</em>.log</p>
<p>ex080801.log - ex080831.log gets zipped up and the log files deleted.</p>
<p>The reason we do this is because on a heavy site a log file for on... | 30,215 | 648 | 2014-02-19 09:27:26 | 29,609 | 12 | 2008-08-27 06:00:40 | 2,783 | 2008-08-27 06:00:40 | https://stackoverflow.com/q/29496 | https://stackoverflow.com/a/29609 | <p>You'll need a command line tool to zip up the files. I recommend <a href="http://www.7-zip.org/download.html" rel="noreferrer">7-Zip</a> which is free and easy to use. The self-contained command line version (7za.exe) is the most portable choice.</p>
<p>Here's a two-line batch file that would zip the log files and ... | <p>You'll need a command line tool to zip up the files. I recommend <a href="http://www.7-zip.org/download.html" rel="noreferrer">7-Zip</a> which is free and easy to use. The self-contained command line version (7za.exe) is the most portable choice.</p> <p>Here's a two-line batch file that would zip the log files and ... | 215, 531, 881, 942, 7002 | batch-file, iis, logging, scripting, zip | <h1>Automated script to zip IIS logs?</h1>
<p>I'd like to write a script/batch that will bunch up my daily IIS logs and zip them up by month.</p>
<p>ex080801.log which is in the format of ex<em>yymmdd</em>.log</p>
<p>ex080801.log - ex080831.log gets zipped up and the log files deleted.</p>
<p>The reason we do this i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,459 | cmd | # Automated script to zip IIS logs?
I'd like to write a script/batch that will bunch up my daily IIS logs and zip them up by month.
ex080801.log which is in the format of ex*yymmdd*.log
ex080801.log - ex080831.log gets zipped up and the log files deleted.
The reason we do this is because on a heavy site a log file ... | You'll need a command line tool to zip up the files. I recommend [7-Zip](http://www.7-zip.org/download.html) which is free and easy to use. The self-contained command line version (7za.exe) is the most portable choice.
Here's a two-line batch file that would zip the log files and delete them afterwards:
```
7za.exe a... |
55290596 | Solving SLURM "sbatch: error: Batch job submission failed: Requested node configuration is not available" error | 14 | 2019-03-21 23:13:59 | <p>We have a 4 GPU nodes with 2 36-core CPUs and 200 GB of RAM available at our local cluster. When I'm trying to submit a job with the follwoing configuration:</p>
<pre><code>#SBATCH --nodes=1
#SBATCH --ntasks=40
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=1500MB
#SBATCH --gres=gpu:4
#SBATCH --time=0-10:00:00
</c... | 55,833 | 2,104,784 | 2025-07-03 19:47:51 | 55,418,390 | 12 | 2019-03-29 13:22:35 | 1,763,614 | 2019-03-29 13:22:35 | https://stackoverflow.com/q/55290596 | https://stackoverflow.com/a/55418390 | <p>The CPUs are most likely 36-threads not 36-cores and Slurm is probably configured to allocate cores and not threads.</p>
<p>Check the output of <code>scontrol show nodes</code> to see what the nodes really offer.</p>
| <p>The CPUs are most likely 36-threads not 36-cores and Slurm is probably configured to allocate cores and not threads.</p> <p>Check the output of <code>scontrol show nodes</code> to see what the nodes really offer.</p> | 9228, 30645, 97759 | batch-processing, cluster-computing, slurm | <h1>Solving SLURM "sbatch: error: Batch job submission failed: Requested node configuration is not available" error</h1>
<p>We have a 4 GPU nodes with 2 36-core CPUs and 200 GB of RAM available at our local cluster. When I'm trying to submit a job with the follwoing configuration:</p>
<pre><code>#SBATCH --nodes=1
#SBA... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,460 | cmd | # Solving SLURM "sbatch: error: Batch job submission failed: Requested node configuration is not available" error
We have a 4 GPU nodes with 2 36-core CPUs and 200 GB of RAM available at our local cluster. When I'm trying to submit a job with the follwoing configuration:
```
#SBATCH --nodes=1
#SBATCH --ntasks=40
#SBA... | The CPUs are most likely 36-threads not 36-cores and Slurm is probably configured to allocate cores and not threads.
Check the output of `scontrol show nodes` to see what the nodes really offer. |
21694861 | How to pass more than 9 parameters to batch file | 14 | 2014-02-11 06:37:33 | <p>How can I pass more than nine parameters to bach file.<br>
I tried another SO question
<a href="https://stackoverflow.com/questions/8328338/how-do-you-utilize-more-than-9-arguments-when-calling-a-label-in-a-cmd-batch-scr/8328669#8328669">How do you utilize more than 9 arguments when calling a label in a CMD batch-s... | 27,840 | 1,989,988 | 2024-07-22 21:18:53 | 21,695,048 | 12 | 2014-02-11 06:50:30 | 447,503 | 2014-02-11 06:50:30 | https://stackoverflow.com/q/21694861 | https://stackoverflow.com/a/21695048 | <p>save the first nine args in a variable. THEN call shift multiple times and only then use the rest:</p>
<pre><code>set "v=http://example.com?firstName=%1&middleName=%2&lastName=%3&country=%4&address=%5&address2=%6&address3=%7&mobileNo=%8&landlineNo=%9"
shift
shift
shift
shift
shift
sh... | <p>save the first nine args in a variable. THEN call shift multiple times and only then use the rest:</p> <pre><code>set "v=http://example.com?firstName=%1&middleName=%2&lastName=%3&country=%4&address=%5&address2=%6&address3=%7&mobileNo=%8&landlineNo=%9" shift shift shift shift shift sh... | 7002 | batch-file | <h1>How to pass more than 9 parameters to batch file</h1>
<p>How can I pass more than nine parameters to bach file.<br>
I tried another SO question
<a href="https://stackoverflow.com/questions/8328338/how-do-you-utilize-more-than-9-arguments-when-calling-a-label-in-a-cmd-batch-scr/8328669#8328669">How do you utilize m... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,461 | cmd | # How to pass more than 9 parameters to batch file
How can I pass more than nine parameters to bach file.
I tried another SO question
[How do you utilize more than 9 arguments when calling a label in a CMD batch-script?](https://stackoverflow.com/questions/8328338/how-do-you-utilize-more-than-9-arguments-when-callin... | save the first nine args in a variable. THEN call shift multiple times and only then use the rest:
```
set "v=http://example.com?firstName=%1&middleName=%2&lastName=%3&country=%4&address=%5&address2=%6&address3=%7&mobileNo=%8&landlineNo=%9"
shift
shift
shift
shift
shift
shift
shift
shift
shift
start iexplore %v%&email... |
5949775 | windows bat file error | 14 | 2011-05-10 12:07:38 | <p>i try to launch a BAT file on a network share but i get this error:</p>
<pre><code>'\\dev\applets'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
</code></pre>
<p>is there a workaround for this?</p>
<p>thanks!</p>
| 20,454 | 97,688 | 2022-11-19 13:34:36 | 5,949,895 | 12 | 2011-05-10 12:18:46 | 669,202 | 2011-05-10 12:18:46 | https://stackoverflow.com/q/5949775 | https://stackoverflow.com/a/5949895 | <p>Do you have a chance to mount the network share first?</p>
<pre><code>net use \\dev\applets z:
z:\mybatchfile.bat
</code></pre>
| <p>Do you have a chance to mount the network share first?</p> <pre><code>net use \\dev\applets z: z:\mybatchfile.bat </code></pre> | 7002 | batch-file | <h1>windows bat file error</h1>
<p>i try to launch a BAT file on a network share but i get this error:</p>
<pre><code>'\\dev\applets'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
</code></pre>
<p>is there a workaround for 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,462 | cmd | # windows bat file error
i try to launch a BAT file on a network share but i get this error:
```
'\\dev\applets'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
```
is there a workaround for this?
thanks! | Do you have a chance to mount the network share first?
```
net use \\dev\applets z:
z:\mybatchfile.bat
``` |
721251 | How to use newline character in text in cmd batch? | 14 | 2009-04-06 12:41:40 | <p>I would like to do </p>
<pre><code>svn commit -m "<message>"
</code></pre>
<p>But message should have two lines:</p>
<pre><code>Commit by: firstuser
Bug track: 9283
</code></pre>
<p>How to add new line character into message? I've tried SHIFT+ENTER, CTRL+T but it does not work. I use MS cmd command line.</... | 41,097 | 38,940 | 2022-10-14 11:26:53 | 722,345 | 12 | 2009-04-06 17:09:43 | 2,441 | 2012-12-14 12:40:02 | https://stackoverflow.com/q/721251 | https://stackoverflow.com/a/722345 | <p>How about using the <code>-F</code> parameter to get the log message from a file?</p>
<p>Then, you could do this (untested):</p>
<pre><code>ECHO Commit by: firstuser>SvnLog.txt
ECHO Bug track: 9283>>SvnLog.txt
SVN COMMIT -F SvnLog.txt
</code></pre>
| <p>How about using the <code>-F</code> parameter to get the log message from a file?</p> <p>Then, you could do this (untested):</p> <pre><code>ECHO Commit by: firstuser>SvnLog.txt ECHO Bug track: 9283>>SvnLog.txt SVN COMMIT -F SvnLog.txt </code></pre> | 63, 7002 | batch-file, svn | <h1>How to use newline character in text in cmd batch?</h1>
<p>I would like to do </p>
<pre><code>svn commit -m "<message>"
</code></pre>
<p>But message should have two lines:</p>
<pre><code>Commit by: firstuser
Bug track: 9283
</code></pre>
<p>How to add new line character into message? I've tried SHIFT+ENTE... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,463 | cmd | # How to use newline character in text in cmd batch?
I would like to do
```
svn commit -m "<message>"
```
But message should have two lines:
```
Commit by: firstuser
Bug track: 9283
```
How to add new line character into message? I've tried SHIFT+ENTER, CTRL+T but it does not work. I use MS cmd command line. | How about using the `-F` parameter to get the log message from a file?
Then, you could do this (untested):
```
ECHO Commit by: firstuser>SvnLog.txt
ECHO Bug track: 9283>>SvnLog.txt
SVN COMMIT -F SvnLog.txt
``` |
66047161 | getting exit status 1 when I run the command nvm use 12.18.0 | 13 | 2021-02-04 13:59:44 | <p>I have installed nvm on my windows machine and with nvm, I installed 2 node versions but it's not letting me change the version.</p>
<pre><code>Microsoft Windows [Version 10.0.16299.64]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Windows\system32>nvm use 12.18.0
exit status 1: 'C:\Users\Sarmad' is no... | 44,367 | 9,934,362 | 2024-06-27 03:24:17 | 68,682,771 | 12 | 2021-08-06 13:52:57 | 5,002,600 | 2023-01-30 12:11:29 | https://stackoverflow.com/q/66047161 | https://stackoverflow.com/a/68682771 | <p>Ali you are getting this error because you are installing nvm in the default location. And that is your user's directory. Nvm for windows is an attempt to port from the linux and currently does not support spaces in the path.</p>
<p>I spent several hours trying to figure this out and none of these solutions work for... | <p>Ali you are getting this error because you are installing nvm in the default location. And that is your user's directory. Nvm for windows is an attempt to port from the linux and currently does not support spaces in the path.</p> <p>I spent several hours trying to figure this out and none of these solutions work for... | 2631, 46426, 81748 | cmd, node.js, nvm | <h1>getting exit status 1 when I run the command nvm use 12.18.0</h1>
<p>I have installed nvm on my windows machine and with nvm, I installed 2 node versions but it's not letting me change the version.</p>
<pre><code>Microsoft Windows [Version 10.0.16299.64]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Wind... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,464 | cmd | # getting exit status 1 when I run the command nvm use 12.18.0
I have installed nvm on my windows machine and with nvm, I installed 2 node versions but it's not letting me change the version.
```
Microsoft Windows [Version 10.0.16299.64]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Windows\system32>nvm us... | Ali you are getting this error because you are installing nvm in the default location. And that is your user's directory. Nvm for windows is an attempt to port from the linux and currently does not support spaces in the path.
I spent several hours trying to figure this out and none of these solutions work for me. If y... |
7029975 | Batch file setting double quote a variable | 13 | 2011-08-11 17:04:19 | <p>In a Windows XP .bat file, how do I set a variable value to use double quote? I couldn't find special characters for batch file.</p>
<pre><code>SET myVariable= " \"myValue \" "
</code></pre>
| 29,976 | 522,410 | 2011-08-11 19:26:06 | 7,030,746 | 12 | 2011-08-11 18:09:08 | 7,903 | 2011-08-11 18:09:08 | https://stackoverflow.com/q/7029975 | https://stackoverflow.com/a/7030746 | <p>If this is for Windows, you need to escape the double quotes with a caret (<code>^</code>):</p>
<pre><code>set myVariable=^"myVlaue^"
</code></pre>
<p>Putting single quotes around the value won't work, the value will include the single and double quotes.</p>
| <p>If this is for Windows, you need to escape the double quotes with a caret (<code>^</code>):</p> <pre><code>set myVariable=^"myVlaue^" </code></pre> <p>Putting single quotes around the value won't work, the value will include the single and double quotes.</p> | 64, 1231, 7002 | batch-file, command-line, windows | <h1>Batch file setting double quote a variable</h1>
<p>In a Windows XP .bat file, how do I set a variable value to use double quote? I couldn't find special characters for batch file.</p>
<pre><code>SET myVariable= " \"myValue \" "
</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,465 | cmd | # Batch file setting double quote a variable
In a Windows XP .bat file, how do I set a variable value to use double quote? I couldn't find special characters for batch file.
```
SET myVariable= " \"myValue \" "
``` | If this is for Windows, you need to escape the double quotes with a caret (`^`):
```
set myVariable=^"myVlaue^"
```
Putting single quotes around the value won't work, the value will include the single and double quotes. |
227288 | How to automate JavaScript files compression with YUI Compressor? | 13 | 2008-10-22 19:51:35 | <p><a href="http://developer.yahoo.com/yui/compressor/" rel="nofollow noreferrer">YUI Compressor</a> does not accept wildcard parameters, so I cannot run it like this: </p>
<pre><code>C:>java -jar yuicompressor.jar *.js
</code></pre>
<p>But I have over 500 files and would rather not have to create a batch file li... | 8,347 | 28,098 | 2012-05-03 09:09:08 | 227,336 | 12 | 2008-10-22 20:05:49 | 12,711 | 2008-10-22 20:33:55 | https://stackoverflow.com/q/227288 | https://stackoverflow.com/a/227336 | <p>I might go for a makefile (I think it would probably be more maintainable long term), but if you want a quick-n-dirty Windows batch command something like the following should work:</p>
<pre><code>for %%a in (*.js) do @java -jar yuicompressor.jar "%%a" -o "deploy\%%a"
</code></pre>
| <p>I might go for a makefile (I think it would probably be more maintainable long term), but if you want a quick-n-dirty Windows batch command something like the following should work:</p> <pre><code>for %%a in (*.js) do @java -jar yuicompressor.jar "%%a" -o "deploy\%%a" </code></pre> | 3, 1269, 7002 | batch-file, javascript, yui | <h1>How to automate JavaScript files compression with YUI Compressor?</h1>
<p><a href="http://developer.yahoo.com/yui/compressor/" rel="nofollow noreferrer">YUI Compressor</a> does not accept wildcard parameters, so I cannot run it like this: </p>
<pre><code>C:>java -jar yuicompressor.jar *.js
</code></pre>
<p>Bu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,466 | cmd | # How to automate JavaScript files compression with YUI Compressor?
[YUI Compressor](http://developer.yahoo.com/yui/compressor/) does not accept wildcard parameters, so I cannot run it like this:
```
C:>java -jar yuicompressor.jar *.js
```
But I have over 500 files and would rather not have to create a batch file li... | I might go for a makefile (I think it would probably be more maintainable long term), but if you want a quick-n-dirty Windows batch command something like the following should work:
```
for %%a in (*.js) do @java -jar yuicompressor.jar "%%a" -o "deploy\%%a"
``` |
28889166 | Do batch files support exit traps? | 12 | 2015-03-05 22:36:50 | <p>Do Windows .bat scripts have an exit-trap like feature, that would allow registration of cleanup actions that always need to be run?</p>
<p>I am not interested in any solution that uses Powershell or other shells (I already have Python installed on the target system so if that can't be done in batch files I'll just... | 10,081 | 378,080 | 2016-07-26 11:24:45 | 28,890,881 | 12 | 2015-03-06 01:21:46 | 1,012,053 | 2016-07-26 11:24:45 | https://stackoverflow.com/q/28889166 | https://stackoverflow.com/a/28890881 | <p>No, there are no exceptions, and no formal way of registering an exit routine to run automatically upon termination.</p>
<p>However, you can get close if you do not need environment changes to persist after the script terminates. You can run the majority of your script in a new CMD session, and then you can have cl... | <p>No, there are no exceptions, and no formal way of registering an exit routine to run automatically upon termination.</p> <p>However, you can get close if you do not need environment changes to persist after the script terminates. You can run the majority of your script in a new CMD session, and then you can have cl... | 7002 | batch-file | <h1>Do batch files support exit traps?</h1>
<p>Do Windows .bat scripts have an exit-trap like feature, that would allow registration of cleanup actions that always need to be run?</p>
<p>I am not interested in any solution that uses Powershell or other shells (I already have Python installed on the target system so if... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,467 | cmd | # Do batch files support exit traps?
Do Windows .bat scripts have an exit-trap like feature, that would allow registration of cleanup actions that always need to be run?
I am not interested in any solution that uses Powershell or other shells (I already have Python installed on the target system so if that can't be d... | No, there are no exceptions, and no formal way of registering an exit routine to run automatically upon termination.
However, you can get close if you do not need environment changes to persist after the script terminates. You can run the majority of your script in a new CMD session, and then you can have cleanup rout... |
20385885 | Echo batch file arrays using a variable for the index? | 12 | 2013-12-04 21:03:02 | <p>If I have a batch file and I am setting arrays with an index that is a variable</p>
<pre><code>@echo off
SET x=1
SET myVar[%x%]=happy
</code></pre>
<p>How do I echo that to get "happy" ?</p>
<p>I've tried</p>
<pre><code>ECHO %myVar[%x%]%
ECHO %%myVar[%x%]%%
ECHO myVar[%x%]
</code></pre>
<p>But none of them work... | 40,503 | 227,664 | 2016-11-12 03:04:56 | 20,385,978 | 12 | 2013-12-04 21:07:27 | 388,389 | 2013-12-05 07:32:55 | https://stackoverflow.com/q/20385885 | https://stackoverflow.com/a/20385978 | <pre><code>SET x=1
SET myVar[%x%]=happy
call echo %%myvar[%x%]%%
set myvar[%x%]
for /f "tokens=2* delims==" %%v in ('set myvar[%x%]') do @echo %%v
setlocal enableDelayedExpansion
echo !myvar[%x%]!
endlocal
</code></pre>
<p>I would recommend you to use </p>
<pre><code>setlocal enableDelayedExpansion
echo !myvar[%x%]... | <pre><code>SET x=1 SET myVar[%x%]=happy call echo %%myvar[%x%]%% set myvar[%x%] for /f "tokens=2* delims==" %%v in ('set myvar[%x%]') do @echo %%v setlocal enableDelayedExpansion echo !myvar[%x%]! endlocal </code></pre> <p>I would recommend you to use </p> <pre><code>setlocal enableDelayedExpansion echo !myvar[%x%]... | 114, 7002, 13824 | arrays, batch-file, echo | <h1>Echo batch file arrays using a variable for the index?</h1>
<p>If I have a batch file and I am setting arrays with an index that is a variable</p>
<pre><code>@echo off
SET x=1
SET myVar[%x%]=happy
</code></pre>
<p>How do I echo that to get "happy" ?</p>
<p>I've tried</p>
<pre><code>ECHO %myVar[%x%]%
ECHO %%myVa... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,468 | cmd | # Echo batch file arrays using a variable for the index?
If I have a batch file and I am setting arrays with an index that is a variable
```
@echo off
SET x=1
SET myVar[%x%]=happy
```
How do I echo that to get "happy" ?
I've tried
```
ECHO %myVar[%x%]%
ECHO %%myVar[%x%]%%
ECHO myVar[%x%]
```
But none of them work... | ```
SET x=1
SET myVar[%x%]=happy
call echo %%myvar[%x%]%%
set myvar[%x%]
for /f "tokens=2* delims==" %%v in ('set myvar[%x%]') do @echo %%v
setlocal enableDelayedExpansion
echo !myvar[%x%]!
endlocal
```
I would recommend you to use
```
setlocal enableDelayedExpansion
echo !myvar[%x%]!
endlocal
```
as it is a best ... |
7205940 | How do I write a file whose *filename* contains utf8 characters in Perl? | 12 | 2011-08-26 14:10:38 | <p>I am struggling creating a file that contains non-ascii characters.</p>
<p>The following script works fine, if it is called with <code>0</code> as parameter but dies when called with <code>1</code>.</p>
<p>The error message is <em>open: Invalid argument at C:\temp\filename.pl line 15.</em></p>
<p>The script is st... | 8,090 | 180,275 | 2017-08-28 00:19:07 | 7,207,996 | 12 | 2011-08-26 16:48:47 | 589,924 | 2017-08-28 00:19:07 | https://stackoverflow.com/q/7205940 | https://stackoverflow.com/a/7207996 | <p>First of all, saying "UTF-8 character" is weird. UTF-8 can encode any Unicode character, so the UTF-8 character set is the Unicode character set. That means you want to create file whose name contain Unicode characters, and more specifically, Unicode characters that aren't in cp1252.</p>
<p>I've <a href="http://www... | <p>First of all, saying "UTF-8 character" is weird. UTF-8 can encode any Unicode character, so the UTF-8 character set is the Unicode character set. That means you want to create file whose name contain Unicode characters, and more specifically, Unicode characters that aren't in cp1252.</p> <p>I've <a href="http://www... | 64, 580, 1062, 2631, 8944 | cmd, filenames, perl, utf-8, windows | <h1>How do I write a file whose *filename* contains utf8 characters in Perl?</h1>
<p>I am struggling creating a file that contains non-ascii characters.</p>
<p>The following script works fine, if it is called with <code>0</code> as parameter but dies when called with <code>1</code>.</p>
<p>The error message is <em>op... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,469 | cmd | # How do I write a file whose *filename* contains utf8 characters in Perl?
I am struggling creating a file that contains non-ascii characters.
The following script works fine, if it is called with `0` as parameter but dies when called with `1`.
The error message is *open: Invalid argument at C:\temp\filename.pl line... | First of all, saying "UTF-8 character" is weird. UTF-8 can encode any Unicode character, so the UTF-8 character set is the Unicode character set. That means you want to create file whose name contain Unicode characters, and more specifically, Unicode characters that aren't in cp1252.
I've [answered](http://www.perlmon... |
16083187 | How to create a shortcut to launch an App with admin privileges from the cmd-line? | 11 | 2013-04-18 12:37:56 | <p>I have an installer (Inno-Setup) that installs my application to a path defined by the user. At the end of the install routine i want to create a shortcut that starts the application with admin privileges. The solution should work on all win version from winXP to Win7.<br>
<br>
What can i do to achieve this? <br>
<b... | 21,831 | 932,656 | 2020-11-09 15:10:49 | 16,084,732 | 12 | 2013-04-18 13:46:37 | 1,582,846 | 2013-04-18 13:46:37 | https://stackoverflow.com/q/16083187 | https://stackoverflow.com/a/16084732 | <p>You can add a registry-key that tells windows to execute your program as admin:</p>
<p>Under <code>HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers</code>, just add a key(REG_SZ) <code><Path to your exe></code> with the value <code>RUNASADMIN</code>. When you launch your exe, you will b... | <p>You can add a registry-key that tells windows to execute your program as admin:</p> <p>Under <code>HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers</code>, just add a key(REG_SZ) <code><Path to your exe></code> with the value <code>RUNASADMIN</code>. When you launch your exe, you will b... | 64, 2631, 3942, 7002, 10593 | batch-file, cmd, hyperlink, inno-setup, windows | <h1>How to create a shortcut to launch an App with admin privileges from the cmd-line?</h1>
<p>I have an installer (Inno-Setup) that installs my application to a path defined by the user. At the end of the install routine i want to create a shortcut that starts the application with admin privileges. The solution should... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,471 | cmd | # How to create a shortcut to launch an App with admin privileges from the cmd-line?
I have an installer (Inno-Setup) that installs my application to a path defined by the user. At the end of the install routine i want to create a shortcut that starts the application with admin privileges. The solution should work on ... | You can add a registry-key that tells windows to execute your program as admin:
Under `HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers`, just add a key(REG_SZ) `<Path to your exe>` with the value `RUNASADMIN`. When you launch your exe, you will be prompted for admin-access.
With that, you can ... |
510156 | Is there a way in a batch script to keep the console open only if invoked from Windows Manager? | 11 | 2009-02-04 05:20:11 | <p>I have a DOS batch script that invokes a java application which interacts with the user through the console UI. For the sake of argument, let's call it <code>runapp.bat</code> and its contents be</p>
<pre><code>java com.example.myApp
</code></pre>
<p>If the batch script is invoked in a console, everything works fi... | 18,954 | 10,026 | 2014-04-17 20:47:10 | 511,063 | 12 | 2009-02-04 12:02:44 | 7,903 | 2009-02-04 12:02:44 | https://stackoverflow.com/q/510156 | https://stackoverflow.com/a/511063 | <p>See this question: <a href="https://stackoverflow.com/questions/377407/detecting-how-a-batch-file-was-executed/377933#377933">Detecting how a batch file was executed</a></p>
<p>This script will not pause if run from the command console, but will if double-clicked in Explorer:</p>
<pre><code>@echo off
setlocal enab... | <p>See this question: <a href="https://stackoverflow.com/questions/377407/detecting-how-a-batch-file-was-executed/377933#377933">Detecting how a batch file was executed</a></p> <p>This script will not pause if run from the command console, but will if double-clicked in Explorer:</p> <pre><code>@echo off setlocal enab... | 64, 531, 1231, 5370, 7002 | batch-file, command-line, dos, scripting, windows | <h1>Is there a way in a batch script to keep the console open only if invoked from Windows Manager?</h1>
<p>I have a DOS batch script that invokes a java application which interacts with the user through the console UI. For the sake of argument, let's call it <code>runapp.bat</code> and its contents be</p>
<pre><code>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,472 | cmd | # Is there a way in a batch script to keep the console open only if invoked from Windows Manager?
I have a DOS batch script that invokes a java application which interacts with the user through the console UI. For the sake of argument, let's call it `runapp.bat` and its contents be
```
java com.example.myApp
```
If ... | See this question: [Detecting how a batch file was executed](https://stackoverflow.com/questions/377407/detecting-how-a-batch-file-was-executed/377933#377933)
This script will not pause if run from the command console, but will if double-clicked in Explorer:
```
@echo off
setlocal enableextensions
set SCRIPT=%0
set ... |
64009522 | Spring batch. How to chain multiple itemProcessors with different types? | 10 | 2020-09-22 12:14:49 | <p>i have to compose 2 processors as following :</p>
<ul>
<li><code>processor 1</code> implement the <code>itemProcessor</code> Interface with <code>itemProcessor<A,B></code> (transforming data).</li>
<li><code>processor 2</code> implement the <code>itemProcessor</code> Interface with <code>itemProcessor<B,B... | 7,947 | null | 2024-01-15 16:37:57 | 64,010,987 | 12 | 2020-09-22 13:38:50 | 5,019,386 | 2020-09-22 13:38:50 | https://stackoverflow.com/q/64009522 | https://stackoverflow.com/a/64010987 | <p>You need to declare your step as well as your composite processor with <code><A, B></code>. Here is a quick example:</p>
<pre><code>import java.util.Arrays;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.configuration.annot... | <p>You need to declare your step as well as your composite processor with <code><A, B></code>. Here is a quick example:</p> <pre><code>import java.util.Arrays; import org.springframework.batch.core.Job; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.configuration.annot... | 41895, 95875 | spring-batch, spring-boot | <h1>Spring batch. How to chain multiple itemProcessors with different types?</h1>
<p>i have to compose 2 processors as following :</p>
<ul>
<li><code>processor 1</code> implement the <code>itemProcessor</code> Interface with <code>itemProcessor<A,B></code> (transforming data).</li>
<li><code>processor 2</code> i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,473 | cmd | # Spring batch. How to chain multiple itemProcessors with different types?
i have to compose 2 processors as following :
- `processor 1` implement the `itemProcessor` Interface with `itemProcessor<A,B>` (transforming data).
- `processor 2` implement the `itemProcessor` Interface with `itemProcessor<B,B>`.(treat trans... | You need to declare your step as well as your composite processor with `<A, B>`. Here is a quick example:
```
import java.util.Arrays;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
i... |
60544671 | Cannot install sdkmanager in windows 10 | 10 | 2020-03-05 11:44:37 | <p>I am trying to install the sdk manager alone for using it with Eclipse. I downloaded the zip file provided by google - </p>
<p>commandlinetools-win-6200805_latest.zip </p>
<p>from <a href="https://developer.android.com/studio" rel="noreferrer">https://developer.android.com/studio</a></p>
<p>But as I try to run th... | 11,458 | 6,904,762 | 2021-03-11 05:55:51 | 60,600,600 | 12 | 2020-03-09 12:29:17 | 5,107,788 | 2020-03-09 12:29:17 | https://stackoverflow.com/q/60544671 | https://stackoverflow.com/a/60600600 | <h3>TL;DR;</h3>
<ul>
<li>copy the content of <code>tools/lib/_</code> to <code>tools/lib</code></li>
<li>run <code>sdkmanager</code> commands with <code>--sdk_root</code> parameter.</li>
</ul>
<h3>Details</h3>
<p>In the line 66 of the sdkmanager.bat, CLASSPATH is defined to be like this</p>
<pre><code>set CLASSPATH... | <h3>TL;DR;</h3> <ul> <li>copy the content of <code>tools/lib/_</code> to <code>tools/lib</code></li> <li>run <code>sdkmanager</code> commands with <code>--sdk_root</code> parameter.</li> </ul> <h3>Details</h3> <p>In the line 66 of the sdkmanager.bat, CLASSPATH is defined to be like this</p> <pre><code>set CLASSPATH... | 759, 1386, 7002 | android, batch-file, sdk | <h1>Cannot install sdkmanager in windows 10</h1>
<p>I am trying to install the sdk manager alone for using it with Eclipse. I downloaded the zip file provided by google - </p>
<p>commandlinetools-win-6200805_latest.zip </p>
<p>from <a href="https://developer.android.com/studio" rel="noreferrer">https://developer.andr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,474 | cmd | # Cannot install sdkmanager in windows 10
I am trying to install the sdk manager alone for using it with Eclipse. I downloaded the zip file provided by google -
commandlinetools-win-6200805_latest.zip
from <https://developer.android.com/studio>
But as I try to run the sdkmanager.bat file it doesn't run and i am get... | ### TL;DR;
- copy the content of `tools/lib/_` to `tools/lib`
- run `sdkmanager` commands with `--sdk_root` parameter.
### Details
In the line 66 of the sdkmanager.bat, CLASSPATH is defined to be like this
```
set CLASSPATH=%APP_HOME%\lib\/sdkmanager-classpath.jar
```
and inside the lib directory, `sdkmanager-clas... |
46681881 | Visual studio 2017 Developer Command Prompt switches current directory | 10 | 2017-10-11 07:06:37 | <p>I am getting weird behavior of "Developer Command Prompt for VS 2017" command line tool. Normally in previous versions of visual studio this script (VsDevCmd.bat) was not messing current directory from where you run it. Now it seems to change it. One simple workflow would be just to start the shortcut "Developer Com... | 7,091 | 575,437 | 2018-08-26 14:59:21 | 46,682,300 | 12 | 2017-10-11 07:29:05 | 21,567 | 2017-10-11 07:29:05 | https://stackoverflow.com/q/46681881 | https://stackoverflow.com/a/46682300 | <p>You can set the <code>VSCMD_START_DIR</code> environment variable to have <code>vsdevcmd.bat</code> change to that directory when it finishes. Otherwise it will check if you have a <code>%USERPROFILE%\source</code> directory and change to that (which is what you see).</p>
<p>You can change the "Target" for the "Dev... | <p>You can set the <code>VSCMD_START_DIR</code> environment variable to have <code>vsdevcmd.bat</code> change to that directory when it finishes. Otherwise it will check if you have a <code>%USERPROFILE%\source</code> directory and change to that (which is what you see).</p> <p>You can change the "Target" for the "Dev... | 265, 2631, 10201, 123095 | cmd, msbuild, visual-studio-2017, working-directory | <h1>Visual studio 2017 Developer Command Prompt switches current directory</h1>
<p>I am getting weird behavior of "Developer Command Prompt for VS 2017" command line tool. Normally in previous versions of visual studio this script (VsDevCmd.bat) was not messing current directory from where you run it. Now it seems to c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,475 | cmd | # Visual studio 2017 Developer Command Prompt switches current directory
I am getting weird behavior of "Developer Command Prompt for VS 2017" command line tool. Normally in previous versions of visual studio this script (VsDevCmd.bat) was not messing current directory from where you run it. Now it seems to change it.... | You can set the `VSCMD_START_DIR` environment variable to have `vsdevcmd.bat` change to that directory when it finishes. Otherwise it will check if you have a `%USERPROFILE%\source` directory and change to that (which is what you see).
You can change the "Target" for the "Developer Command Prompt for VS 2017" to somet... |
45442830 | How to open a specific excel file with a batch script and command line arguments? | 10 | 2017-08-01 16:14:25 | <p>I designed an excel spreadsheet that takes data from a server using an RTD feed and processes it. I want the excel file to open automatically during the computers startup. The way that I have decided to go about doing this is to write a batch script that opens the excel file and to then put that batch script in the ... | 114,861 | 7,871,710 | 2024-03-13 20:45:14 | 45,446,725 | 12 | 2017-08-01 20:02:19 | 3,191,482 | 2017-08-01 20:02:19 | https://stackoverflow.com/q/45442830 | https://stackoverflow.com/a/45446725 | <pre><code>@echo off
set params=%*
start excel "MyWorkbook.xlsm" /e/%params%
</code></pre>
<p>Let's suppose you named it "MyBatch.bat", then you call it like this:</p>
<pre><code>MyBatch.bat Hello/World1
</code></pre>
<p>Use space " " to separate parameters.
Use slash "/" instead of space for parameters with spaces.... | <pre><code>@echo off set params=%* start excel "MyWorkbook.xlsm" /e/%params% </code></pre> <p>Let's suppose you named it "MyBatch.bat", then you call it like this:</p> <pre><code>MyBatch.bat Hello/World1 </code></pre> <p>Use space " " to separate parameters. Use slash "/" instead of space for parameters with spaces.... | 64, 522, 7002 | batch-file, excel, windows | <h1>How to open a specific excel file with a batch script and command line arguments?</h1>
<p>I designed an excel spreadsheet that takes data from a server using an RTD feed and processes it. I want the excel file to open automatically during the computers startup. The way that I have decided to go about doing this is ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,476 | cmd | # How to open a specific excel file with a batch script and command line arguments?
I designed an excel spreadsheet that takes data from a server using an RTD feed and processes it. I want the excel file to open automatically during the computers startup. The way that I have decided to go about doing this is to write ... | ```
@echo off
set params=%*
start excel "MyWorkbook.xlsm" /e/%params%
```
Let's suppose you named it "MyBatch.bat", then you call it like this:
```
MyBatch.bat Hello/World1
```
Use space " " to separate parameters.
Use slash "/" instead of space for parameters with spaces.
In case you do not like the string I belie... |
41777585 | Running JavaScript from the windows command prompt | 10 | 2017-01-21 09:13:07 | <p>I wrote the following JavaScipt code which converts a binary number into a decimal number:</p>
<pre><code>(function bin_dec(num) {
var x = num;
var result = 0;
for (var i = 0; i < x.length; i++) {
result += eval(x[x.length - i] * 2^i);
}
return result;
})()
</code></pre>
<p>I want to be able to ru... | 46,926 | 6,649,786 | 2017-01-21 09:36:08 | 41,777,656 | 12 | 2017-01-21 09:22:17 | 1,083,663 | 2017-01-21 09:22:17 | https://stackoverflow.com/q/41777585 | https://stackoverflow.com/a/41777656 | <p>1) Install <a href="https://nodejs.org/" rel="noreferrer">Node.js</a> if you haven't done so yet.</p>
<p>2) Change your <code>converter.js</code> file like this:</p>
<pre><code>function bin_dec(num) {
return parseInt(num, 2);
}
console.log(bin_dec(process.argv[2]));
</code></pre>
<p>3) Open a new command promp... | <p>1) Install <a href="https://nodejs.org/" rel="noreferrer">Node.js</a> if you haven't done so yet.</p> <p>2) Change your <code>converter.js</code> file like this:</p> <pre><code>function bin_dec(num) { return parseInt(num, 2); } console.log(bin_dec(process.argv[2])); </code></pre> <p>3) Open a new command promp... | 3, 1231, 2631 | cmd, command-line, javascript | <h1>Running JavaScript from the windows command prompt</h1>
<p>I wrote the following JavaScipt code which converts a binary number into a decimal number:</p>
<pre><code>(function bin_dec(num) {
var x = num;
var result = 0;
for (var i = 0; i < x.length; i++) {
result += eval(x[x.length - i] * 2^i);
}
r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,477 | cmd | # Running JavaScript from the windows command prompt
I wrote the following JavaScipt code which converts a binary number into a decimal number:
```
(function bin_dec(num) {
var x = num;
var result = 0;
for (var i = 0; i < x.length; i++) {
result += eval(x[x.length - i] * 2^i);
}
return result;
})()
```
... | 1) Install [Node.js](https://nodejs.org/) if you haven't done so yet.
2) Change your `converter.js` file like this:
```
function bin_dec(num) {
return parseInt(num, 2);
}
console.log(bin_dec(process.argv[2]));
```
3) Open a new command prompt in the folder where your script is and run
```
$ node converter.js 010... |
38395462 | How to put in custom scope/context (JobScoped - custom CDI scope) particular instance from request to make it injectable? | 10 | 2016-07-15 11:52:25 | <p>Saying in a nutshell I would like to put in custom scope particular instance of Configuration class from rest request.
Main problem is that custom scope (JobScoped from JBeret <a href="https://jberet.gitbooks.io/jberet-user-guide/content/custom_cdi_scopes/index.html" rel="noreferrer">https://jberet.gitbooks.io/jbere... | 5,627 | 1,560,780 | 2016-10-26 13:22:57 | 38,437,190 | 12 | 2016-07-18 12:52:16 | 2,104,280 | 2016-07-18 12:52:16 | https://stackoverflow.com/q/38395462 | https://stackoverflow.com/a/38437190 | <p>I think this question consists of several parts:</p>
<ol>
<li>How to inject values into batch jobs?</li>
<li>How to seed context based values to batch jobs?</li>
<li>How to enter the RequestScope in a batch job?</li>
<li>How to create a custom scope?</li>
<li>How to enter a custom scope?</li>
<li>How to seed a valu... | <p>I think this question consists of several parts:</p> <ol> <li>How to inject values into batch jobs?</li> <li>How to seed context based values to batch jobs?</li> <li>How to enter the RequestScope in a batch job?</li> <li>How to create a custom scope?</li> <li>How to enter a custom scope?</li> <li>How to seed a valu... | 6101, 50008, 108540, 114544, 135017 | cdi, jakarta-ee, java-batch, jax-rs, jberet | <h1>How to put in custom scope/context (JobScoped - custom CDI scope) particular instance from request to make it injectable?</h1>
<p>Saying in a nutshell I would like to put in custom scope particular instance of Configuration class from rest request.
Main problem is that custom scope (JobScoped from JBeret <a href="h... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,478 | cmd | # How to put in custom scope/context (JobScoped - custom CDI scope) particular instance from request to make it injectable?
Saying in a nutshell I would like to put in custom scope particular instance of Configuration class from rest request.
Main problem is that custom scope (JobScoped from JBeret <https://jberet.git... | I think this question consists of several parts:
1. How to inject values into batch jobs?
2. How to seed context based values to batch jobs?
3. How to enter the RequestScope in a batch job?
4. How to create a custom scope?
5. How to enter a custom scope?
6. How to seed a value in a custom scope?
I will try to answer ... |
13031958 | Batch programming setting ERRORLEVEL from failed FIND command | 10 | 2012-10-23 13:48:14 | <p>I have found the need to report an error level to a program that calls batch scripts.</p>
<p>The script will create a CSV log file that I would like to check in order to display whether the script was run successfully.</p>
<p>What I would like to say is something like </p>
<pre><code>IF NOT FIND "[ERR" "test.csv"... | 34,184 | 1,768,462 | 2018-02-09 11:37:25 | 13,033,422 | 12 | 2012-10-23 15:01:16 | 1,012,053 | 2018-02-09 11:37:25 | https://stackoverflow.com/q/13031958 | https://stackoverflow.com/a/13033422 | <p>FIND "[ERR" "text.csv" sets ERRORLEVEL to 0 if at least one <code>[ERR</code> is found, and 1 if no <code>[ERR</code> is found. You need a way to invert the logic.</p>
<p>If all you want to do is immediately return 0 if no <code>[ERR</code> found, or <code>1</code> if at least one <code>[ERR</code> found, then I wo... | <p>FIND "[ERR" "text.csv" sets ERRORLEVEL to 0 if at least one <code>[ERR</code> is found, and 1 if no <code>[ERR</code> is found. You need a way to invert the logic.</p> <p>If all you want to do is immediately return 0 if no <code>[ERR</code> found, or <code>1</code> if at least one <code>[ERR</code> found, then I wo... | 379, 7002, 17564 | batch-file, error-handling, errorlevel | <h1>Batch programming setting ERRORLEVEL from failed FIND command</h1>
<p>I have found the need to report an error level to a program that calls batch scripts.</p>
<p>The script will create a CSV log file that I would like to check in order to display whether the script was run successfully.</p>
<p>What I would like ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,479 | cmd | # Batch programming setting ERRORLEVEL from failed FIND command
I have found the need to report an error level to a program that calls batch scripts.
The script will create a CSV log file that I would like to check in order to display whether the script was run successfully.
What I would like to say is something lik... | FIND "[ERR" "text.csv" sets ERRORLEVEL to 0 if at least one `[ERR` is found, and 1 if no `[ERR` is found. You need a way to invert the logic.
If all you want to do is immediately return 0 if no `[ERR` found, or `1` if at least one `[ERR` found, then I would use the following:
```
find "[ERR" "test.csv" >nul && exit /... |
11691454 | Running variable string as command in batch scripting | 10 | 2012-07-27 15:57:07 | <p>EDIT: There was nothing wrong with the code below. The error was coming from elsewhere.</p>
<p>The command variable is the command I want to execute. The name variable is pulling a list of computer names. When I echo !command! it returns the value I want to use. That should run the command needed to delete all ... | 22,503 | 1,096,496 | 2017-07-03 14:11:25 | 11,692,192 | 12 | 2012-07-27 16:48:48 | 1,012,053 | 2012-07-27 16:48:48 | https://stackoverflow.com/q/11691454 | https://stackoverflow.com/a/11692192 | <p><code>%command%</code> will not work because it is expanded at parse time, so the expanded value is the value of command prior to the loop executing.</p>
<p>I don't know why <code>!command!</code> does not work. Normally you want to use normal expansion instead of delayed expansion when executing code in a variable... | <p><code>%command%</code> will not work because it is expanded at parse time, so the expanded value is the value of command prior to the loop executing.</p> <p>I don't know why <code>!command!</code> does not work. Normally you want to use normal expansion instead of delayed expansion when executing code in a variable... | 139, 7002, 31134 | batch-file, command-line-arguments, string | <h1>Running variable string as command in batch scripting</h1>
<p>EDIT: There was nothing wrong with the code below. The error was coming from elsewhere.</p>
<p>The command variable is the command I want to execute. The name variable is pulling a list of computer names. When I echo !command! it returns the value I ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,480 | cmd | # Running variable string as command in batch scripting
EDIT: There was nothing wrong with the code below. The error was coming from elsewhere.
The command variable is the command I want to execute. The name variable is pulling a list of computer names. When I echo !command! it returns the value I want to use. That s... | `%command%` will not work because it is expanded at parse time, so the expanded value is the value of command prior to the loop executing.
I don't know why `!command!` does not work. Normally you want to use normal expansion instead of delayed expansion when executing code in a variable because delayed expansion limit... |
10021464 | Batch file to add characters to beginning and end of each line in txt file | 10 | 2012-04-05 01:19:23 | <p>I have a text file, I was wondering anyone have a batch file to add " to the beninning and ", at the end of each line in a text file? </p>
<p>For example I have</p>
<pre><code>1
2
3
</code></pre>
<p>and I want</p>
<pre><code>"1",
"2",
"3",
</code></pre>
<p>If some could paste a quick one it would help me out =)... | 52,006 | 814,950 | 2020-05-20 14:25:19 | 10,021,590 | 12 | 2012-04-05 01:41:42 | 883,015 | 2012-04-05 01:41:42 | https://stackoverflow.com/q/10021464 | https://stackoverflow.com/a/10021590 | <pre><code>@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N+=1
echo ^"%%a^",>>output.txt
)
</code></pre>
<p>-joedf</p>
| <pre><code>@echo off setLocal EnableDelayedExpansion for /f "tokens=* delims= " %%a in (input.txt) do ( set /a N+=1 echo ^"%%a^",>>output.txt ) </code></pre> <p>-joedf</p> | 2631, 7002 | batch-file, cmd | <h1>Batch file to add characters to beginning and end of each line in txt file</h1>
<p>I have a text file, I was wondering anyone have a batch file to add " to the beninning and ", at the end of each line in a text file? </p>
<p>For example I have</p>
<pre><code>1
2
3
</code></pre>
<p>and I want</p>
<pre><code>"1",... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,481 | cmd | # Batch file to add characters to beginning and end of each line in txt file
I have a text file, I was wondering anyone have a batch file to add " to the beninning and ", at the end of each line in a text file?
For example I have
```
1
2
3
```
and I want
```
"1",
"2",
"3",
```
If some could paste a quick one it w... | ```
@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N+=1
echo ^"%%a^",>>output.txt
)
```
-joedf |
6941167 | Hiding a simple batch window | 10 | 2011-08-04 12:10:37 | <p>I've searched this and some pages came which weren't really useful or were too complicated (I am not a skilled batch file programmer!)! What I need is to run a batch file in hidden form (no console window). The batch file will not be called from external application or code. It will be clicked on by the client and t... | 9,070 | 2,308,801 | 2021-01-12 11:18:55 | 6,941,198 | 12 | 2011-08-04 12:12:35 | 799,586 | 2013-12-21 05:12:23 | https://stackoverflow.com/q/6941167 | https://stackoverflow.com/a/6941198 | <p>I use VBScripts to open it hidden, like this:</p>
<pre><code>Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("%batchfile%"), 0, True
</code></pre>
<p>for e.g the bat file I want to run is <code>run.bat</code> then I'll do like this</p>
<pre><code>objShell.Run("run.bat"), 0, True
</code></pre>
<... | <p>I use VBScripts to open it hidden, like this:</p> <pre><code>Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run("%batchfile%"), 0, True </code></pre> <p>for e.g the bat file I want to run is <code>run.bat</code> then I'll do like this</p> <pre><code>objShell.Run("run.bat"), 0, True </code></pre> <... | 64, 1231, 2631, 7002 | batch-file, cmd, command-line, windows | <h1>Hiding a simple batch window</h1>
<p>I've searched this and some pages came which weren't really useful or were too complicated (I am not a skilled batch file programmer!)! What I need is to run a batch file in hidden form (no console window). The batch file will not be called from external application or code. It ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,482 | cmd | # Hiding a simple batch window
I've searched this and some pages came which weren't really useful or were too complicated (I am not a skilled batch file programmer!)! What I need is to run a batch file in hidden form (no console window). The batch file will not be called from external application or code. It will be c... | I use VBScripts to open it hidden, like this:
```
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("%batchfile%"), 0, True
```
for e.g the bat file I want to run is `run.bat` then I'll do like this
```
objShell.Run("run.bat"), 0, True
```
Instead of running the batch file run the vb file.
Write it... |
6685229 | batch file: pass parameter with white spaces to function | 10 | 2011-07-13 20:30:15 | <p>I am using a batch file for backups. I pass the options to a function which calls the packaging executable. This works unless the parameters contain whitespaces. This is the relevant code:</p>
<pre><code>SET TARGET="%SAVEDIR%\XP.User.Documents.rar"
SET FILES="%DIRUSER%\Eigene Dateien\*"
SET EXLUCDE="%DIRUSER%... | 14,867 | 843,458 | 2011-07-14 13:45:22 | 6,687,143 | 12 | 2011-07-14 00:16:28 | 463,115 | 2011-07-14 00:16:28 | https://stackoverflow.com/q/6685229 | https://stackoverflow.com/a/6687143 | <p>The problem seems to be your style of assigning the variables.<br>
I suppose you set the DIRUSER variable like the other ones </p>
<pre><code>set DIRUSER="Dokumente und Einstellungen"
</code></pre>
<p>But the content of DIRUSER is then <code>"Dokumente und Einstellungen"</code>, so the quotes are a part of the co... | <p>The problem seems to be your style of assigning the variables.<br> I suppose you set the DIRUSER variable like the other ones </p> <pre><code>set DIRUSER="Dokumente und Einstellungen" </code></pre> <p>But the content of DIRUSER is then <code>"Dokumente und Einstellungen"</code>, so the quotes are a part of the co... | 64, 5162, 7002 | batch-file, spaces, windows | <h1>batch file: pass parameter with white spaces to function</h1>
<p>I am using a batch file for backups. I pass the options to a function which calls the packaging executable. This works unless the parameters contain whitespaces. This is the relevant code:</p>
<pre><code>SET TARGET="%SAVEDIR%\XP.User.Documents.rar"
S... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,483 | cmd | # batch file: pass parameter with white spaces to function
I am using a batch file for backups. I pass the options to a function which calls the packaging executable. This works unless the parameters contain whitespaces. This is the relevant code:
```
SET TARGET="%SAVEDIR%\XP.User.Documents.rar"
SET FILES="%DIRUSER%\... | The problem seems to be your style of assigning the variables.
I suppose you set the DIRUSER variable like the other ones
```
set DIRUSER="Dokumente und Einstellungen"
```
But the content of DIRUSER is then `"Dokumente und Einstellungen"`, so the quotes are a part of the content.
But then `SET FILES="%DIRUSER%\Eig... |
3852563 | In cmd.exe, how can you get one variable to escape the setlocal command? | 10 | 2010-10-04 02:55:06 | <p>I frequently find myself using <code>setlocal</code> within <code>cmd.exe</code> to avoid polluting the environment variable space with temporary variables (and to ensure both command extensions and delayed expansion are active).</p>
<p>However, I'm at a loss on how to do this if I actually want one of those variab... | 2,320 | 14,860 | 2013-07-07 21:28:08 | 3,852,661 | 12 | 2010-10-04 03:25:06 | 3,534 | 2010-10-04 03:25:06 | https://stackoverflow.com/q/3852563 | https://stackoverflow.com/a/3852661 | <p>"The solution to this is to take advantage of the fact that the CMD shell evaluates variables on a line-by-line basis - so placing ENDLOCAL on the same line as the SET statement(s) gives the result we want:" source: <a href="http://ss64.com/nt/syntax-functions.html" rel="noreferrer">ss64.com</a></p>
<p>So changing ... | <p>"The solution to this is to take advantage of the fact that the CMD shell evaluates variables on a line-by-line basis - so placing ENDLOCAL on the same line as the SET statement(s) gives the result we want:" source: <a href="http://ss64.com/nt/syntax-functions.html" rel="noreferrer">ss64.com</a></p> <p>So changing ... | 64, 2182, 2631, 7002 | batch-file, cmd, scope, windows | <h1>In cmd.exe, how can you get one variable to escape the setlocal command?</h1>
<p>I frequently find myself using <code>setlocal</code> within <code>cmd.exe</code> to avoid polluting the environment variable space with temporary variables (and to ensure both command extensions and delayed expansion are active).</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,484 | cmd | # In cmd.exe, how can you get one variable to escape the setlocal command?
I frequently find myself using `setlocal` within `cmd.exe` to avoid polluting the environment variable space with temporary variables (and to ensure both command extensions and delayed expansion are active).
However, I'm at a loss on how to do... | "The solution to this is to take advantage of the fact that the CMD shell evaluates variables on a line-by-line basis - so placing ENDLOCAL on the same line as the SET statement(s) gives the result we want:" source: [ss64.com](http://ss64.com/nt/syntax-functions.html)
So changing the endlocal of func: to this...
```
... |
50242293 | Using SBATCH Job Name as a Variable in File Output | 9 | 2018-05-08 21:08:34 | <p>With SBATCH you can use the job-id in automatically generated output files using the following syntax with <code>%j</code>: </p>
<pre><code>#!/bin/bash
# omitting some other sbatch commands here ...
#SBATCH -o slurm-%j.out-%N # name of the stdout, using the job number (%j) and the first node (%N)
#SBATCH -e slurm-... | 12,160 | 3,161,979 | 2018-05-09 02:31:30 | 50,244,694 | 12 | 2018-05-09 02:31:30 | 2,355,634 | 2018-05-09 02:31:30 | https://stackoverflow.com/q/50242293 | https://stackoverflow.com/a/50244694 | <p>In the newest versions of SLURM there is an option %x that represents job name.
See the "Changes in Slurm 17.02.1" section on the github:
<a href="https://github.com/SchedMD/slurm/blob/master/NEWS" rel="noreferrer">https://github.com/SchedMD/slurm/blob/master/NEWS</a></p>
<p>However on many current clusters the slu... | <p>In the newest versions of SLURM there is an option %x that represents job name. See the "Changes in Slurm 17.02.1" section on the github: <a href="https://github.com/SchedMD/slurm/blob/master/NEWS" rel="noreferrer">https://github.com/SchedMD/slurm/blob/master/NEWS</a></p> <p>However on many current clusters the slu... | 97759, 105553 | sbatch, slurm | <h1>Using SBATCH Job Name as a Variable in File Output</h1>
<p>With SBATCH you can use the job-id in automatically generated output files using the following syntax with <code>%j</code>: </p>
<pre><code>#!/bin/bash
# omitting some other sbatch commands here ...
#SBATCH -o slurm-%j.out-%N # name of the stdout, using t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,485 | cmd | # Using SBATCH Job Name as a Variable in File Output
With SBATCH you can use the job-id in automatically generated output files using the following syntax with `%j`:
```
#!/bin/bash
# omitting some other sbatch commands here ...
#SBATCH -o slurm-%j.out-%N # name of the stdout, using the job number (%j) and the first... | In the newest versions of SLURM there is an option %x that represents job name.
See the "Changes in Slurm 17.02.1" section on the github:
<https://github.com/SchedMD/slurm/blob/master/NEWS>
However on many current clusters the slurm version is older than that and this option is not implemented. You can view the versio... |
39512375 | Is there any way to create an shortcut desktop to a Node.js (npm) application? | 9 | 2016-09-15 13:30:48 | <p>Inexperienced users want to "see" the app that I've created in Node.js, but they don't want to use the console. According to them, it's a good idea to install it, and with a simple click, in desktop, they could "see" it.</p>
<p>They want to run the Node.js app as a Windows program. That's all!</p>
<p>How can I do ... | 19,544 | 6,291,719 | 2025-02-07 14:05:14 | 39,512,970 | 12 | 2016-09-15 13:56:35 | 6,291,719 | 2016-09-15 13:56:35 | https://stackoverflow.com/q/39512375 | https://stackoverflow.com/a/39512970 | <p><strong>**SOLVED**</strong></p>
<p>An .bat file, renamed as "appstart.bat"</p>
<pre><code>cd C:\Users\MyUser\MyApp
npm start
</code></pre>
<p>With shortcut in desktop. </p>
| <p><strong>**SOLVED**</strong></p> <p>An .bat file, renamed as "appstart.bat"</p> <pre><code>cd C:\Users\MyUser\MyApp npm start </code></pre> <p>With shortcut in desktop. </p> | 3, 64, 1135, 7002, 46426 | batch-file, executable, javascript, node.js, windows | <h1>Is there any way to create an shortcut desktop to a Node.js (npm) application?</h1>
<p>Inexperienced users want to "see" the app that I've created in Node.js, but they don't want to use the console. According to them, it's a good idea to install it, and with a simple click, in desktop, they could "see" it.</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,487 | cmd | # Is there any way to create an shortcut desktop to a Node.js (npm) application?
Inexperienced users want to "see" the app that I've created in Node.js, but they don't want to use the console. According to them, it's a good idea to install it, and with a simple click, in desktop, they could "see" it.
They want to run... | ****SOLVED****
An .bat file, renamed as "appstart.bat"
```
cd C:\Users\MyUser\MyApp
npm start
```
With shortcut in desktop. |
37434897 | Find a Windows process based on its description, using CMD | 9 | 2016-05-25 10:50:44 | <p>I get two results when I run this:</p>
<p><strong>tasklist /FI "imagename eq PROCESS.exe"</strong></p>
<pre><code>Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
PROCESS.exe 2760 Console ... | 25,943 | 1,430,002 | 2016-05-25 12:41:24 | 37,436,860 | 12 | 2016-05-25 12:17:00 | 1,911,064 | 2016-05-25 12:17:00 | https://stackoverflow.com/q/37434897 | https://stackoverflow.com/a/37436860 | <p>Use the following to distinguish the processes according to their own process ID and their parent process ID:</p>
<pre><code>wmic process get processid,parentprocessid,executablepath | find "PROCESS"
</code></pre>
<p>This way, you can find the process ID to kill.</p>
<p><code>wmic</code> grants access to addition... | <p>Use the following to distinguish the processes according to their own process ID and their parent process ID:</p> <pre><code>wmic process get processid,parentprocessid,executablepath | find "PROCESS" </code></pre> <p>This way, you can find the process ID to kill.</p> <p><code>wmic</code> grants access to addition... | 64, 2631, 5910 | cmd, process, windows | <h1>Find a Windows process based on its description, using CMD</h1>
<p>I get two results when I run this:</p>
<p><strong>tasklist /FI "imagename eq PROCESS.exe"</strong></p>
<pre><code>Image Name PID Session Name Session# Mem Usage
========================= ======== ================ ====... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,488 | cmd | # Find a Windows process based on its description, using CMD
I get two results when I run this:
**tasklist /FI "imagename eq PROCESS.exe"**
```
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
PROCESS.exe ... | Use the following to distinguish the processes according to their own process ID and their parent process ID:
```
wmic process get processid,parentprocessid,executablepath | find "PROCESS"
```
This way, you can find the process ID to kill.
`wmic` grants access to additional process properties.
Use `wmic process get... |
28537941 | How to hibernate windows pc from cmd | 9 | 2015-02-16 09:11:47 | <p>How can I set my computer to hibernate after, say 18000 seconds?</p>
<p>This doesn't work:</p>
<pre><code>shutdown -h -t 18000
</code></pre>
| 30,521 | 3,663,765 | 2017-10-24 14:09:01 | 28,540,689 | 12 | 2015-02-16 11:44:27 | 3,663,765 | 2015-02-16 11:44:27 | https://stackoverflow.com/q/28537941 | https://stackoverflow.com/a/28540689 | <p>From the question: <a href="https://superuser.com/questions/83437/hibernate-computer-from-command-line-on-windows-7">Hibernate computer from command line on Windows 7</a>, Phoshi's answer does it:</p>
<p>The hibernation time for cannot be set, unfortunately.</p>
<p>This works, though.</p>
<pre><code>ping -n 20 12... | <p>From the question: <a href="https://superuser.com/questions/83437/hibernate-computer-from-command-line-on-windows-7">Hibernate computer from command line on Windows 7</a>, Phoshi's answer does it:</p> <p>The hibernation time for cannot be set, unfortunately.</p> <p>This works, though.</p> <pre><code>ping -n 20 12... | 64, 2631, 4921, 45938 | cmd, shutdown, system-shutdown, windows | <h1>How to hibernate windows pc from cmd</h1>
<p>How can I set my computer to hibernate after, say 18000 seconds?</p>
<p>This doesn't work:</p>
<pre><code>shutdown -h -t 18000
</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,489 | cmd | # How to hibernate windows pc from cmd
How can I set my computer to hibernate after, say 18000 seconds?
This doesn't work:
```
shutdown -h -t 18000
``` | From the question: [Hibernate computer from command line on Windows 7](https://superuser.com/questions/83437/hibernate-computer-from-command-line-on-windows-7), Phoshi's answer does it:
The hibernation time for cannot be set, unfortunately.
This works, though.
```
ping -n 20 127.0.0.1 > NUL 2>&1 && shutdown /h /f
``... |
24583984 | Why does cmd run my second command when I use && even though the first one failed? | 9 | 2014-07-05 07:12:56 | <p>I'm experimenting with Rust. I want to compile a program, and only if it succeeds, run it. So I'm trying:</p>
<pre><code>rustc hello.rs && hello
</code></pre>
<p>But hello.exe always runs, even if compilation fails.</p>
<p>If I try</p>
<pre><code>rustc hello.rs
echo Exit Code is %errorlevel%
</code></pr... | 3,086 | 65,387 | 2014-07-05 17:52:28 | 24,586,555 | 12 | 2014-07-05 12:43:02 | 1,012,053 | 2014-07-05 17:52:28 | https://stackoverflow.com/q/24583984 | https://stackoverflow.com/a/24586555 | <p>Very curious this. Put a CALL in front and all should be fine.</p>
<pre><code>call rustc hello.rs && hello
</code></pre>
<p>I don't totally understand the mechanism. I know that <code>&&</code> and <code>||</code> do not read the dynamic <code>%errorlevel%</code> value directly, but operate at some... | <p>Very curious this. Put a CALL in front and all should be fine.</p> <pre><code>call rustc hello.rs && hello </code></pre> <p>I don't totally understand the mechanism. I know that <code>&&</code> and <code>||</code> do not read the dynamic <code>%errorlevel%</code> value directly, but operate at some... | 64, 2631 | cmd, windows | <h1>Why does cmd run my second command when I use && even though the first one failed?</h1>
<p>I'm experimenting with Rust. I want to compile a program, and only if it succeeds, run it. So I'm trying:</p>
<pre><code>rustc hello.rs && hello
</code></pre>
<p>But hello.exe always runs, even if compilation fails.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,490 | cmd | # Why does cmd run my second command when I use && even though the first one failed?
I'm experimenting with Rust. I want to compile a program, and only if it succeeds, run it. So I'm trying:
```
rustc hello.rs && hello
```
But hello.exe always runs, even if compilation fails.
If I try
```
rustc hello.rs
echo Exit ... | Very curious this. Put a CALL in front and all should be fine.
```
call rustc hello.rs && hello
```
I don't totally understand the mechanism. I know that `&&` and `||` do not read the dynamic `%errorlevel%` value directly, but operate at some lower level. They conditionally fire based on the outcome of the most recen... |
19442819 | CMD.exe: Get second column output to variable | 9 | 2013-10-18 06:15:37 | <p>I need the below command second column output <code><USERNAME></code> result to variables:</p>
<pre><code>query sessions|find "Active"
>console <USERNAME> 1 Active
</code></pre>
<p>I know the <code>%USERNAME%</code> OR <code>whoami</code> could get the current user name but this script will... | 13,605 | 2,424,167 | 2013-10-18 06:24:16 | 19,442,952 | 12 | 2013-10-18 06:24:16 | 463,115 | 2013-10-18 06:24:16 | https://stackoverflow.com/q/19442819 | https://stackoverflow.com/a/19442952 | <p>In this case you should use <code>FOR /F</code> to capture the output</p>
<pre><code>for /F "tokens=1,2,3,4,5" %%A in ('"query session | find "Active""') DO (
echo %%A,%%B,%%C,%%D,%%E
)
</code></pre>
<p>It splits also the line at spaces and TABs, but this can be problematic if the username contains spaces.</p>
| <p>In this case you should use <code>FOR /F</code> to capture the output</p> <pre><code>for /F "tokens=1,2,3,4,5" %%A in ('"query session | find "Active""') DO ( echo %%A,%%B,%%C,%%D,%%E ) </code></pre> <p>It splits also the line at spaces and TABs, but this can be problematic if the username contains spaces.</p> | 2631, 7002 | batch-file, cmd | <h1>CMD.exe: Get second column output to variable</h1>
<p>I need the below command second column output <code><USERNAME></code> result to variables:</p>
<pre><code>query sessions|find "Active"
>console <USERNAME> 1 Active
</code></pre>
<p>I know the <code>%USERNAME%</code> OR <code>whoami</cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,492 | cmd | # CMD.exe: Get second column output to variable
I need the below command second column output `<USERNAME>` result to variables:
```
query sessions|find "Active"
>console <USERNAME> 1 Active
```
I know the `%USERNAME%` OR `whoami` could get the current user name but this script will run using administrator a... | In this case you should use `FOR /F` to capture the output
```
for /F "tokens=1,2,3,4,5" %%A in ('"query session | find "Active""') DO (
echo %%A,%%B,%%C,%%D,%%E
)
```
It splits also the line at spaces and TABs, but this can be problematic if the username contains spaces. |
15994824 | Faking standard input on the Windows command line | 9 | 2013-04-14 01:33:49 | <p>I want to use <a href="http://dev.evernote.com/documentation/local/chapters/windows.php#enscript" rel="noreferrer">Evernote's ENScript.exe</a> to create new notes, entering the text and title as arguments. The problem is that ENScript only allows the text to be entered via a file or via standard input.</p>
<p>For m... | 35,896 | 1,442,881 | 2020-04-16 15:56:22 | 15,998,833 | 12 | 2013-04-14 12:02:37 | 1,012,053 | 2013-04-14 17:08:21 | https://stackoverflow.com/q/15994824 | https://stackoverflow.com/a/15998833 | <p>You are looking for a pipe operation that captures the output of one command and sends it as input to the next. This is a standard capability in most operating systems.</p>
<p>The pipe symbol for Windows CMD is <code>|</code></p>
<p>Your script could be as simple as:</p>
<pre><code>@echo %~2|@ENScript.exe createN... | <p>You are looking for a pipe operation that captures the output of one command and sends it as input to the next. This is a standard capability in most operating systems.</p> <p>The pipe symbol for Windows CMD is <code>|</code></p> <p>Your script could be as simple as:</p> <pre><code>@echo %~2|@ENScript.exe createN... | 64, 2631, 35853 | cmd, evernote, windows | <h1>Faking standard input on the Windows command line</h1>
<p>I want to use <a href="http://dev.evernote.com/documentation/local/chapters/windows.php#enscript" rel="noreferrer">Evernote's ENScript.exe</a> to create new notes, entering the text and title as arguments. The problem is that ENScript only allows the text to... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,493 | cmd | # Faking standard input on the Windows command line
I want to use [Evernote's ENScript.exe](http://dev.evernote.com/documentation/local/chapters/windows.php#enscript) to create new notes, entering the text and title as arguments. The problem is that ENScript only allows the text to be entered via a file or via standar... | You are looking for a pipe operation that captures the output of one command and sends it as input to the next. This is a standard capability in most operating systems.
The pipe symbol for Windows CMD is `|`
Your script could be as simple as:
```
@echo %~2|@ENScript.exe createNote /i %1
```
If your script is called... |
15903139 | If Notepad.exe is running then taskkill if not running go to next statement | 9 | 2013-04-09 13:22:18 | <p>I need help writing batch code.</p>
<p>In the initial state of my batch script I need to check if <code>notepad.exe</code> is running
if it is running then <Br> <code>taskkill /im notepad.exe</code> elsif <code>notepad.exe</code> is not running then go to next batch statement/code.</p>
| 17,812 | 1,512,440 | 2013-04-09 13:48:23 | 15,903,179 | 12 | 2013-04-09 13:23:39 | 505,088 | 2013-04-09 13:29:51 | https://stackoverflow.com/q/15903139 | https://stackoverflow.com/a/15903179 | <p>You can simply execute <code>taskkill /im notepad.exe</code> in all cases. If it's not running, then <code>taskill</code> will having nothing to kill and will just return.</p>
<p>In that situation, <code>taskkill</code> will report an error and set the error level. You can suppress the reporting of the error by red... | <p>You can simply execute <code>taskkill /im notepad.exe</code> in all cases. If it's not running, then <code>taskill</code> will having nothing to kill and will just return.</p> <p>In that situation, <code>taskkill</code> will report an error and set the error level. You can suppress the reporting of the error by red... | 7002, 12488, 30645 | batch-file, batch-processing, taskkill | <h1>If Notepad.exe is running then taskkill if not running go to next statement</h1>
<p>I need help writing batch code.</p>
<p>In the initial state of my batch script I need to check if <code>notepad.exe</code> is running
if it is running then <Br> <code>taskkill /im notepad.exe</code> elsif <code>notepad.exe</code> i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,494 | cmd | # If Notepad.exe is running then taskkill if not running go to next statement
I need help writing batch code.
In the initial state of my batch script I need to check if `notepad.exe` is running
if it is running then
`taskkill /im notepad.exe` elsif `notepad.exe` is not running then go to next batch statement/code... | You can simply execute `taskkill /im notepad.exe` in all cases. If it's not running, then `taskill` will having nothing to kill and will just return.
In that situation, `taskkill` will report an error and set the error level. You can suppress the reporting of the error by redirecting standard error:
```
taskkill /im ... |
12841024 | Using Windows/DOS shell/batch commands, how do I take a file and only keep unique lines? | 9 | 2012-10-11 13:44:48 | <p>Say I have a file like:</p>
<pre><code>apple
pear
lemon
lemon
pear
orange
lemon
</code></pre>
<p>How do I make it so that I only keep the unique lines, so I get:</p>
<pre><code>apple
pear
lemon
orange
</code></pre>
<p>I can either modify the original file or create a new one.</p>
<p>I'm thinking there's a way t... | 20,983 | 234,593 | 2020-07-24 22:58:37 | 12,847,935 | 12 | 2012-10-11 20:24:41 | 1,123,692 | 2016-11-29 12:34:59 | https://stackoverflow.com/q/12841024 | https://stackoverflow.com/a/12847935 | <pre><code>@echo off
setlocal disabledelayedexpansion
set "prev="
for /f "delims=" %%F in ('sort uniqinput.txt') do (
set "curr=%%F"
setlocal enabledelayedexpansion
if "!prev!" neq "!curr!" echo !curr!
endlocal
set "prev=%%F"
)
</code></pre>
<p>What it does: sorts the input first, and then goes though it seq... | <pre><code>@echo off setlocal disabledelayedexpansion set "prev=" for /f "delims=" %%F in ('sort uniqinput.txt') do ( set "curr=%%F" setlocal enabledelayedexpansion if "!prev!" neq "!curr!" echo !curr! endlocal set "prev=%%F" ) </code></pre> <p>What it does: sorts the input first, and then goes though it seq... | 64, 134, 1231, 6205, 7002 | batch-file, command-line, sorting, unique, windows | <h1>Using Windows/DOS shell/batch commands, how do I take a file and only keep unique lines?</h1>
<p>Say I have a file like:</p>
<pre><code>apple
pear
lemon
lemon
pear
orange
lemon
</code></pre>
<p>How do I make it so that I only keep the unique lines, so I get:</p>
<pre><code>apple
pear
lemon
orange
</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,495 | cmd | # Using Windows/DOS shell/batch commands, how do I take a file and only keep unique lines?
Say I have a file like:
```
apple
pear
lemon
lemon
pear
orange
lemon
```
How do I make it so that I only keep the unique lines, so I get:
```
apple
pear
lemon
orange
```
I can either modify the original file or create a new ... | ```
@echo off
setlocal disabledelayedexpansion
set "prev="
for /f "delims=" %%F in ('sort uniqinput.txt') do (
set "curr=%%F"
setlocal enabledelayedexpansion
if "!prev!" neq "!curr!" echo !curr!
endlocal
set "prev=%%F"
)
```
What it does: sorts the input first, and then goes though it sequentially and output... |
11910040 | `exec': string contains null byte (ArgumentError) | 9 | 2012-08-10 22:25:36 | <pre><code>cmd = "snv co #{rep} --username #{svn_user} --password #{pxs}"
puts cmd # this code wotks and prints all vars values normally
exec(cmd)
</code></pre>
<pre><code>xpto.rb:69:in `exec': string contains null byte (ArgumentError)
from xpto.rb:69
</code></pre>
<pre><code>$ ruby -v
ruby 1.8.7 (2010... | 10,418 | 220,175 | 2012-08-10 23:03:50 | 11,910,310 | 12 | 2012-08-10 23:02:23 | 214,790 | 2012-08-10 23:02:23 | https://stackoverflow.com/q/11910040 | https://stackoverflow.com/a/11910310 | <p>Your <code>cmd</code> string has got a null (i.e. zero) byte in it somehow. Using <code>puts</code> won’t show up any null bytes, they’ll just be left out of the output:</p>
<pre class="lang-none prettyprint-override"><code>1.8.7 :001 > exec "\0"
ArgumentError: string contains null byte
from (irb):1:in `... | <p>Your <code>cmd</code> string has got a null (i.e. zero) byte in it somehow. Using <code>puts</code> won’t show up any null bytes, they’ll just be left out of the output:</p> <pre class="lang-none prettyprint-override"><code>1.8.7 :001 > exec "\0" ArgumentError: string contains null byte from (irb):1:in `... | 12, 139, 2313, 2631, 7932 | arguments, cmd, exec, ruby, string | <h1>`exec': string contains null byte (ArgumentError)</h1>
<pre><code>cmd = "snv co #{rep} --username #{svn_user} --password #{pxs}"
puts cmd # this code wotks and prints all vars values normally
exec(cmd)
</code></pre>
<pre><code>xpto.rb:69:in `exec': string contains null byte (ArgumentError)
from xpto.r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,496 | cmd | # `exec': string contains null byte (ArgumentError)
```
cmd = "snv co #{rep} --username #{svn_user} --password #{pxs}"
puts cmd # this code wotks and prints all vars values normally
exec(cmd)
```
```
xpto.rb:69:in `exec': string contains null byte (ArgumentError)
from xpto.rb:69
```
```
$ ruby -v
ruby 1.8.7 ... | Your `cmd` string has got a null (i.e. zero) byte in it somehow. Using `puts` won’t show up any null bytes, they’ll just be left out of the output:
```
1.8.7 :001 > exec "\0"
ArgumentError: string contains null byte
from (irb):1:in `exec'
from (irb):1
1.8.7 :002 > puts "n\0n"
nn
=> nil
```
You should... |
10358672 | Using appcmd to add a new site without supplying site id? | 9 | 2012-04-27 22:27:06 | <p>I'm writing a batch script to deploy web sites packaged with Visual Studio 2010. In the script, I'm adding new sites as such:</p>
<p><code>appcmd add site /name:MySite /id:123</code></p>
<p>However, I don't want to specify a site id. I would just like <code>appcmd</code> to randomly assign one for me. But the <cod... | 6,232 | 310,767 | 2012-04-27 22:39:14 | 10,358,715 | 12 | 2012-04-27 22:30:49 | 189,857 | 2012-04-27 22:30:49 | https://stackoverflow.com/q/10358672 | https://stackoverflow.com/a/10358715 | <p>I've never known the /id param to be required - I've always used the form:</p>
<pre><code>appcmd add site /name:"%appName%" /bindings:http://%appDns%:80 /physicalPath:"%mainApplicationPath%"
</code></pre>
<p>And never had any problems. What error is appcmd giving you when you don't specify it?</p>
| <p>I've never known the /id param to be required - I've always used the form:</p> <pre><code>appcmd add site /name:"%appName%" /bindings:http://%appDns%:80 /physicalPath:"%mainApplicationPath%" </code></pre> <p>And never had any problems. What error is appcmd giving you when you don't specify it?</p> | 96, 215, 1301, 7002, 14456 | asp.net, batch-file, iis, iis-7, visual-studio-2010 | <h1>Using appcmd to add a new site without supplying site id?</h1>
<p>I'm writing a batch script to deploy web sites packaged with Visual Studio 2010. In the script, I'm adding new sites as such:</p>
<p><code>appcmd add site /name:MySite /id:123</code></p>
<p>However, I don't want to specify a site id. I would just l... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,497 | cmd | # Using appcmd to add a new site without supplying site id?
I'm writing a batch script to deploy web sites packaged with Visual Studio 2010. In the script, I'm adding new sites as such:
`appcmd add site /name:MySite /id:123`
However, I don't want to specify a site id. I would just like `appcmd` to randomly assign on... | I've never known the /id param to be required - I've always used the form:
```
appcmd add site /name:"%appName%" /bindings:http://%appDns%:80 /physicalPath:"%mainApplicationPath%"
```
And never had any problems. What error is appcmd giving you when you don't specify it? |
9888806 | run two commands in one windows cmd line, one command is SET command | 9 | 2012-03-27 11:35:50 | <h2>[purpose]</h2>
<p>This simple command sequence runs expected in the Windows' CMD shell:</p>
<pre><code>dir & echo hello
</code></pre>
<p>will list the files and directories and echo the string.</p>
<p>However, the following command sequence does not run as expected (at least by me):</p>
<pre><code>C:\Users\Admi... | 13,055 | 531,199 | 2015-08-05 09:13:08 | 9,900,337 | 12 | 2012-03-28 02:24:43 | 1,012,053 | 2015-07-16 13:45:31 | https://stackoverflow.com/q/9888806 | https://stackoverflow.com/a/9900337 | <p>Your result is due to the fact that %name% is expanded during the parsing phase, and the entire line is parsed at once, prior to the value being set.</p>
<p>You can get the current value on the same line as the set command in one of two ways.</p>
<p>1) use CALL to cause ECHO %NAME% to be parsed a 2nd time:</p>
<p... | <p>Your result is due to the fact that %name% is expanded during the parsing phase, and the entire line is parsed at once, prior to the value being set.</p> <p>You can get the current value on the same line as the set command in one of two ways.</p> <p>1) use CALL to cause ECHO %NAME% to be parsed a 2nd time:</p> <p... | 64, 1231, 2631 | cmd, command-line, windows | <h1>run two commands in one windows cmd line, one command is SET command</h1>
<h2>[purpose]</h2>
<p>This simple command sequence runs expected in the Windows' CMD shell:</p>
<pre><code>dir & echo hello
</code></pre>
<p>will list the files and directories and echo the string.</p>
<p>However, the following command se... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,498 | cmd | # run two commands in one windows cmd line, one command is SET command
## [purpose]
This simple command sequence runs expected in the Windows' CMD shell:
```
dir & echo hello
```
will list the files and directories and echo the string.
However, the following command sequence does not run as expected (at least by m... | Your result is due to the fact that %name% is expanded during the parsing phase, and the entire line is parsed at once, prior to the value being set.
You can get the current value on the same line as the set command in one of two ways.
1) use CALL to cause ECHO %NAME% to be parsed a 2nd time:
```
set name=value&call... |
9457355 | Batch parse each parameter | 9 | 2012-02-26 21:31:34 | <p>I am trying to create a batch script which would perform the same action for each parameter given. For example, giving X files as parameters:<br>
<code>script.bat "file1.txt" "file2.txt" "file3.txt" "file4.txt" ... "fileX.txt"</code><br>
will rename them to:<br>
<code>"file1.bin" "file2.bin" "file3.bin" "file4.bin" ... | 7,198 | 851,538 | 2015-05-07 19:28:15 | 9,457,406 | 12 | 2012-02-26 21:37:32 | 791,998 | 2012-02-26 21:37:32 | https://stackoverflow.com/q/9457355 | https://stackoverflow.com/a/9457406 | <p>You can use <code>SHIFT</code> to shift the parameters left. In other words calling shift will put the second parameter to %1, the third to %2 etc.</p>
<p>So you need something like:</p>
<pre><code>@ECHO OFF
:Loop
IF "%1"=="" GOTO Continue
ECHO %1
SHIFT
GOTO Loop
:Continue
</code></pre>
<p>This will just print... | <p>You can use <code>SHIFT</code> to shift the parameters left. In other words calling shift will put the second parameter to %1, the third to %2 etc.</p> <p>So you need something like:</p> <pre><code>@ECHO OFF :Loop IF "%1"=="" GOTO Continue ECHO %1 SHIFT GOTO Loop :Continue </code></pre> <p>This will just print... | 360, 631, 7002 | batch-file, foreach, parameters | <h1>Batch parse each parameter</h1>
<p>I am trying to create a batch script which would perform the same action for each parameter given. For example, giving X files as parameters:<br>
<code>script.bat "file1.txt" "file2.txt" "file3.txt" "file4.txt" ... "fileX.txt"</code><br>
will rename them to:<br>
<code>"file1.bin" ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,499 | cmd | # Batch parse each parameter
I am trying to create a batch script which would perform the same action for each parameter given. For example, giving X files as parameters:
`script.bat "file1.txt" "file2.txt" "file3.txt" "file4.txt" ... "fileX.txt"`
will rename them to:
`"file1.bin" "file2.bin" "file3.bin" "file4.... | You can use `SHIFT` to shift the parameters left. In other words calling shift will put the second parameter to %1, the third to %2 etc.
So you need something like:
```
@ECHO OFF
:Loop
IF "%1"=="" GOTO Continue
ECHO %1
SHIFT
GOTO Loop
:Continue
```
This will just print the arguments in order, but you can do whate... |
7355331 | Check if computer is plugged into AC power in batch file | 9 | 2011-09-08 22:36:57 | <p>How can I check if computer is plugged into AC power in a batch file in windows 7, like <code>on_ac_power</code> does in linux?</p>
| 16,167 | 931,721 | 2019-06-04 13:16:15 | 7,355,663 | 12 | 2011-09-08 23:29:09 | 1,813 | 2011-09-08 23:29:09 | https://stackoverflow.com/q/7355331 | https://stackoverflow.com/a/7355663 | <p>There's a direct batch file way:</p>
<pre><code>WMIC Path Win32_Battery Get BatteryStatus
</code></pre>
<p>Using this and some <code>find</code>/<code>errorlevel</code> magic, you should be able to turn it into a condition.</p>
| <p>There's a direct batch file way:</p> <pre><code>WMIC Path Win32_Battery Get BatteryStatus </code></pre> <p>Using this and some <code>find</code>/<code>errorlevel</code> magic, you should be able to turn it into a condition.</p> | 7002, 34595 | batch-file, windows-7 | <h1>Check if computer is plugged into AC power in batch file</h1>
<p>How can I check if computer is plugged into AC power in a batch file in windows 7, like <code>on_ac_power</code> does in linux?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,500 | cmd | # Check if computer is plugged into AC power in batch file
How can I check if computer is plugged into AC power in a batch file in windows 7, like `on_ac_power` does in linux? | There's a direct batch file way:
```
WMIC Path Win32_Battery Get BatteryStatus
```
Using this and some `find`/`errorlevel` magic, you should be able to turn it into a condition. |
2499746 | Extracting columns from text file using Perl one-liner: similar to Unix cut | 9 | 2010-03-23 12:20:07 | <p>I'm using Windows, and I would like to extract certain columns from a text file using a Perl, Python, batch etc. one-liner.</p>
<p>On Unix I could do this:</p>
<pre><code>cut -d " " -f 1-3 <my file>
</code></pre>
<p>How can I do this on Windows?</p>
| 10,361 | 255,564 | 2015-01-28 11:17:33 | 2,499,833 | 12 | 2010-03-23 12:34:19 | 197,758 | 2010-03-23 12:41:35 | https://stackoverflow.com/q/2499746 | https://stackoverflow.com/a/2499833 | <p>Here is a Perl one-liner to print the first 3 whitespace-delimited columns of a file. This can be run on Windows (or Unix). Refer to <a href="http://perldoc.perl.org/perlrun.html" rel="noreferrer">perlrun</a>.</p>
<pre><code>perl -ane "print qq(@F[0..2]\n)" file.txt
</code></pre>
| <p>Here is a Perl one-liner to print the first 3 whitespace-delimited columns of a file. This can be run on Windows (or Unix). Refer to <a href="http://perldoc.perl.org/perlrun.html" rel="noreferrer">perlrun</a>.</p> <pre><code>perl -ane "print qq(@F[0..2]\n)" file.txt </code></pre> | 16, 34, 580, 7002 | batch-file, perl, python, unix | <h1>Extracting columns from text file using Perl one-liner: similar to Unix cut</h1>
<p>I'm using Windows, and I would like to extract certain columns from a text file using a Perl, Python, batch etc. one-liner.</p>
<p>On Unix I could do this:</p>
<pre><code>cut -d " " -f 1-3 <my file>
</code></pre>
<p>How can... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,501 | cmd | # Extracting columns from text file using Perl one-liner: similar to Unix cut
I'm using Windows, and I would like to extract certain columns from a text file using a Perl, Python, batch etc. one-liner.
On Unix I could do this:
```
cut -d " " -f 1-3 <my file>
```
How can I do this on Windows? | Here is a Perl one-liner to print the first 3 whitespace-delimited columns of a file. This can be run on Windows (or Unix). Refer to [perlrun](http://perldoc.perl.org/perlrun.html).
```
perl -ane "print qq(@F[0..2]\n)" file.txt
``` |
39597481 | Windows cmd which removes every bin and obj folders | 8 | 2016-09-20 15:00:08 | <p>I'm trying to write a windows script that will remove every <code>bin</code> and <code>obj</code> folder in my project folder. It just doesn't work..</p>
<p>I found <a href="https://stackoverflow.com/questions/521382/command-line-tool-to-delete-folder-with-a-specified-name-recursively-in-windows/521433#521433">this... | 4,537 | 5,522,036 | 2020-08-17 04:19:40 | 39,597,917 | 12 | 2016-09-20 15:20:15 | 4,945,059 | 2016-09-20 15:31:12 | https://stackoverflow.com/q/39597481 | https://stackoverflow.com/a/39597917 | <p>Like this:</p>
<pre><code>for /d /r . %%d in (bin obj) do @if exist "%%d" rd /s/q "%%d"
</code></pre>
| <p>Like this:</p> <pre><code>for /d /r . %%d in (bin obj) do @if exist "%%d" rd /s/q "%%d" </code></pre> | 64, 1796, 7002, 30645, 40232 | batch-file, batch-processing, command, windows, windows-console | <h1>Windows cmd which removes every bin and obj folders</h1>
<p>I'm trying to write a windows script that will remove every <code>bin</code> and <code>obj</code> folder in my project folder. It just doesn't work..</p>
<p>I found <a href="https://stackoverflow.com/questions/521382/command-line-tool-to-delete-folder-wit... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,502 | cmd | # Windows cmd which removes every bin and obj folders
I'm trying to write a windows script that will remove every `bin` and `obj` folder in my project folder. It just doesn't work..
I found [this](https://stackoverflow.com/questions/521382/command-line-tool-to-delete-folder-with-a-specified-name-recursively-in-window... | Like this:
```
for /d /r . %%d in (bin obj) do @if exist "%%d" rd /s/q "%%d"
``` |
10948605 | Spring Batch - Executing multiple instances of a job at same time | 8 | 2012-06-08 12:10:26 | <p>I have a clarification.</p>
<p>Is it possible for us to run multiple instances of a job at the same time.</p>
<p>Currently, we have single instance of a job at any given time.</p>
<p>If it is possible, please let me know how to do it.</p>
| 17,990 | 1,369,783 | 2020-05-09 02:49:06 | 38,349,888 | 12 | 2016-07-13 11:05:05 | 169,792 | 2016-07-13 11:05:05 | https://stackoverflow.com/q/10948605 | https://stackoverflow.com/a/38349888 | <p>Yes you can. Spring Batch distinguishes jobs based on the JobParameters. So if you always pass different JobParameters to the same job, you will have multiple instances of the same job running.
A simple way is just to add a UUID parameter to each request to start a job.
Example:</p>
<pre><code>final JobParametersBu... | <p>Yes you can. Spring Batch distinguishes jobs based on the JobParameters. So if you always pass different JobParameters to the same job, you will have multiple instances of the same job running. A simple way is just to add a UUID parameter to each request to start a job. Example:</p> <pre><code>final JobParametersBu... | 41895 | spring-batch | <h1>Spring Batch - Executing multiple instances of a job at same time</h1>
<p>I have a clarification.</p>
<p>Is it possible for us to run multiple instances of a job at the same time.</p>
<p>Currently, we have single instance of a job at any given time.</p>
<p>If it is possible, please let me know how to do it.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,503 | cmd | # Spring Batch - Executing multiple instances of a job at same time
I have a clarification.
Is it possible for us to run multiple instances of a job at the same time.
Currently, we have single instance of a job at any given time.
If it is possible, please let me know how to do it. | Yes you can. Spring Batch distinguishes jobs based on the JobParameters. So if you always pass different JobParameters to the same job, you will have multiple instances of the same job running.
A simple way is just to add a UUID parameter to each request to start a job.
Example:
```
final JobParametersBuilder jobParam... |
32015333 | Executing a batch file in an R script | 8 | 2015-08-14 17:09:00 | <p>I would like to execute a batch file from a R script. The file is in a directory like <code>\\network\path\to\batch\file.bat</code>.</p>
<p>I know I can use the <code>system</code> command in R to run DOS commands but I can't simply use <code>system("start file.bat")</code>. So how would I best use R script to exec... | 15,052 | 4,227,893 | 2023-01-27 09:53:35 | 32,016,089 | 12 | 2015-08-14 17:58:49 | 5,228,418 | 2015-08-14 17:58:49 | https://stackoverflow.com/q/32015333 | https://stackoverflow.com/a/32016089 | <p>Try <code>shell.exec("\\\\network\\path\\file.bat")</code></p>
<p>The <code>shell.exec</code> command uses the Windows-associated application to open the file. Note the double back-ticks.</p>
<p>Pro tip: <code>write.csv(file='tmp.csv',tmpdat);shell.exec('tmp.csv')</code> is useful (assuming you've associated CSV ... | <p>Try <code>shell.exec("\\\\network\\path\\file.bat")</code></p> <p>The <code>shell.exec</code> command uses the Windows-associated application to open the file. Note the double back-ticks.</p> <p>Pro tip: <code>write.csv(file='tmp.csv',tmpdat);shell.exec('tmp.csv')</code> is useful (assuming you've associated CSV ... | 4452, 7002 | batch-file, r | <h1>Executing a batch file in an R script</h1>
<p>I would like to execute a batch file from a R script. The file is in a directory like <code>\\network\path\to\batch\file.bat</code>.</p>
<p>I know I can use the <code>system</code> command in R to run DOS commands but I can't simply use <code>system("start file.bat")</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,504 | cmd | # Executing a batch file in an R script
I would like to execute a batch file from a R script. The file is in a directory like `\\network\path\to\batch\file.bat`.
I know I can use the `system` command in R to run DOS commands but I can't simply use `system("start file.bat")`. So how would I best use R script to execut... | Try `shell.exec("\\\\network\\path\\file.bat")`
The `shell.exec` command uses the Windows-associated application to open the file. Note the double back-ticks.
Pro tip: `write.csv(file='tmp.csv',tmpdat);shell.exec('tmp.csv')` is useful (assuming you've associated CSV files with your preferred application for viewing C... |
27916091 | What's the difference between step sequence and flow in spring batch configuration? | 8 | 2015-01-13 06:25:38 | <p>I was reading spring io document.</p>
<p>the document shows two different examples</p>
<p>5.3.1 Sequential Flow</p>
<pre><code><job id="job">
<step id="stepA" parent="s1" next="stepB" />
<step id="stepB" parent="s2" next="stepC"/>
<step id="stepC" parent="s3" />
</job>
</... | 13,831 | 1,640,822 | 2019-05-10 19:56:01 | 27,916,819 | 12 | 2015-01-13 07:21:23 | 2,587,166 | 2015-01-13 07:21:23 | https://stackoverflow.com/q/27916091 | https://stackoverflow.com/a/27916819 | <p>The second form allow you to reuse <code>flow1</code> in another job.</p>
<pre><code><job id="job2">
<flow id="job2.flow1" parent="flow1" next="job2.step3"/>
<step id="job2.step3" parent="s3"/>
</job>
</code></pre>
<p>From official doc:</p>
<blockquote>
<p>The effect of defining ... | <p>The second form allow you to reuse <code>flow1</code> in another job.</p> <pre><code><job id="job2"> <flow id="job2.flow1" parent="flow1" next="job2.step3"/> <step id="job2.step3" parent="s3"/> </job> </code></pre> <p>From official doc:</p> <blockquote> <p>The effect of defining ... | 725, 41895 | configuration, spring-batch | <h1>What's the difference between step sequence and flow in spring batch configuration?</h1>
<p>I was reading spring io document.</p>
<p>the document shows two different examples</p>
<p>5.3.1 Sequential Flow</p>
<pre><code><job id="job">
<step id="stepA" parent="s1" next="stepB" />
<step id="s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,505 | cmd | # What's the difference between step sequence and flow in spring batch configuration?
I was reading spring io document.
the document shows two different examples
5.3.1 Sequential Flow
```
<job id="job">
<step id="stepA" parent="s1" next="stepB" />
<step id="stepB" parent="s2" next="stepC"/>
<step id="st... | The second form allow you to reuse `flow1` in another job.
```
<job id="job2">
<flow id="job2.flow1" parent="flow1" next="job2.step3"/>
<step id="job2.step3" parent="s3"/>
</job>
```
From official doc:
> The effect of defining an external flow like this is simply to insert
> the steps from the external flow ... |
26251171 | How set a variable and then use it in the same line in command prompt | 8 | 2014-10-08 07:17:15 | <p>I want to set a variable e.g. <code>%p%</code> and then use it in the same line in CMD.</p>
<p>e.g.:</p>
<pre><code>set p=notepad.exe&%p%
</code></pre>
<p>This not works. But <code>%p%</code> is set for the next line. Therefore if I execute this line for second time, it works.</p>
<p>How can I use <code>%p%<... | 2,966 | 1,132,686 | 2014-10-08 12:09:43 | 26,252,288 | 12 | 2014-10-08 08:23:29 | 2,861,476 | 2014-10-08 12:09:43 | https://stackoverflow.com/q/26251171 | https://stackoverflow.com/a/26252288 | <p>When you execute a batch file, each line or block of lines (lines enclosed in parenthesis) is first parsed and then executed. During the parse, the read operations on the variables are replaced with the value inside the variable <strong>before</strong> the commands are executed. So if in a line/block a variable valu... | <p>When you execute a batch file, each line or block of lines (lines enclosed in parenthesis) is first parsed and then executed. During the parse, the read operations on the variables are replaced with the value inside the variable <strong>before</strong> the commands are executed. So if in a line/block a variable valu... | 2631, 7002 | batch-file, cmd | <h1>How set a variable and then use it in the same line in command prompt</h1>
<p>I want to set a variable e.g. <code>%p%</code> and then use it in the same line in CMD.</p>
<p>e.g.:</p>
<pre><code>set p=notepad.exe&%p%
</code></pre>
<p>This not works. But <code>%p%</code> is set for the next line. Therefore if ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,506 | cmd | # How set a variable and then use it in the same line in command prompt
I want to set a variable e.g. `%p%` and then use it in the same line in CMD.
e.g.:
```
set p=notepad.exe&%p%
```
This not works. But `%p%` is set for the next line. Therefore if I execute this line for second time, it works.
How can I use `%p%... | When you execute a batch file, each line or block of lines (lines enclosed in parenthesis) is first parsed and then executed. During the parse, the read operations on the variables are replaced with the value inside the variable **before** the commands are executed. So if in a line/block a variable value is changed, yo... |
25583161 | Rename multiple files in a directory using batch script | 8 | 2014-08-30 14:00:53 | <p>I have about 1000 images and they have name like "IMG-12223". I want to rename them to 1 2 3 4 ... 1000. How can I do that. I have written a batch script which list the files but I don't know how to rename each file. e.g. rename first image with name "IMG-12223" to 1 , second image with name "IMG-23441" to 2 and so... | 42,391 | 1,986,149 | 2017-08-08 12:25:41 | 25,583,317 | 12 | 2014-08-30 14:17:31 | 2,749,114 | 2014-08-31 04:33:12 | https://stackoverflow.com/q/25583161 | https://stackoverflow.com/a/25583317 | <p>Here's the script. Just put the script in your folder and run it.</p>
<pre><code>@echo off & setlocal EnableDelayedExpansion
set a=1
for /f "delims=" %%i in ('dir /b *') do (
if not "%%~nxi"=="%~nx0" (
ren "%%i" "!a!"
set /a a+=1
)
)
</code></pre>
<p>If you want to keep the extensions, i.e. ren... | <p>Here's the script. Just put the script in your folder and run it.</p> <pre><code>@echo off & setlocal EnableDelayedExpansion set a=1 for /f "delims=" %%i in ('dir /b *') do ( if not "%%~nxi"=="%~nx0" ( ren "%%i" "!a!" set /a a+=1 ) ) </code></pre> <p>If you want to keep the extensions, i.e. ren... | 4510, 5310, 7002 | batch-file, file, rename | <h1>Rename multiple files in a directory using batch script</h1>
<p>I have about 1000 images and they have name like "IMG-12223". I want to rename them to 1 2 3 4 ... 1000. How can I do that. I have written a batch script which list the files but I don't know how to rename each file. e.g. rename first image with name ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,507 | cmd | # Rename multiple files in a directory using batch script
I have about 1000 images and they have name like "IMG-12223". I want to rename them to 1 2 3 4 ... 1000. How can I do that. I have written a batch script which list the files but I don't know how to rename each file. e.g. rename first image with name "IMG-12223... | Here's the script. Just put the script in your folder and run it.
```
@echo off & setlocal EnableDelayedExpansion
set a=1
for /f "delims=" %%i in ('dir /b *') do (
if not "%%~nxi"=="%~nx0" (
ren "%%i" "!a!"
set /a a+=1
)
)
```
If you want to keep the extensions, i.e. rename "IMG-12223.jpg", "IMG-12224.... |
14282788 | Windows Batch File Time Comparison | 8 | 2013-01-11 16:48:38 | <p>I am trying to compare current system time to a set time. Please see below:</p>
<pre><code> set currentTime=%TIME%
set flag=false
if %currentTime% geq 07:00 if %currentTime% leq 22:45 set flag=true
if %flag%==true (
) else (
)
</code></pre>
<p>If the time is between 7 am and 10:45pm then perform this act... | 12,707 | 393,440 | 2013-01-11 18:34:26 | 14,284,514 | 12 | 2013-01-11 18:34:26 | 891,976 | 2013-01-11 18:34:26 | https://stackoverflow.com/q/14282788 | https://stackoverflow.com/a/14284514 | <p>The reason your script is failing is for time before 10 AM. When the time is less than 10, the %Time% variable returns this format: <code>" H:MM:SS:ss"</code>. However when 10 or later the <code>%Time%</code> variable returns this format: <code>"HH:MM:SS:ss"</code>.</p>
<p>Note the missing <code>0</code> at the b... | <p>The reason your script is failing is for time before 10 AM. When the time is less than 10, the %Time% variable returns this format: <code>" H:MM:SS:ss"</code>. However when 10 or later the <code>%Time%</code> variable returns this format: <code>"HH:MM:SS:ss"</code>.</p> <p>Note the missing <code>0</code> at the b... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Windows Batch File Time Comparison</h1>
<p>I am trying to compare current system time to a set time. Please see below:</p>
<pre><code> set currentTime=%TIME%
set flag=false
if %currentTime% geq 07:00 if %currentTime% leq 22:45 set flag=true
if %flag%==true (
) else (
)
</code></pre>
<p>If the time is be... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,508 | cmd | # Windows Batch File Time Comparison
I am trying to compare current system time to a set time. Please see below:
```
set currentTime=%TIME%
set flag=false
if %currentTime% geq 07:00 if %currentTime% leq 22:45 set flag=true
if %flag%==true (
) else (
)
```
If the time is between 7 am and 10:45pm then perfo... | The reason your script is failing is for time before 10 AM. When the time is less than 10, the %Time% variable returns this format: `" H:MM:SS:ss"`. However when 10 or later the `%Time%` variable returns this format: `"HH:MM:SS:ss"`.
Note the missing `0` at the beggining of the times before `10` is missing. This cause... |
9337415 | How do you have shared log files under Windows? | 8 | 2012-02-18 00:43:10 | <p>I have several different processes and I would like them to all log to the same file. These processes are running on a Windows 7 system. Some are python scripts and others are <code>cmd</code> batch files.</p>
<p>Under Unix you'd just have everybody open the file in append mode and write away. As long as each proce... | 4,183 | 167,958 | 2017-10-13 16:38:05 | 9,344,547 | 12 | 2012-02-18 22:03:55 | 1,012,053 | 2013-09-15 12:26:33 | https://stackoverflow.com/q/9337415 | https://stackoverflow.com/a/9344547 | <p>It is possible to have multiple batch processes safely write to a single log file. I know nothing about Python, but I imagine the concepts in this answer could be integrated with Python.</p>
<p>Windows allows at most one process to have a specific file open for write access at any point in time. This can be used to... | <p>It is possible to have multiple batch processes safely write to a single log file. I know nothing about Python, but I imagine the concepts in this answer could be integrated with Python.</p> <p>Windows allows at most one process to have a specific file open for write access at any point in time. This can be used to... | 16, 64, 942, 3227, 7002 | batch-file, locking, logging, python, windows | <h1>How do you have shared log files under Windows?</h1>
<p>I have several different processes and I would like them to all log to the same file. These processes are running on a Windows 7 system. Some are python scripts and others are <code>cmd</code> batch files.</p>
<p>Under Unix you'd just have everybody open the ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,509 | cmd | # How do you have shared log files under Windows?
I have several different processes and I would like them to all log to the same file. These processes are running on a Windows 7 system. Some are python scripts and others are `cmd` batch files.
Under Unix you'd just have everybody open the file in append mode and wri... | It is possible to have multiple batch processes safely write to a single log file. I know nothing about Python, but I imagine the concepts in this answer could be integrated with Python.
Windows allows at most one process to have a specific file open for write access at any point in time. This can be used to implement... |
2840574 | Why Java programs use .bat file as program launcher? | 8 | 2010-05-15 15:07:48 | <p>I found that a lot of Java programs in Windows use .bat batch file as program launcher. It looks weird if compared with other programs which use .exe executable file.</p>
<p>Why can't those Java programs use .exe file? Is that a limitation of Java program?</p>
<p>Thanks.</p>
| 3,772 | 330,372 | 2010-05-23 21:22:11 | 2,840,921 | 12 | 2010-05-15 16:50:29 | 342,003 | 2010-05-16 13:47:43 | https://stackoverflow.com/q/2840574 | https://stackoverflow.com/a/2840921 | <p>It's pretty easy to just create a .bat file and include the <code>java -jar <archive-path></code> in it and you have it running. You can edit the .bat file easily and configure it more. All you need is notepad.</p>
<p>Also it looks pretty much like bash script files for Linux for example. This makes a .bat fi... | <p>It's pretty easy to just create a .bat file and include the <code>java -jar <archive-path></code> in it and you have it running. You can edit the .bat file easily and configure it more. All you need is notepad.</p> <p>Also it looks pretty much like bash script files for Linux for example. This makes a .bat fi... | 17, 7002 | batch-file, java | <h1>Why Java programs use .bat file as program launcher?</h1>
<p>I found that a lot of Java programs in Windows use .bat batch file as program launcher. It looks weird if compared with other programs which use .exe executable file.</p>
<p>Why can't those Java programs use .exe file? Is that a limitation of Java progra... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,510 | cmd | # Why Java programs use .bat file as program launcher?
I found that a lot of Java programs in Windows use .bat batch file as program launcher. It looks weird if compared with other programs which use .exe executable file.
Why can't those Java programs use .exe file? Is that a limitation of Java program?
Thanks. | It's pretty easy to just create a .bat file and include the `java -jar <archive-path>` in it and you have it running. You can edit the .bat file easily and configure it more. All you need is notepad.
Also it looks pretty much like bash script files for Linux for example. This makes a .bat file for execution a program ... |
1461910 | How to log text displayed in a Windows XP command line application | 8 | 2009-09-22 18:48:37 | <p>Is there a simple way to log everything that appears on the command line on Windows?</p>
<p>I have a batch file that is running some things, but everything flies by so fast I cannot see if any errors have occurred.</p>
| 30,738 | 5,653 | 2015-10-09 21:04:53 | 1,461,933 | 12 | 2009-09-22 18:51:57 | 103,043 | 2015-10-09 21:04:53 | https://stackoverflow.com/q/1461910 | https://stackoverflow.com/a/1461933 | <p>You can redirect the results to a file:</p>
<pre><code>C:\> myBatch.bat > myBatch.log
</code></pre>
<p>The above will redirect standard output to a file called <code>myBatch.log</code>.</p>
<p>If you need to redirect standard error to this file as well, you can append <code>2>&1</code> to the command... | <p>You can redirect the results to a file:</p> <pre><code>C:\> myBatch.bat > myBatch.log </code></pre> <p>The above will redirect standard output to a file called <code>myBatch.log</code>.</p> <p>If you need to redirect standard error to this file as well, you can append <code>2>&1</code> to the command... | 2631 | cmd | <h1>How to log text displayed in a Windows XP command line application</h1>
<p>Is there a simple way to log everything that appears on the command line on Windows?</p>
<p>I have a batch file that is running some things, but everything flies by so fast I cannot see if any errors have occurred.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,511 | cmd | # How to log text displayed in a Windows XP command line application
Is there a simple way to log everything that appears on the command line on Windows?
I have a batch file that is running some things, but everything flies by so fast I cannot see if any errors have occurred. | You can redirect the results to a file:
```
C:\> myBatch.bat > myBatch.log
```
The above will redirect standard output to a file called `myBatch.log`.
If you need to redirect standard error to this file as well, you can append `2>&1` to the command:
```
C:\> myBatch.bat > myBatch.log 2>&1
```
Note that the single ... |
66967270 | ERR undefined while installing airbnb eslint | 7 | 2021-04-06 10:54:04 | <pre><code>npx install-peerdeps --dev eslint-config-airbnb
install-peerdeps v3.0.3
Installing peerdeps for eslint-config-airbnb@latest.
npm install eslint-config-airbnb@18.2.1 eslint@^7.2.0 eslint-plugin-import@^2.22.1 eslint-plugin-jsx-a11y@^6.4.1 eslint-plugin-react@^7.21.5 eslint-plugin-react-hooks@^1.7.0 --save-dev... | 4,857 | 14,614,914 | 2021-09-24 10:16:24 | 67,375,717 | 12 | 2021-05-03 20:55:17 | 1,265,167 | 2021-05-03 20:55:17 | https://stackoverflow.com/q/66967270 | https://stackoverflow.com/a/67375717 | <p>I resolved this by explicitly installing the dependent npm packages i.e. <code>npm install [package]@[version] --save-dev</code> rather than using the <code>npx install-peerdeps</code> shortcut.</p>
<p>The npm package page for <a href="https://www.npmjs.com/package/eslint-config-airbnb" rel="noreferrer">eslint-confi... | <p>I resolved this by explicitly installing the dependent npm packages i.e. <code>npm install [package]@[version] --save-dev</code> rather than using the <code>npx install-peerdeps</code> shortcut.</p> <p>The npm package page for <a href="https://www.npmjs.com/package/eslint-config-airbnb" rel="noreferrer">eslint-confi... | 2631, 46426, 61387, 78230, 125517 | cmd, eslint-config-airbnb, node.js, node-modules, npm | <h1>ERR undefined while installing airbnb eslint</h1>
<pre><code>npx install-peerdeps --dev eslint-config-airbnb
install-peerdeps v3.0.3
Installing peerdeps for eslint-config-airbnb@latest.
npm install eslint-config-airbnb@18.2.1 eslint@^7.2.0 eslint-plugin-import@^2.22.1 eslint-plugin-jsx-a11y@^6.4.1 eslint-plugin-rea... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,512 | cmd | # ERR undefined while installing airbnb eslint
```
npx install-peerdeps --dev eslint-config-airbnb
install-peerdeps v3.0.3
Installing peerdeps for eslint-config-airbnb@latest.
npm install eslint-config-airbnb@18.2.1 eslint@^7.2.0 eslint-plugin-import@^2.22.1 eslint-plugin-jsx-a11y@^6.4.1 eslint-plugin-react@^7.21.5 es... | I resolved this by explicitly installing the dependent npm packages i.e. `npm install [package]@[version] --save-dev` rather than using the `npx install-peerdeps` shortcut.
The npm package page for [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb) details how to list the dependencies using: `n... |
54284559 | Get all files with a specific extension | 7 | 2019-01-21 06:33:11 | <p>I am trying to get a file with a specific extension from a directory. To do that I am using the following batch file code:</p>
<pre><code>for %%f in (.\*.ext) do (
echo %%f
)
</code></pre>
<p>This works fine, unless I have a file with <code>.extsomething</code> extension.<br>
I tried adding the <code>$</code>... | 31,085 | 10,547,018 | 2023-11-14 14:25:27 | 54,284,672 | 12 | 2019-01-21 06:44:34 | null | 2019-01-21 18:45:10 | https://stackoverflow.com/q/54284559 | https://stackoverflow.com/a/54284672 | <p>Just add an <code>if</code> statement:</p>
<pre><code>@echo off
for %%f in (*.ext) do (
if "%%~xf"==".ext" echo %%f
)
</code></pre>
| <p>Just add an <code>if</code> statement:</p> <pre><code>@echo off for %%f in (*.ext) do ( if "%%~xf"==".ext" echo %%f ) </code></pre> | 2631, 7002 | batch-file, cmd | <h1>Get all files with a specific extension</h1>
<p>I am trying to get a file with a specific extension from a directory. To do that I am using the following batch file code:</p>
<pre><code>for %%f in (.\*.ext) do (
echo %%f
)
</code></pre>
<p>This works fine, unless I have a file with <code>.extsomething</code>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,513 | cmd | # Get all files with a specific extension
I am trying to get a file with a specific extension from a directory. To do that I am using the following batch file code:
```
for %%f in (.\*.ext) do (
echo %%f
)
```
This works fine, unless I have a file with `.extsomething` extension.
I tried adding the `$` wildcar... | Just add an `if` statement:
```
@echo off
for %%f in (*.ext) do (
if "%%~xf"==".ext" echo %%f
)
``` |
25883365 | 'Pyuic4' is not recognized as an internal external command | 7 | 2014-09-17 06:04:34 | <p>Im trying to compile a ui file by using Pyuic, but i can't get it to work...
Every time i try using the command </p>
<blockquote>
<p>pyuic4 -o OutFile_ui.py InFile.ui</p>
</blockquote>
<p>it just givet me this error </p>
<blockquote>
<p>C:\Windows\system32>pyuic4 'pyuic4' is not recognized as an internal
or... | 37,223 | 4,021,630 | 2018-11-20 10:04:29 | 25,883,418 | 12 | 2014-09-17 06:08:54 | 1,665,093 | 2014-09-17 06:08:54 | https://stackoverflow.com/q/25883365 | https://stackoverflow.com/a/25883418 | <p>When you install <code>PyQt</code>, it gets install under Python's <code>site-packages</code>.</p>
<p>There is a batch file <code>pyuic.bat</code> under the <code><PYTHON_INSTALL_DIR>\Lib\site-packages\PyQt4</code>. Use this batch to run your command.</p>
<p>If you look into the content of the batch file you... | <p>When you install <code>PyQt</code>, it gets install under Python's <code>site-packages</code>.</p> <p>There is a batch file <code>pyuic.bat</code> under the <code><PYTHON_INSTALL_DIR>\Lib\site-packages\PyQt4</code>. Use this batch to run your command.</p> <p>If you look into the content of the batch file you... | 2631, 5313, 6159, 98126 | cmd, external, pyqt, pyuic | <h1>'Pyuic4' is not recognized as an internal external command</h1>
<p>Im trying to compile a ui file by using Pyuic, but i can't get it to work...
Every time i try using the command </p>
<blockquote>
<p>pyuic4 -o OutFile_ui.py InFile.ui</p>
</blockquote>
<p>it just givet me this error </p>
<blockquote>
<p>C:\Wi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,514 | cmd | # 'Pyuic4' is not recognized as an internal external command
Im trying to compile a ui file by using Pyuic, but i can't get it to work...
Every time i try using the command
> pyuic4 -o OutFile_ui.py InFile.ui
it just givet me this error
> C:\Windows\system32>pyuic4 'pyuic4' is not recognized as an internal
> or ext... | When you install `PyQt`, it gets install under Python's `site-packages`.
There is a batch file `pyuic.bat` under the `<PYTHON_INSTALL_DIR>\Lib\site-packages\PyQt4`. Use this batch to run your command.
If you look into the content of the batch file you will see that it calls the Python interpreter with `PyQt4\uic\pyui... |
25162348 | Find the version of a installed program from batch file | 7 | 2014-08-06 13:58:20 | <p>We have a batch file that installs several programs as part of the developers setup. This is ran periodically when we get new versions of used components. So it would be nice only to install if the versions are different.</p>
<p>At the command prompt I can run this and get back the version installed:</p>
<pre><cod... | 49,919 | 342 | 2020-10-22 04:23:53 | 25,163,332 | 12 | 2014-08-06 14:41:16 | 1,012,053 | 2014-08-07 11:04:50 | https://stackoverflow.com/q/25162348 | https://stackoverflow.com/a/25163332 | <p>You have a set of misplaced double quotes, as well as an extra <code>(</code>.</p>
<p>WMIC uses SQL syntax, and strings are enclosed in single quotes.The internal single quotes do not interfere with the command enclosing single quotes.</p>
<p>You can put double quotes around the WHERE clause (not including the WHE... | <p>You have a set of misplaced double quotes, as well as an extra <code>(</code>.</p> <p>WMIC uses SQL syntax, and strings are enclosed in single quotes.The internal single quotes do not interfere with the command enclosing single quotes.</p> <p>You can put double quotes around the WHERE clause (not including the WHE... | 7002, 61774 | batch-file, wmic | <h1>Find the version of a installed program from batch file</h1>
<p>We have a batch file that installs several programs as part of the developers setup. This is ran periodically when we get new versions of used components. So it would be nice only to install if the versions are different.</p>
<p>At the command prompt ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,515 | cmd | # Find the version of a installed program from batch file
We have a batch file that installs several programs as part of the developers setup. This is ran periodically when we get new versions of used components. So it would be nice only to install if the versions are different.
At the command prompt I can run this a... | You have a set of misplaced double quotes, as well as an extra `(`.
WMIC uses SQL syntax, and strings are enclosed in single quotes.The internal single quotes do not interfere with the command enclosing single quotes.
You can put double quotes around the WHERE clause (not including the WHERE keyword) to avoid some es... |
24658745 | WMIC: how to use **process call create** with a specific working directory? | 7 | 2014-07-09 16:10:38 | <p>The task is to launch a program using <code>wmic process call create "c:\folder\app.exe"</code> and have <code>app.exe</code> access it's own support files in the <code>app.exe home folder tree</code>.</p>
<p>The batch script below illustrates the problem with WMIC silently changing the working directory, so that t... | 54,988 | 2,299,431 | 2015-09-29 16:36:15 | 24,658,880 | 12 | 2014-07-09 16:18:28 | 2,861,476 | 2014-07-09 16:18:28 | https://stackoverflow.com/q/24658745 | https://stackoverflow.com/a/24658880 | <p>Run </p>
<pre><code>wmic process call create /?
</code></pre>
<p>to get the information on why this</p>
<pre><code>wmic process call create "c:\folder\app.exe","c:\folder"
</code></pre>
<p>should work</p>
| <p>Run </p> <pre><code>wmic process call create /? </code></pre> <p>to get the information on why this</p> <pre><code>wmic process call create "c:\folder\app.exe","c:\folder" </code></pre> <p>should work</p> | 64, 7002, 61774 | batch-file, windows, wmic | <h1>WMIC: how to use **process call create** with a specific working directory?</h1>
<p>The task is to launch a program using <code>wmic process call create "c:\folder\app.exe"</code> and have <code>app.exe</code> access it's own support files in the <code>app.exe home folder tree</code>.</p>
<p>The batch script below... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,516 | cmd | # WMIC: how to use **process call create** with a specific working directory?
The task is to launch a program using `wmic process call create "c:\folder\app.exe"` and have `app.exe` access it's own support files in the `app.exe home folder tree`.
The batch script below illustrates the problem with WMIC silently chang... | Run
```
wmic process call create /?
```
to get the information on why this
```
wmic process call create "c:\folder\app.exe","c:\folder"
```
should work |
21802815 | ConEmu commands in task | 7 | 2014-02-15 19:54:45 | <p>I'm trying to get a Task in ConEmu to open several consoles, and for each run a batch-like script when opened. For example:</p>
<ul>
<li>Open a Git Bash, name the console "X", set the current directory to "Y".</li>
<li>Open another Git Bash and run a set of commands, for example "cd A/B/C", "vagrant up"</li>
<li>Op... | 11,104 | 603,387 | 2014-02-15 21:22:45 | 21,803,819 | 12 | 2014-02-15 21:22:45 | 1,405,560 | 2014-02-15 21:22:45 | https://stackoverflow.com/q/21802815 | https://stackoverflow.com/a/21803819 | <p>No colon is needed between switches (<code>n</code> & <code>t</code> for example).</p>
<p><code>cmd</code> has <code>/k</code> switch to run commands.</p>
<p>I don't know the way to tell bash "run this command and stay in prompt". May be you need to run commands with <code>&</code>. I'm not sure about seco... | <p>No colon is needed between switches (<code>n</code> & <code>t</code> for example).</p> <p><code>cmd</code> has <code>/k</code> switch to run commands.</p> <p>I don't know the way to tell bash "run this command and stay in prompt". May be you need to run commands with <code>&</code>. I'm not sure about seco... | 7002, 85755 | batch-file, conemu | <h1>ConEmu commands in task</h1>
<p>I'm trying to get a Task in ConEmu to open several consoles, and for each run a batch-like script when opened. For example:</p>
<ul>
<li>Open a Git Bash, name the console "X", set the current directory to "Y".</li>
<li>Open another Git Bash and run a set of commands, for example "cd... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,517 | cmd | # ConEmu commands in task
I'm trying to get a Task in ConEmu to open several consoles, and for each run a batch-like script when opened. For example:
- Open a Git Bash, name the console "X", set the current directory to "Y".
- Open another Git Bash and run a set of commands, for example "cd A/B/C", "vagrant up"
- Ope... | No colon is needed between switches (`n` & `t` for example).
`cmd` has `/k` switch to run commands.
I don't know the way to tell bash "run this command and stay in prompt". May be you need to run commands with `&`. I'm not sure about second line, you need to check it yourself.
```
"%ProgramFiles(x86)%\Git\bin\sh.exe... |
21367518 | Is it possible to echo some non-printable characters in batch/cmd? | 7 | 2014-01-26 18:32:41 | <p><strong>motivation</strong></p>
<p>I have a 3rd party, somehow long .bat file written for some specific function and would take considerable effort to re-write (which effort is also hindered by my problem). In for loops the most basic way to debug it would seem echoing some information to the screen. I used to do t... | 6,761 | 611,007 | 2020-10-22 16:30:02 | 21,369,945 | 12 | 2014-01-26 22:10:21 | 1,012,053 | 2014-04-29 18:01:44 | https://stackoverflow.com/q/21367518 | https://stackoverflow.com/a/21369945 | <p>You need two hacks - one to define a carriage return character, and another to echo a line of text without issuing the newline character.</p>
<p><strong>1) Define carriage return.</strong></p>
<pre><code>:: Define CR to contain a carriage return (0x0D)
for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
</code>... | <p>You need two hacks - one to define a carriage return character, and another to echo a line of text without issuing the newline character.</p> <p><strong>1) Define carriage return.</strong></p> <pre><code>:: Define CR to contain a carriage return (0x0D) for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A" </code>... | 64, 2631, 7002, 14899, 45170 | batch-file, carriage-return, cmd, non-printing-characters, windows | <h1>Is it possible to echo some non-printable characters in batch/cmd?</h1>
<p><strong>motivation</strong></p>
<p>I have a 3rd party, somehow long .bat file written for some specific function and would take considerable effort to re-write (which effort is also hindered by my problem). In for loops the most basic way t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,518 | cmd | # Is it possible to echo some non-printable characters in batch/cmd?
**motivation**
I have a 3rd party, somehow long .bat file written for some specific function and would take considerable effort to re-write (which effort is also hindered by my problem). In for loops the most basic way to debug it would seem echoing... | You need two hacks - one to define a carriage return character, and another to echo a line of text without issuing the newline character.
**1) Define carriage return.**
```
:: Define CR to contain a carriage return (0x0D)
for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
```
Once defined, the value can only be ... |
21338903 | Specify exit code in batch exit | 7 | 2014-01-24 17:37:01 | <p>I need to specify my own exit code in my batch script when it successful exits on a if exist clause. As you will notice, I specified it as an <code>exit 5</code>, I have also tried <code>exit /b 5</code> but nothing has worked. Any suggestions?</p>
<pre><code>@ECHO OFF
CLS
set SOURCE_PARENT=%1
set FOLDER=%2
set TA... | 13,791 | 2,682,661 | 2025-03-20 13:30:50 | 21,339,045 | 12 | 2014-01-24 17:44:38 | 2,970,379 | 2014-01-24 17:44:38 | https://stackoverflow.com/q/21338903 | https://stackoverflow.com/a/21339045 | <p>If you have a script script.bat containing:</p>
<pre><code>@echo off
echo Hello from script.
exit /b 5
</code></pre>
<p>In the command prompt or from another script call </p>
<pre><code>test.bat
echo %errorlevel%
</code></pre>
<p>It should show:</p>
<blockquote>
<p>C:\Temp>script.bat</p>
<p>Hello from sc... | <p>If you have a script script.bat containing:</p> <pre><code>@echo off echo Hello from script. exit /b 5 </code></pre> <p>In the command prompt or from another script call </p> <pre><code>test.bat echo %errorlevel% </code></pre> <p>It should show:</p> <blockquote> <p>C:\Temp>script.bat</p> <p>Hello from sc... | 7002, 10021 | batch-file, exit-code | <h1>Specify exit code in batch exit</h1>
<p>I need to specify my own exit code in my batch script when it successful exits on a if exist clause. As you will notice, I specified it as an <code>exit 5</code>, I have also tried <code>exit /b 5</code> but nothing has worked. Any suggestions?</p>
<pre><code>@ECHO OFF
CLS
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,519 | cmd | # Specify exit code in batch exit
I need to specify my own exit code in my batch script when it successful exits on a if exist clause. As you will notice, I specified it as an `exit 5`, I have also tried `exit /b 5` but nothing has worked. Any suggestions?
```
@ECHO OFF
CLS
set SOURCE_PARENT=%1
set FOLDER=%2
set TAR... | If you have a script script.bat containing:
```
@echo off
echo Hello from script.
exit /b 5
```
In the command prompt or from another script call
```
test.bat
echo %errorlevel%
```
It should show:
> C:\Temp>script.bat
>
> Hello from script.
>
> C:\Temp>echo %errorlevel%
>
> 5 |
20965846 | how to execute SQL statements in command prompt (CMD) | 7 | 2014-01-07 07:06:35 | <p>how to execute SQL statements in command prompt (CMD),</p>
<p>I'm using SQL Server 2012 in windows 8 OS.</p>
<p>I have tried sqlplus and sqlcmd, both are giving error "</p>
<p><img src="https://i.sstatic.net/WFloK.png" alt="enter image description here" /></p>
| 91,318 | 3,138,542 | 2022-04-25 09:22:20 | 20,965,899 | 12 | 2014-01-07 07:09:46 | 2,223,788 | 2014-01-07 08:13:17 | https://stackoverflow.com/q/20965846 | https://stackoverflow.com/a/20965899 | <p>You are looking for the <code>sqlcmd</code> utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt</p>
<pre><code>sqlcmd -U myLogin -P myPassword -S MyServerName -d MyDatabaseName
-Q "query"
</code></pre>
<p>Refer <a href="http://msdn.microsoft.com/en-us/library/... | <p>You are looking for the <code>sqlcmd</code> utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt</p> <pre><code>sqlcmd -U myLogin -P myPassword -S MyServerName -d MyDatabaseName -Q "query" </code></pre> <p>Refer <a href="http://msdn.microsoft.com/en-us/library/... | 22, 72, 2631 | cmd, sql, sql-server | <h1>how to execute SQL statements in command prompt (CMD)</h1>
<p>how to execute SQL statements in command prompt (CMD),</p>
<p>I'm using SQL Server 2012 in windows 8 OS.</p>
<p>I have tried sqlplus and sqlcmd, both are giving error "</p>
<p><img src="https://i.sstatic.net/WFloK.png" alt="enter image description h... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,520 | cmd | # how to execute SQL statements in command prompt (CMD)
how to execute SQL statements in command prompt (CMD),
I'm using SQL Server 2012 in windows 8 OS.
I have tried sqlplus and sqlcmd, both are giving error "
 | You are looking for the `sqlcmd` utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt
```
sqlcmd -U myLogin -P myPassword -S MyServerName -d MyDatabaseName
-Q "query"
```
Refer [this](http://msdn.microsoft.com/en-us/library/ms162773.aspx)
Edit: The OP said The `s... |
19304652 | Run a batch file from Task Scheduler is not working with a java command | 7 | 2013-10-10 19:32:43 | <p>Run a batch file from Task Scheduler is not working with a java command inside the .bat file. If I run the .bat file manually its working good.</p>
<p>Here is the simple .bat file I'm trying to schedule</p>
<pre><code>set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_24;
set CMD= "%JAVA_HOME%\bin\java" -version
... | 43,110 | 2,371,505 | 2026-01-21 08:29:50 | 19,304,983 | 12 | 2013-10-10 19:53:06 | 591,064 | 2019-06-04 11:47:48 | https://stackoverflow.com/q/19304652 | https://stackoverflow.com/a/19304983 | <p>When you type <code>batchfile.bat</code> on the command line, you are telling <code>cmd.exe</code> to read the file and execute each line it finds in it. When you double-click on your batch file in explorer, it calls <code>cmd.exe</code> for you, after reading the file associations in the registry.</p>
<p>Task Mana... | <p>When you type <code>batchfile.bat</code> on the command line, you are telling <code>cmd.exe</code> to read the file and execute each line it finds in it. When you double-click on your batch file in explorer, it calls <code>cmd.exe</code> for you, after reading the file associations in the registry.</p> <p>Task Mana... | 64, 7002, 9299 | batch-file, scheduled-tasks, windows | <h1>Run a batch file from Task Scheduler is not working with a java command</h1>
<p>Run a batch file from Task Scheduler is not working with a java command inside the .bat file. If I run the .bat file manually its working good.</p>
<p>Here is the simple .bat file I'm trying to schedule</p>
<pre><code>set JAVA_HOME=C:... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,521 | cmd | # Run a batch file from Task Scheduler is not working with a java command
Run a batch file from Task Scheduler is not working with a java command inside the .bat file. If I run the .bat file manually its working good.
Here is the simple .bat file I'm trying to schedule
```
set JAVA_HOME=C:\Program Files (x86)\Java\j... | When you type `batchfile.bat` on the command line, you are telling `cmd.exe` to read the file and execute each line it finds in it. When you double-click on your batch file in explorer, it calls `cmd.exe` for you, after reading the file associations in the registry.
Task Manager is not so kind.
So for your task to wo... |
16223199 | Suppress "The program can't start because X.dll is missing" error popup | 7 | 2013-04-25 19:30:14 | <p>I have a Python program which uses <code>os.system</code> to execute various commands. (It can't use <code>subprocess</code> because it has to be backward compatible all the way to Python 2.0.)</p>
<p>On Windows, sometimes the command references DLLs in an unusual directory, and so I get the infamous "The program ... | 2,636 | 388,520 | 2013-04-30 16:25:25 | 16,304,666 | 12 | 2013-04-30 16:25:25 | 388,520 | 2013-04-30 16:25:25 | https://stackoverflow.com/q/16223199 | https://stackoverflow.com/a/16304666 | <p>The dialog box can be disabled for the calling process with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621%28v=vs.85%29.aspx" rel="noreferrer"><code>SetErrorMode</code></a>. However, you have to read the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175%28v=vs.85%2... | <p>The dialog box can be disabled for the calling process with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621%28v=vs.85%29.aspx" rel="noreferrer"><code>SetErrorMode</code></a>. However, you have to read the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175%28v=vs.85%2... | 16, 64, 2631 | cmd, python, windows | <h1>Suppress "The program can't start because X.dll is missing" error popup</h1>
<p>I have a Python program which uses <code>os.system</code> to execute various commands. (It can't use <code>subprocess</code> because it has to be backward compatible all the way to Python 2.0.)</p>
<p>On Windows, sometimes the command... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,522 | cmd | # Suppress "The program can't start because X.dll is missing" error popup
I have a Python program which uses `os.system` to execute various commands. (It can't use `subprocess` because it has to be backward compatible all the way to Python 2.0.)
On Windows, sometimes the command references DLLs in an unusual director... | The dialog box can be disabled for the calling process with [`SetErrorMode`](http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621%28v=vs.85%29.aspx). However, you have to read the [`LoadLibrary`](http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175%28v=vs.85%29.aspx) documentation to discover th... |
13013378 | Read lines with blank spaces from a file using batch | 7 | 2012-10-22 14:19:17 | <p>I'm trying to read each line from a text file using batch. </p>
<p>The lines inside the file has <strong>some blank spaces</strong>, so this is an example of the input:</p>
<pre><code>This is the first line
This is the second line
...
</code></pre>
<p>I'm using the following source code</p>
<pre><code>FOR /f %%a... | 13,410 | 402,081 | 2025-04-07 13:29:52 | 13,014,064 | 12 | 2012-10-22 14:54:20 | 187,864 | 2012-10-22 14:54:20 | https://stackoverflow.com/q/13013378 | https://stackoverflow.com/a/13014064 | <p>try this.</p>
<pre><code>FOR /f "tokens=* delims=," %%a in ('type "%1"') do (
@echo %%a
)
</code></pre>
| <p>try this.</p> <pre><code>FOR /f "tokens=* delims=," %%a in ('type "%1"') do ( @echo %%a ) </code></pre> | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Read lines with blank spaces from a file using batch</h1>
<p>I'm trying to read each line from a text file using batch. </p>
<p>The lines inside the file has <strong>some blank spaces</strong>, so this is an example of the input:</p>
<pre><code>This is the first line
This is the second line
...
</code></pre>
<p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 13,523 | cmd | # Read lines with blank spaces from a file using batch
I'm trying to read each line from a text file using batch.
The lines inside the file has **some blank spaces**, so this is an example of the input:
```
This is the first line
This is the second line
...
```
I'm using the following source code
```
FOR /f %%a in... | try this.
```
FOR /f "tokens=* delims=," %%a in ('type "%1"') do (
@echo %%a
)
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.