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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
30786382 | Spring batch difference between Multithreading vs partitioning | 14 | 2015-06-11 16:28:21 | <p>I cannot understand the difference between multi-threading and partitioning in Spring batch. The implementation is of course different: In partitioning you need to prepare the partitions then process it. I want to know what is the difference and which one is more efficient way to process when the bottleneck is the i... | 12,184 | 1,057,347 | 2019-03-25 03:30:59 | 30,788,168 | 29 | 2015-06-11 18:01:18 | 618,059 | 2015-06-11 18:01:18 | https://stackoverflow.com/q/30786382 | https://stackoverflow.com/a/30788168 | <p><strong>TL;DR;</strong><br>
Neither approach is intended to help when the bottleneck is in the processor. You will see some gains by having multiple items going through a processor at the same time, but both of the options you point out get their full benefits when used in processes that are I/O bound. The <code>A... | <p><strong>TL;DR;</strong><br> Neither approach is intended to help when the bottleneck is in the processor. You will see some gains by having multiple items going through a processor at the same time, but both of the options you point out get their full benefits when used in processes that are I/O bound. The <code>A... | 1211, 1381, 41895 | multithreading, spring, spring-batch | <h1>Spring batch difference between Multithreading vs partitioning</h1>
<p>I cannot understand the difference between multi-threading and partitioning in Spring batch. The implementation is of course different: In partitioning you need to prepare the partitions then process it. I want to know what is the difference and... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,627 | cmd | # Spring batch difference between Multithreading vs partitioning
I cannot understand the difference between multi-threading and partitioning in Spring batch. The implementation is of course different: In partitioning you need to prepare the partitions then process it. I want to know what is the difference and which on... | **TL;DR;**
Neither approach is intended to help when the bottleneck is in the processor. You will see some gains by having multiple items going through a processor at the same time, but both of the options you point out get their full benefits when used in processes that are I/O bound. The `AsyncItemProcessor`/`Async... |
7761057 | Why am I getting "Can't find string terminator "'" anywhere before EOF at -e line 1" when I try to run a Perl one-liner on Windows? | 14 | 2011-10-13 22:12:37 | <p>I am trying to run the following on Windows with 5.14.2</p>
<pre>C:\Perl>perl -e 'print "Hello World \n"'
Can't find string terminator "'" anywhere before EOF at -e line 1.</pre>
<p>What am I missing?</p>
| 28,133 | 30,546 | 2019-07-12 16:19:42 | 7,761,088 | 29 | 2011-10-13 22:16:36 | 8,355 | 2011-10-13 22:28:39 | https://stackoverflow.com/q/7761057 | https://stackoverflow.com/a/7761088 | <p>You're missing a decent shell with sane and well-defined quoting rules. On Windows, only the double quote is considered a quote, and the escaping rules are poorly defined and inconsistent. Try:</p>
<pre><code>perl -e "print qq{Hello World \n}"
</code></pre>
<p>I strongly recommend avoiding anything but the very ... | <p>You're missing a decent shell with sane and well-defined quoting rules. On Windows, only the double quote is considered a quote, and the escaping rules are poorly defined and inconsistent. Try:</p> <pre><code>perl -e "print qq{Hello World \n}" </code></pre> <p>I strongly recommend avoiding anything but the very ... | 64, 580, 2631 | cmd, perl, windows | <h1>Why am I getting "Can't find string terminator "'" anywhere before EOF at -e line 1" when I try to run a Perl one-liner on Windows?</h1>
<p>I am trying to run the following on Windows with 5.14.2</p>
<pre>C:\Perl>perl -e 'print "Hello World \n"'
Can't find string terminator "'" anywhere before EOF at -e line 1.</p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,628 | cmd | # Why am I getting "Can't find string terminator "'" anywhere before EOF at -e line 1" when I try to run a Perl one-liner on Windows?
I am trying to run the following on Windows with 5.14.2
```
C:\Perl>perl -e 'print "Hello World \n"'
Can't find string terminator "'" anywhere before EOF at -e line 1.
```
What am I m... | You're missing a decent shell with sane and well-defined quoting rules. On Windows, only the double quote is considered a quote, and the escaping rules are poorly defined and inconsistent. Try:
```
perl -e "print qq{Hello World \n}"
```
I strongly recommend avoiding anything but the very simplest one-liners on Window... |
10167482 | Cant get symbolic link to work (windows 7) cmd | 13 | 2012-04-16 00:43:08 | <p>Am trying to create a symbolic hard link so that I can move chrome's cache to another harddrive, I have been trying to get it to work, but every variation I have tried has come back from the command line that my syntax is incorrect. From what ive seen seaching about this error is normaly todo with the quotation mar... | 21,362 | 638,278 | 2018-11-21 18:35:49 | 10,167,494 | 29 | 2012-04-16 00:45:14 | 34,397 | 2012-04-16 00:45:14 | https://stackoverflow.com/q/10167482 | https://stackoverflow.com/a/10167494 | <p>Use straight quotes (<code>"</code>) instead of smart quotes.</p>
| <p>Use straight quotes (<code>"</code>) instead of smart quotes.</p> | 64, 367, 2631 | cmd, syntax, windows | <h1>Cant get symbolic link to work (windows 7) cmd</h1>
<p>Am trying to create a symbolic hard link so that I can move chrome's cache to another harddrive, I have been trying to get it to work, but every variation I have tried has come back from the command line that my syntax is incorrect. From what ive seen seaching... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,629 | cmd | # Cant get symbolic link to work (windows 7) cmd
Am trying to create a symbolic hard link so that I can move chrome's cache to another harddrive, I have been trying to get it to work, but every variation I have tried has come back from the command line that my syntax is incorrect. From what ive seen seaching about thi... | Use straight quotes (`"`) instead of smart quotes. |
52767500 | How to pass script arguments to AWS Batch fetch-and-run | 9 | 2018-10-11 19:23:34 | <p>I am following <a href="https://aws.amazon.com/blogs/compute/creating-a-simple-fetch-and-run-aws-batch-job/" rel="noreferrer">this tutorial</a> to run a simple fetch-and-run example in AWS batch. However, I'm unable to pass arguments to the script fetched through this example.</p>
<p>The basic example will produce ... | 13,618 | 41,977 | 2018-10-11 19:41:07 | 52,767,751 | 29 | 2018-10-11 19:41:07 | 41,977 | 2018-10-11 19:41:07 | https://stackoverflow.com/q/52767500 | https://stackoverflow.com/a/52767751 | <p>Mixing <a href="https://docs.aws.amazon.com/batch/latest/userguide/example-job-definitions.html" rel="noreferrer">these example of job definitions</a> I achieved it with <code>aws batch</code> using:</p>
<pre><code>aws batch submit-job --job-name <job_name> --job-definition <job_def_name> \
--job-queu... | <p>Mixing <a href="https://docs.aws.amazon.com/batch/latest/userguide/example-job-definitions.html" rel="noreferrer">these example of job definitions</a> I achieved it with <code>aws batch</code> using:</p> <pre><code>aws batch submit-job --job-name <job_name> --job-definition <job_def_name> \ --job-queu... | 2313, 33388, 124227 | amazon-web-services, arguments, aws-batch | <h1>How to pass script arguments to AWS Batch fetch-and-run</h1>
<p>I am following <a href="https://aws.amazon.com/blogs/compute/creating-a-simple-fetch-and-run-aws-batch-job/" rel="noreferrer">this tutorial</a> to run a simple fetch-and-run example in AWS batch. However, I'm unable to pass arguments to the script fetc... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,630 | cmd | # How to pass script arguments to AWS Batch fetch-and-run
I am following [this tutorial](https://aws.amazon.com/blogs/compute/creating-a-simple-fetch-and-run-aws-batch-job/) to run a simple fetch-and-run example in AWS batch. However, I'm unable to pass arguments to the script fetched through this example.
The basic ... | Mixing [these example of job definitions](https://docs.aws.amazon.com/batch/latest/userguide/example-job-definitions.html) I achieved it with `aws batch` using:
```
aws batch submit-job --job-name <job_name> --job-definition <job_def_name> \
--job-queue <queue_name> \
--container-overrides '{
"command": ["<scr... |
12329103 | Way to change Windows (7) monitors settings via script | 9 | 2012-09-08 08:05:04 | <p>i bought a new TV mainly as second monitor to my PC and I often need to change settings (extend display for movies, duplicate display for gaming, disable for work'n'browsing).</p>
<p>Is there a way to switch among those settings via some script (batch most likely or VBS, whatever) so I dont't need to crawl through ... | 30,036 | 1,656,353 | 2016-08-13 16:16:50 | 12,347,530 | 29 | 2012-09-10 08:05:06 | 379,840 | 2012-09-10 08:05:06 | https://stackoverflow.com/q/12329103 | https://stackoverflow.com/a/12347530 | <p>Firstly, not sure if you know the shortcut </p>
<pre><code>Windows + P
</code></pre>
<p>2 buttons seems pretty easy!</p>
<p>but, you could write a batch file to run the programs with the appication displayswitch.exe included. displayswitch comes with windows 7 so you can have a batch file with:</p>
<pre><code>Di... | <p>Firstly, not sure if you know the shortcut </p> <pre><code>Windows + P </code></pre> <p>2 buttons seems pretty easy!</p> <p>but, you could write a batch file to run the programs with the appication displayswitch.exe included. displayswitch comes with windows 7 so you can have a batch file with:</p> <pre><code>Di... | 494, 3327, 7002, 34595 | batch-file, multiple-monitors, vbscript, windows-7 | <h1>Way to change Windows (7) monitors settings via script</h1>
<p>i bought a new TV mainly as second monitor to my PC and I often need to change settings (extend display for movies, duplicate display for gaming, disable for work'n'browsing).</p>
<p>Is there a way to switch among those settings via some script (batch ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,631 | cmd | # Way to change Windows (7) monitors settings via script
i bought a new TV mainly as second monitor to my PC and I often need to change settings (extend display for movies, duplicate display for gaming, disable for work'n'browsing).
Is there a way to switch among those settings via some script (batch most likely or V... | Firstly, not sure if you know the shortcut
```
Windows + P
```
2 buttons seems pretty easy!
but, you could write a batch file to run the programs with the appication displayswitch.exe included. displayswitch comes with windows 7 so you can have a batch file with:
```
DisplaySwitch.exe /external
notepad.exe
```
the... |
23542453 | Change backslash to forward slash in windows batch file | 49 | 2014-05-08 12:58:15 | <p>I'm trying to convert all backslashes () to forward slashes (/) in a variable which contains a file name and location. I've read about this and seen:</p>
<pre><code>%variable:str1=str2%
</code></pre>
<p>and</p>
<pre><code>set "var=%var:\=/%"
</code></pre>
<p>which I've attempted, but I'm obviously not getting it... | 62,632 | 3,253,319 | 2020-06-11 17:14:24 | 23,544,690 | 28 | 2014-05-08 14:26:59 | 2,128,947 | 2014-05-08 14:26:59 | https://stackoverflow.com/q/23542453 | https://stackoverflow.com/a/23544690 | <p>Within a block statement <code>(a parenthesised series of statements)</code>, the <strong>entire</strong> block is parsed and <strong>then</strong> executed. Any <code>%var%</code> within the block will be replaced by that variable's value <strong>at the time the block is parsed</strong> - before the block is execut... | <p>Within a block statement <code>(a parenthesised series of statements)</code>, the <strong>entire</strong> block is parsed and <strong>then</strong> executed. Any <code>%var%</code> within the block will be replaced by that variable's value <strong>at the time the block is parsed</strong> - before the block is execut... | 64, 139, 7002, 10194 | batch-file, slash, string, windows | <h1>Change backslash to forward slash in windows batch file</h1>
<p>I'm trying to convert all backslashes () to forward slashes (/) in a variable which contains a file name and location. I've read about this and seen:</p>
<pre><code>%variable:str1=str2%
</code></pre>
<p>and</p>
<pre><code>set "var=%var:\=/%"
</code>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,632 | cmd | # Change backslash to forward slash in windows batch file
I'm trying to convert all backslashes () to forward slashes (/) in a variable which contains a file name and location. I've read about this and seen:
```
%variable:str1=str2%
```
and
```
set "var=%var:\=/%"
```
which I've attempted, but I'm obviously not ge... | Within a block statement `(a parenthesised series of statements)`, the **entire** block is parsed and **then** executed. Any `%var%` within the block will be replaced by that variable's value **at the time the block is parsed** - before the block is executed - the same thing applies to a `FOR ... DO (block)`.
Hence, `... |
12356646 | Xcopy Command excluding files and folders | 30 | 2012-09-10 17:28:34 | <p>I want to copy files and folders in a directory to another folder excluding a list of files and folders.Is that possible.</p>
<p>I was just trying to copy excluding file : </p>
<pre><code> xcopy c:\t1 c:\t2 /EXCLUDE:exclusion.txt
</code></pre>
<p>But it keeps saying read cant read file : exclusion.txt</p>
<p>Can... | 144,319 | 696,219 | 2019-12-18 17:31:46 | 21,447,865 | 28 | 2014-01-30 04:32:30 | 3,251,587 | 2014-01-30 04:55:38 | https://stackoverflow.com/q/12356646 | https://stackoverflow.com/a/21447865 | <p>Just give full path to exclusion file: eg..</p>
<p>-- <strong>no</strong> - - - - -<code>xcopy c:\t1 c:\t2 /EXCLUDE:list-of-excluded-files.txt</code></p>
<p><strong>correct</strong> - - - <code>xcopy c:\t1 c:\t2 /EXCLUDE:C:\list-of-excluded-files.txt</code></p>
<p>In this example the file would be located <strong... | <p>Just give full path to exclusion file: eg..</p> <p>-- <strong>no</strong> - - - - -<code>xcopy c:\t1 c:\t2 /EXCLUDE:list-of-excluded-files.txt</code></p> <p><strong>correct</strong> - - - <code>xcopy c:\t1 c:\t2 /EXCLUDE:C:\list-of-excluded-files.txt</code></p> <p>In this example the file would be located <strong... | 1231, 2631, 4710 | cmd, command-line, xcopy | <h1>Xcopy Command excluding files and folders</h1>
<p>I want to copy files and folders in a directory to another folder excluding a list of files and folders.Is that possible.</p>
<p>I was just trying to copy excluding file : </p>
<pre><code> xcopy c:\t1 c:\t2 /EXCLUDE:exclusion.txt
</code></pre>
<p>But it keeps say... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,633 | cmd | # Xcopy Command excluding files and folders
I want to copy files and folders in a directory to another folder excluding a list of files and folders.Is that possible.
I was just trying to copy excluding file :
```
xcopy c:\t1 c:\t2 /EXCLUDE:exclusion.txt
```
But it keeps saying read cant read file : exclusion.txt
... | Just give full path to exclusion file: eg..
-- **no** - - - - -`xcopy c:\t1 c:\t2 /EXCLUDE:list-of-excluded-files.txt`
**correct** - - - `xcopy c:\t1 c:\t2 /EXCLUDE:C:\list-of-excluded-files.txt`
In this example the file would be located ***" C:\list-of-excluded-files.txt "***
or...
**correct** - - - `xcopy c:\t1 ... |
7264736 | Windows Batch move to directory that may not exist | 29 | 2011-08-31 23:45:00 | <p>In a Windows batch file I am trying to move a file to a directory which may not currently exist. Because the directory is not there, when I do the move I see an error like:</p>
<p>The system cannot find the path specified</p>
<pre><code>move c:\aaa\bbb\ccc\ddd\myfile.txt c:\aaa\111\222\333\444\mytext.txt
</code><... | 44,149 | 913,102 | 2021-07-01 14:43:55 | 7,264,775 | 28 | 2011-08-31 23:50:24 | 704,654 | 2011-08-31 23:50:24 | https://stackoverflow.com/q/7264736 | https://stackoverflow.com/a/7264775 | <p>Try:</p>
<pre><code>md c:\aaa\111\222\333\444 2> nul
</code></pre>
<p>before your Move command.</p>
<p>md makes directories recursive, so if there are no parent directories to 444, it will keep creating hierarchically. The "2> nul" ensures that if you have the directory already, your command wouldnt error out.... | <p>Try:</p> <pre><code>md c:\aaa\111\222\333\444 2> nul </code></pre> <p>before your Move command.</p> <p>md makes directories recursive, so if there are no parent directories to 444, it will keep creating hierarchically. The "2> nul" ensures that if you have the directory already, your command wouldnt error out.... | 64, 7002 | batch-file, windows | <h1>Windows Batch move to directory that may not exist</h1>
<p>In a Windows batch file I am trying to move a file to a directory which may not currently exist. Because the directory is not there, when I do the move I see an error like:</p>
<p>The system cannot find the path specified</p>
<pre><code>move c:\aaa\bbb\c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,634 | cmd | # Windows Batch move to directory that may not exist
In a Windows batch file I am trying to move a file to a directory which may not currently exist. Because the directory is not there, when I do the move I see an error like:
The system cannot find the path specified
```
move c:\aaa\bbb\ccc\ddd\myfile.txt c:\aaa\111... | Try:
```
md c:\aaa\111\222\333\444 2> nul
```
before your Move command.
md makes directories recursive, so if there are no parent directories to 444, it will keep creating hierarchically. The "2> nul" ensures that if you have the directory already, your command wouldnt error out. |
3161989 | How do I set the current working directory/drive in a dos batch file? | 28 | 2010-07-01 22:01:06 | <p><code>cd d:\projects</code> does not work</p>
<p>How can I set the current working drive and directory so that I can run msbuild scripts from there?</p>
| 68,565 | 57,883 | 2014-12-16 14:15:51 | 3,162,001 | 28 | 2010-07-01 22:02:45 | 98,094 | 2014-12-16 14:15:51 | https://stackoverflow.com/q/3161989 | https://stackoverflow.com/a/3162001 | <p>try the following:</p>
<pre><code>D:
cd \projects
</code></pre>
<p>or, in a single line (courtesy of <a href="https://stackoverflow.com/questions/3161989/how-do-i-set-the-current-working-directory-drive-in-a-dos-batch-file/3162001#comment3251896_3162001">Kilanash</a>):</p>
<pre><code>cd /d D:\projects
</code></pr... | <p>try the following:</p> <pre><code>D: cd \projects </code></pre> <p>or, in a single line (courtesy of <a href="https://stackoverflow.com/questions/3161989/how-do-i-set-the-current-working-directory-drive-in-a-dos-batch-file/3162001#comment3251896_3162001">Kilanash</a>):</p> <pre><code>cd /d D:\projects </code></pr... | 7002 | batch-file | <h1>How do I set the current working directory/drive in a dos batch file?</h1>
<p><code>cd d:\projects</code> does not work</p>
<p>How can I set the current working drive and directory so that I can run msbuild scripts from there?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,635 | cmd | # How do I set the current working directory/drive in a dos batch file?
`cd d:\projects` does not work
How can I set the current working drive and directory so that I can run msbuild scripts from there? | try the following:
```
D:
cd \projects
```
or, in a single line (courtesy of [Kilanash](https://stackoverflow.com/questions/3161989/how-do-i-set-the-current-working-directory-drive-in-a-dos-batch-file/3162001#comment3251896_3162001)):
```
cd /d D:\projects
``` |
343518 | Finding out the file name of the running batch file | 28 | 2008-12-05 11:06:04 | <p>Inside a windows batch file I'd like to figure out what the fully qualified path name of this batch file is.</p>
<p>I have tried <code>%0</code> but this does only gave me the typed command (e.g. just the file name without path or extension).</p>
| 43,389 | 25,782 | 2020-02-19 10:05:55 | 343,823 | 28 | 2008-12-05 13:25:13 | 15,459 | 2020-02-19 09:34:03 | https://stackoverflow.com/q/343518 | https://stackoverflow.com/a/343823 | <pre><code>echo %~f0
</code></pre>
<p>works for me.</p>
<p>see <code>for /?</code> from <code>cmd</code> and read about variable substitution.</p>
| <pre><code>echo %~f0 </code></pre> <p>works for me.</p> <p>see <code>for /?</code> from <code>cmd</code> and read about variable substitution.</p> | 64, 7002 | batch-file, windows | <h1>Finding out the file name of the running batch file</h1>
<p>Inside a windows batch file I'd like to figure out what the fully qualified path name of this batch file is.</p>
<p>I have tried <code>%0</code> but this does only gave me the typed command (e.g. just the file name without path or extension).</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,636 | cmd | # Finding out the file name of the running batch file
Inside a windows batch file I'd like to figure out what the fully qualified path name of this batch file is.
I have tried `%0` but this does only gave me the typed command (e.g. just the file name without path or extension). | ```
echo %~f0
```
works for me.
see `for /?` from `cmd` and read about variable substitution. |
6811522 | changing the working-directory of command from java | 27 | 2011-07-25 03:26:59 | <p>I need to execute a .exe file from a function in one of the packages I have in my java project. now the working directory is the root directory of the project for java but the .exe file in sub-directories of my project. here is how the project is organized:</p>
<pre><code>ROOT_DIR
|.......->com
| |......... | 38,298 | 804,723 | 2018-06-20 08:47:04 | 6,811,610 | 28 | 2011-07-25 03:45:49 | 293,686 | 2011-07-25 03:45:49 | https://stackoverflow.com/q/6811522 | https://stackoverflow.com/a/6811610 | <p>To implement this you can use the ProcessBuilder class, here's how it would look like:</p>
<pre><code>File pathToExecutable = new File( "resources/external.exe" );
ProcessBuilder builder = new ProcessBuilder( pathToExecutable.getAbsolutePath(), "-i", "input", "-o", "output");
builder.directory( new File( "resources... | <p>To implement this you can use the ProcessBuilder class, here's how it would look like:</p> <pre><code>File pathToExecutable = new File( "resources/external.exe" ); ProcessBuilder builder = new ProcessBuilder( pathToExecutable.getAbsolutePath(), "-i", "input", "-o", "output"); builder.directory( new File( "resources... | 17, 1231, 7002, 10201 | batch-file, command-line, java, working-directory | <h1>changing the working-directory of command from java</h1>
<p>I need to execute a .exe file from a function in one of the packages I have in my java project. now the working directory is the root directory of the project for java but the .exe file in sub-directories of my project. here is how the project is organized... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,637 | cmd | # changing the working-directory of command from java
I need to execute a .exe file from a function in one of the packages I have in my java project. now the working directory is the root directory of the project for java but the .exe file in sub-directories of my project. here is how the project is organized:
```
RO... | To implement this you can use the ProcessBuilder class, here's how it would look like:
```
File pathToExecutable = new File( "resources/external.exe" );
ProcessBuilder builder = new ProcessBuilder( pathToExecutable.getAbsolutePath(), "-i", "input", "-o", "output");
builder.directory( new File( "resources" ).getAbsolut... |
19187241 | Change affinity of process with windows script | 25 | 2013-10-04 17:23:17 | <p>In Windows, with</p>
<pre><code> START /node 1 /affinity ff cmd /C "app.exe"
</code></pre>
<p>I can set the affinity of app.exe (number of cores used by app.exe).</p>
<p>With a windows script, How I can change the affinity of a running process ? </p>
| 73,265 | 348,081 | 2023-08-29 18:51:36 | 19,190,533 | 28 | 2013-10-04 20:48:26 | 891,976 | 2023-08-29 18:51:36 | https://stackoverflow.com/q/19187241 | https://stackoverflow.com/a/19190533 | <p>PowerShell can do this task for you.</p>
<h5>Get Affinity</h5>
<pre><code>$Process = Get-Process app
$Process | Select-Object ProcessorAffinity
</code></pre>
<h5>Set Affinity</h5>
<pre><code>$Process = Get-Process app
$Process.ProcessorAffinity = 255
</code></pre>
<h4>Example <sub><sup>( 8 Core Processor )</sup></su... | <p>PowerShell can do this task for you.</p> <h5>Get Affinity</h5> <pre><code>$Process = Get-Process app $Process | Select-Object ProcessorAffinity </code></pre> <h5>Set Affinity</h5> <pre><code>$Process = Get-Process app $Process.ProcessorAffinity = 255 </code></pre> <h4>Example <sub><sup>( 8 Core Processor )</sup></su... | 64, 7002, 15997 | affinity, batch-file, windows | <h1>Change affinity of process with windows script</h1>
<p>In Windows, with</p>
<pre><code> START /node 1 /affinity ff cmd /C "app.exe"
</code></pre>
<p>I can set the affinity of app.exe (number of cores used by app.exe).</p>
<p>With a windows script, How I can change the affinity of a running process ? </p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,638 | cmd | # Change affinity of process with windows script
In Windows, with
```
START /node 1 /affinity ff cmd /C "app.exe"
```
I can set the affinity of app.exe (number of cores used by app.exe).
With a windows script, How I can change the affinity of a running process ? | PowerShell can do this task for you.
##### Get Affinity
```
$Process = Get-Process app
$Process | Select-Object ProcessorAffinity
```
##### Set Affinity
```
$Process = Get-Process app
$Process.ProcessorAffinity = 255
```
#### Example ( 8 Core Processor )
| Core # | Value | BitMask |
| --- | --- | --- |
| Core 1 |... |
11225581 | How to check if a file is not empty in Batch | 24 | 2012-06-27 11:53:42 | <p>There are several ways google throws at me for checking if a file is empty but I need to do the opposite.</p>
<pre><code>If (file is NOT empty)
do things
</code></pre>
<p>How would I do this in batch?</p>
| 71,258 | 1,266,650 | 2016-08-05 02:15:46 | 11,225,772 | 28 | 2012-06-27 12:04:41 | 799,586 | 2012-06-27 12:04:41 | https://stackoverflow.com/q/11225581 | https://stackoverflow.com/a/11225772 | <pre><code>for /f %%i in ("file.txt") do set size=%%~zi
if %size% gtr 0 echo Not empty
</code></pre>
| <pre><code>for /f %%i in ("file.txt") do set size=%%~zi if %size% gtr 0 echo Not empty </code></pre> | 64, 7002 | batch-file, windows | <h1>How to check if a file is not empty in Batch</h1>
<p>There are several ways google throws at me for checking if a file is empty but I need to do the opposite.</p>
<pre><code>If (file is NOT empty)
do things
</code></pre>
<p>How would I do this in batch?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,639 | cmd | # How to check if a file is not empty in Batch
There are several ways google throws at me for checking if a file is empty but I need to do the opposite.
```
If (file is NOT empty)
do things
```
How would I do this in batch? | ```
for /f %%i in ("file.txt") do set size=%%~zi
if %size% gtr 0 echo Not empty
``` |
13445648 | Zipping everything in directory with 7z except one file or one file type | 22 | 2012-11-18 23:17:18 | <p>i'd like to zip everything except one file</p>
<pre><code>7z a -tzip files.zip *
</code></pre>
<p>this will zip all the files in my current directory.. is there a way I can tell it to not zip one file or one file type ?</p>
| 25,977 | 647,287 | 2024-11-25 19:38:35 | 13,464,376 | 28 | 2012-11-19 23:39:04 | 235 | 2022-06-17 12:30:27 | https://stackoverflow.com/q/13445648 | https://stackoverflow.com/a/13464376 | <p>Per the 7za command-line help, you use the -x switch to do this:</p>
<pre><code>-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
</code></pre>
<p>To exclude the file foo.txt you would add:</p>
<pre><code>-x!foo.txt
</code></pre>
<p>To exclude all .html files (*.html) you would add:</p>
<pre><code>-x!*.html
</code... | <p>Per the 7za command-line help, you use the -x switch to do this:</p> <pre><code>-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames </code></pre> <p>To exclude the file foo.txt you would add:</p> <pre><code>-x!foo.txt </code></pre> <p>To exclude all .html files (*.html) you would add:</p> <pre><code>-x!*.html </code... | 881, 2631, 5680 | 7zip, cmd, zip | <h1>Zipping everything in directory with 7z except one file or one file type</h1>
<p>i'd like to zip everything except one file</p>
<pre><code>7z a -tzip files.zip *
</code></pre>
<p>this will zip all the files in my current directory.. is there a way I can tell it to not zip one file or one file type ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,641 | cmd | # Zipping everything in directory with 7z except one file or one file type
i'd like to zip everything except one file
```
7z a -tzip files.zip *
```
this will zip all the files in my current directory.. is there a way I can tell it to not zip one file or one file type ? | Per the 7za command-line help, you use the -x switch to do this:
```
-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
```
To exclude the file foo.txt you would add:
```
-x!foo.txt
```
To exclude all .html files (*.html) you would add:
```
-x!*.html
```
You can add multiple -x entries to exclude multiple filena... |
54866820 | Create alias for a specific command in cmd | 18 | 2019-02-25 13:01:14 | <p>Is there anyway to create an alias to <code>cd PATH</code> command in cmd?</p>
<p>For example, instead of typing <code>cd C:\John\Pictures</code> I'd like to type just <code>pictures</code> in cmd and press <kbd>Enter</kbd> and it should simply take me to <code>C:\John\Pictures</code>.</p>
<p>Is that possible and ... | 27,711 | 1,939,926 | 2023-06-29 10:27:56 | 54,872,621 | 28 | 2019-02-25 18:33:20 | 10,607,772 | 2023-06-29 10:27:56 | https://stackoverflow.com/q/54866820 | https://stackoverflow.com/a/54872621 |
<p>You will need to use the <a href="https://ss64.com/nt/doskey.html" rel="noreferrer"><code>doskey</code> command</a> which creates aliases. For example:</p>
<pre class="lang-bat prettyprint-override"><code>doskey note = "C:\Windows\System32\notepad.exe"
note
</code></pre>
<p>creates a macro to open Notepad... | <p>You will need to use the <a href="https://ss64.com/nt/doskey.html" rel="noreferrer"><code>doskey</code> command</a> which creates aliases. For example:</p> <pre class="lang-bat prettyprint-override"><code>doskey note = "C:\Windows\System32\notepad.exe" note </code></pre> <p>creates a macro to open Notepad... | 1448, 2631 | alias, cmd | <h1>Create alias for a specific command in cmd</h1>
<p>Is there anyway to create an alias to <code>cd PATH</code> command in cmd?</p>
<p>For example, instead of typing <code>cd C:\John\Pictures</code> I'd like to type just <code>pictures</code> in cmd and press <kbd>Enter</kbd> and it should simply take me to <code>C:... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,642 | cmd | # Create alias for a specific command in cmd
Is there anyway to create an alias to `cd PATH` command in cmd?
For example, instead of typing `cd C:\John\Pictures` I'd like to type just `pictures` in cmd and press `Enter` and it should simply take me to `C:\John\Pictures`.
Is that possible and how? | You will need to use the [`doskey` command](https://ss64.com/nt/doskey.html) which creates aliases. For example:
```
doskey note = "C:\Windows\System32\notepad.exe"
note
```
creates a macro to open Notepad, then calls it. The [macro](https://ss64.com/nt/syntax-macros.html) name (`note` in the above example) must be v... |
8095002 | Windows batch script to unhide files hidden by virus | 18 | 2011-11-11 13:59:14 | <p>Since I'm seing many people having their files hidden by flash drive viruses, I'm giving them a Windows command line using <strong>attrib</strong> (or using Linux) to solve the problem when the infected files are removed and the their files are still "missing". The command removing file and folders properties syste... | 119,067 | 473,433 | 2016-01-25 20:48:17 | 8,095,042 | 28 | 2011-11-11 14:02:14 | 48,082 | 2011-11-11 14:35:13 | https://stackoverflow.com/q/8095002 | https://stackoverflow.com/a/8095042 | <pre><code>echo "Enter Drive letter"
set /p driveletter=
attrib -s -h -a /s /d %driveletter%:\*.*
</code></pre>
| <pre><code>echo "Enter Drive letter" set /p driveletter= attrib -s -h -a /s /d %driveletter%:\*.* </code></pre> | 64, 1337, 7002 | batch-file, hidden, windows | <h1>Windows batch script to unhide files hidden by virus</h1>
<p>Since I'm seing many people having their files hidden by flash drive viruses, I'm giving them a Windows command line using <strong>attrib</strong> (or using Linux) to solve the problem when the infected files are removed and the their files are still "mi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,643 | cmd | # Windows batch script to unhide files hidden by virus
Since I'm seing many people having their files hidden by flash drive viruses, I'm giving them a Windows command line using **attrib** (or using Linux) to solve the problem when the infected files are removed and the their files are still "missing". The command rem... | ```
echo "Enter Drive letter"
set /p driveletter=
attrib -s -h -a /s /d %driveletter%:\*.*
``` |
866623 | How do I test the current drive letter in a batch file? | 18 | 2009-05-15 01:11:04 | <p>I'm trying to write a batch file that takes the drive letter the batch file is being run from, and uses it an an IF statement. If the letter is M: for example, it will jump to the label :mSection.</p>
<p>Is this even possible?</p>
| 19,154 | 107,421 | 2018-12-13 14:00:15 | 866,638 | 28 | 2009-05-15 01:16:55 | 30,933 | 2009-05-15 01:22:04 | https://stackoverflow.com/q/866623 | https://stackoverflow.com/a/866638 | <p>You can use %~d0 to get the drive letter.
Something like this:</p>
<pre><code>IF "%~d0"=="M:" CALL :mSection
</code></pre>
| <p>You can use %~d0 to get the drive letter. Something like this:</p> <pre><code>IF "%~d0"=="M:" CALL :mSection </code></pre> | 64, 7002 | batch-file, windows | <h1>How do I test the current drive letter in a batch file?</h1>
<p>I'm trying to write a batch file that takes the drive letter the batch file is being run from, and uses it an an IF statement. If the letter is M: for example, it will jump to the label :mSection.</p>
<p>Is this even possible?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,644 | cmd | # How do I test the current drive letter in a batch file?
I'm trying to write a batch file that takes the drive letter the batch file is being run from, and uses it an an IF statement. If the letter is M: for example, it will jump to the label :mSection.
Is this even possible? | You can use %~d0 to get the drive letter.
Something like this:
```
IF "%~d0"=="M:" CALL :mSection
``` |
32150412 | BATCH- echo % (print an percent sign) | 17 | 2015-08-21 22:55:18 | <p>In my program i made it so that it shows 20% or 2% but the percent signs don't show. Any way you to display the percentage symbol? </p>
<p>(This is for minimal character limit don't bother looking down here)</p>
| 19,454 | 5,252,073 | 2020-10-11 15:20:31 | 32,150,522 | 28 | 2015-08-21 23:08:01 | 2,299,431 | 2015-08-21 23:08:01 | https://stackoverflow.com/q/32150412 | https://stackoverflow.com/a/32150522 | <p>Doubling the percent sign will print one percent sign:</p>
<pre><code>echo %%
</code></pre>
| <p>Doubling the percent sign will print one percent sign:</p> <pre><code>echo %% </code></pre> | 64, 2631, 4804, 7002 | batch-file, cmd, escaping, windows | <h1>BATCH- echo % (print an percent sign)</h1>
<p>In my program i made it so that it shows 20% or 2% but the percent signs don't show. Any way you to display the percentage symbol? </p>
<p>(This is for minimal character limit don't bother looking down here)</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,645 | cmd | # BATCH- echo % (print an percent sign)
In my program i made it so that it shows 20% or 2% but the percent signs don't show. Any way you to display the percentage symbol?
(This is for minimal character limit don't bother looking down here) | Doubling the percent sign will print one percent sign:
```
echo %%
``` |
8071458 | Get directory name from path of %CD% | 17 | 2011-11-09 20:47:51 | <p>Given that the current directory, <code>%CD%</code> is </p>
<pre><code>C:\Parent\Child
</code></pre>
<p>In a batch file, how can I get the value <code>Child</code> in to a variable?</p>
<p>thanks</p>
| 32,163 | 511,438 | 2016-04-14 18:31:41 | 8,071,683 | 28 | 2011-11-09 21:07:34 | 526,535 | 2011-11-09 21:07:34 | https://stackoverflow.com/q/8071458 | https://stackoverflow.com/a/8071683 | <pre><code>for %%a in (.) do set currentfolder=%%~na
echo %currentfolder%
</code></pre>
<p>From here: <a href="https://superuser.com/questions/160702/get-current-folder-name-by-a-dos-command">https://superuser.com/questions/160702/get-current-folder-name-by-a-dos-command</a></p>
| <pre><code>for %%a in (.) do set currentfolder=%%~na echo %currentfolder% </code></pre> <p>From here: <a href="https://superuser.com/questions/160702/get-current-folder-name-by-a-dos-command">https://superuser.com/questions/160702/get-current-folder-name-by-a-dos-command</a></p> | 2631, 7002 | batch-file, cmd | <h1>Get directory name from path of %CD%</h1>
<p>Given that the current directory, <code>%CD%</code> is </p>
<pre><code>C:\Parent\Child
</code></pre>
<p>In a batch file, how can I get the value <code>Child</code> in to a variable?</p>
<p>thanks</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,646 | cmd | # Get directory name from path of %CD%
Given that the current directory, `%CD%` is
```
C:\Parent\Child
```
In a batch file, how can I get the value `Child` in to a variable?
thanks | ```
for %%a in (.) do set currentfolder=%%~na
echo %currentfolder%
```
From here: <https://superuser.com/questions/160702/get-current-folder-name-by-a-dos-command> |
32152934 | How to run command until it succeeds? | 15 | 2015-08-22 06:04:45 | <p>I still use Windows batch-files for basic tasks. One of these is to check my internet connection (pg.bat) which does only do a <code>ping www.google.com</code></p>
<p>Most of the time, I need to run it a few times until it succeeds (host could not be found error). At first I thought a <code>ping -t</code> would wor... | 18,943 | 12,860 | 2017-10-01 09:20:45 | 32,152,992 | 28 | 2015-08-22 06:12:07 | 821,878 | 2015-08-22 15:48:41 | https://stackoverflow.com/q/32152934 | https://stackoverflow.com/a/32152992 | <p>In general, you can use the label/goto syntax in a batch file.</p>
<pre><code>:repeat
your-command || goto :repeat
echo Success!
</code></pre>
<p>The <code>||</code> will only run the second command if the first one fails. Failure in this case means a nonzero exit code, so it will only work with commands that set... | <p>In general, you can use the label/goto syntax in a batch file.</p> <pre><code>:repeat your-command || goto :repeat echo Success! </code></pre> <p>The <code>||</code> will only run the second command if the first one fails. Failure in this case means a nonzero exit code, so it will only work with commands that set... | 64, 7002 | batch-file, windows | <h1>How to run command until it succeeds?</h1>
<p>I still use Windows batch-files for basic tasks. One of these is to check my internet connection (pg.bat) which does only do a <code>ping www.google.com</code></p>
<p>Most of the time, I need to run it a few times until it succeeds (host could not be found error). At f... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,649 | cmd | # How to run command until it succeeds?
I still use Windows batch-files for basic tasks. One of these is to check my internet connection (pg.bat) which does only do a `ping www.google.com`
Most of the time, I need to run it a few times until it succeeds (host could not be found error). At first I thought a `ping -t` ... | In general, you can use the label/goto syntax in a batch file.
```
:repeat
your-command || goto :repeat
echo Success!
```
The `||` will only run the second command if the first one fails. Failure in this case means a nonzero exit code, so it will only work with commands that set `%errorlevel%` to 0 for success or non... |
27906705 | Loop until file exists using windows batch command | 14 | 2015-01-12 16:38:34 | <p>how can i convert following code into windows batch command?</p>
<p>Here is a perl script which is searching for a file in a while loop, if found it Exits.</p>
<pre><code>use strict;
use warnings;
my $filename = 'something.txt';
while (1) {
if (-e $filename) {
print "File Exists!";
exit;
}
}
</code></pre>... | 35,970 | 3,075,765 | 2015-01-12 17:46:23 | 27,907,596 | 28 | 2015-01-12 17:30:37 | 3,962,346 | 2015-01-12 17:46:23 | https://stackoverflow.com/q/27906705 | https://stackoverflow.com/a/27907596 | <p>This is a fairly straight-forward translation. The code should be pretty self-explanatory:</p>
<pre><code>@ECHO OFF
SET LookForFile="C:\Path\To\File.txt"
:CheckForFile
IF EXIST %LookForFile% GOTO FoundIt
REM If we get here, the file is not found.
REM Wait 60 seconds and then recheck.
REM If no delay is needed, c... | <p>This is a fairly straight-forward translation. The code should be pretty self-explanatory:</p> <pre><code>@ECHO OFF SET LookForFile="C:\Path\To\File.txt" :CheckForFile IF EXIST %LookForFile% GOTO FoundIt REM If we get here, the file is not found. REM Wait 60 seconds and then recheck. REM If no delay is needed, c... | 1796, 5310, 7002, 9325, 17310 | batch-file, command, file, line, while-loop | <h1>Loop until file exists using windows batch command</h1>
<p>how can i convert following code into windows batch command?</p>
<p>Here is a perl script which is searching for a file in a while loop, if found it Exits.</p>
<pre><code>use strict;
use warnings;
my $filename = 'something.txt';
while (1) {
if (-e $file... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,650 | cmd | # Loop until file exists using windows batch command
how can i convert following code into windows batch command?
Here is a perl script which is searching for a file in a while loop, if found it Exits.
```
use strict;
use warnings;
my $filename = 'something.txt';
while (1) {
if (-e $filename) {
print "File Exists!... | This is a fairly straight-forward translation. The code should be pretty self-explanatory:
```
@ECHO OFF
SET LookForFile="C:\Path\To\File.txt"
:CheckForFile
IF EXIST %LookForFile% GOTO FoundIt
REM If we get here, the file is not found.
REM Wait 60 seconds and then recheck.
REM If no delay is needed, comment/remove ... |
3179649 | Getting the current Revision number on command line via TortoiseSVN | 14 | 2010-07-05 13:03:16 | <p>I'm trying to write a batch file in which I need the HEAD revision of the project I am working on.</p>
<p>Is there a command to get this from the command line?</p>
<p>I am on a Windows XP machine.</p>
| 29,111 | 383,704 | 2025-01-24 11:39:14 | 3,179,816 | 28 | 2010-07-05 13:24:26 | 351,301 | 2010-07-05 13:24:26 | https://stackoverflow.com/q/3179649 | https://stackoverflow.com/a/3179816 | <p>It's awkward without the text-processing capabilities of *nix, but this batch file does it:</p>
<pre><code>@echo off
for /f "tokens=2" %%i in ('svn info -rHEAD svn://localhost^|find "Revision"') do @echo %%i
</code></pre>
<p>Substitute your svn repository for my <code>svn://localhost</code>.</p>
<p><code>svn info... | <p>It's awkward without the text-processing capabilities of *nix, but this batch file does it:</p> <pre><code>@echo off for /f "tokens=2" %%i in ('svn info -rHEAD svn://localhost^|find "Revision"') do @echo %%i </code></pre> <p>Substitute your svn repository for my <code>svn://localhost</code>.</p> <p><code>svn info... | 63, 656, 7002 | batch-file, svn, tortoisesvn | <h1>Getting the current Revision number on command line via TortoiseSVN</h1>
<p>I'm trying to write a batch file in which I need the HEAD revision of the project I am working on.</p>
<p>Is there a command to get this from the command line?</p>
<p>I am on a Windows XP machine.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,652 | cmd | # Getting the current Revision number on command line via TortoiseSVN
I'm trying to write a batch file in which I need the HEAD revision of the project I am working on.
Is there a command to get this from the command line?
I am on a Windows XP machine. | It's awkward without the text-processing capabilities of *nix, but this batch file does it:
```
@echo off
for /f "tokens=2" %%i in ('svn info -rHEAD svn://localhost^|find "Revision"') do @echo %%i
```
Substitute your svn repository for my `svn://localhost`.
`svn info` gets the repository info, then pipes it to `find... |
34698558 | Copy paste is not working in command prompt neither right click or keyboard shortcuts in Windows 10 | 12 | 2016-01-09 20:29:53 | <p>Win 10 copy paste is not working in cmd from right click neither keyboard short cuts as well. Nothing happens if I try to paste some text in prompt. Reason is unknown to me. Any help?</p>
| 70,398 | 1,325,758 | 2018-12-06 20:52:14 | 34,698,674 | 28 | 2016-01-09 20:40:55 | 2,152,082 | 2018-12-06 20:52:14 | https://stackoverflow.com/q/34698558 | https://stackoverflow.com/a/34698674 | <p>Right-click on the title-bar of your <code>cmd</code> window. [Properties] - Options - check "QuickEdit Mode". Now when you right click, it will immediately paste. To copy, select the text you want and press enter.</p>
<p>You may also want to change the defaults for future instances. Same thing, but [Defaults] inst... | <p>Right-click on the title-bar of your <code>cmd</code> window. [Properties] - Options - check "QuickEdit Mode". Now when you right click, it will immediately paste. To copy, select the text you want and press enter.</p> <p>You may also want to change the defaults for future instances. Same thing, but [Defaults] inst... | 2631, 5098, 115669 | cmd, copy-paste, windows-10-desktop | <h1>Copy paste is not working in command prompt neither right click or keyboard shortcuts in Windows 10</h1>
<p>Win 10 copy paste is not working in cmd from right click neither keyboard short cuts as well. Nothing happens if I try to paste some text in prompt. Reason is unknown to me. Any help?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,653 | cmd | # Copy paste is not working in command prompt neither right click or keyboard shortcuts in Windows 10
Win 10 copy paste is not working in cmd from right click neither keyboard short cuts as well. Nothing happens if I try to paste some text in prompt. Reason is unknown to me. Any help? | Right-click on the title-bar of your `cmd` window. [Properties] - Options - check "QuickEdit Mode". Now when you right click, it will immediately paste. To copy, select the text you want and press enter.
You may also want to change the defaults for future instances. Same thing, but [Defaults] instead of [Properties] |
18600317 | Batch File: Append a string inside a for loop | 12 | 2013-09-03 19:46:59 | <p>I have the following for loop:</p>
<pre><code>for /l %%a in (1,1,%count%) do (
<nul set /p=" %%a - "
Echo !var%%a!
)
</code></pre>
<p>which will display something like this:</p>
<pre><code>1 - REL1206
2 - REL1302
3 - REL1306
</code></pre>
<p>I need to create a variable that appends itself based on the number... | 34,306 | 742,279 | 2013-09-03 20:32:37 | 18,600,971 | 28 | 2013-09-03 20:32:37 | 2,098,699 | 2013-09-03 20:32:37 | https://stackoverflow.com/q/18600317 | https://stackoverflow.com/a/18600971 | <p>example:</p>
<pre><code>@ECHO OFF &SETLOCAL
SET /a count=5
for /l %%a in (1,1,%count%) do call set "Myvar=%%Myvar%%, %%a"
ECHO %Myvar:~2%
</code></pre>
<p>..output is:</p>
<pre><code>1, 2, 3, 4, 5
</code></pre>
| <p>example:</p> <pre><code>@ECHO OFF &SETLOCAL SET /a count=5 for /l %%a in (1,1,%count%) do call set "Myvar=%%Myvar%%, %%a" ECHO %Myvar:~2% </code></pre> <p>..output is:</p> <pre><code>1, 2, 3, 4, 5 </code></pre> | 7002 | batch-file | <h1>Batch File: Append a string inside a for loop</h1>
<p>I have the following for loop:</p>
<pre><code>for /l %%a in (1,1,%count%) do (
<nul set /p=" %%a - "
Echo !var%%a!
)
</code></pre>
<p>which will display something like this:</p>
<pre><code>1 - REL1206
2 - REL1302
3 - REL1306
</code></pre>
<p>I need to cr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,654 | cmd | # Batch File: Append a string inside a for loop
I have the following for loop:
```
for /l %%a in (1,1,%count%) do (
<nul set /p=" %%a - "
Echo !var%%a!
)
```
which will display something like this:
```
1 - REL1206
2 - REL1302
3 - REL1306
```
I need to create a variable that appends itself based on the number of i... | example:
```
@ECHO OFF &SETLOCAL
SET /a count=5
for /l %%a in (1,1,%count%) do call set "Myvar=%%Myvar%%, %%a"
ECHO %Myvar:~2%
```
..output is:
```
1, 2, 3, 4, 5
``` |
8523997 | Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/batch] | 12 | 2011-12-15 17:14:22 | <h3>Situation</h3>
<p>I am using Spring Batch to build an Accumulative Snapshot for our Data Warehouse and I am having a configuration roadblock that I cannot figure out.</p>
<p>I have created a Simple Spring Batch Project with STS (SpringSource Tool Suite 2.8.1) using the <strong>Spring Template Project</strong>. Thes... | 43,212 | 615,636 | 2015-03-12 07:16:23 | 8,574,629 | 28 | 2011-12-20 11:20:34 | 62,201 | 2013-02-14 09:25:28 | https://stackoverflow.com/q/8523997 | https://stackoverflow.com/a/8574629 | <blockquote>
<p>Run the job through CommandLineJobRunner: java -jar
batchprimer-1.0.jar META-INF/spring/module-context.xml job1</p>
</blockquote>
<p><strong>even with a complete target folder you have to provide the classpath information for the java command</strong>, to ease the configuration you can try it with ... | <blockquote> <p>Run the job through CommandLineJobRunner: java -jar batchprimer-1.0.jar META-INF/spring/module-context.xml job1</p> </blockquote> <p><strong>even with a complete target folder you have to provide the classpath information for the java command</strong>, to ease the configuration you can try it with ... | 1211, 41895 | spring, spring-batch | <h1>Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/batch]</h1>
<h3>Situation</h3>
<p>I am using Spring Batch to build an Accumulative Snapshot for our Data Warehouse and I am having a configuration roadblock that I cannot figure out.</p>
<p>I have created a Simp... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,655 | cmd | # Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/batch]
### Situation
I am using Spring Batch to build an Accumulative Snapshot for our Data Warehouse and I am having a configuration roadblock that I cannot figure out.
I have created a Simple Spring Batch Pro... | > Run the job through CommandLineJobRunner: java -jar
> batchprimer-1.0.jar META-INF/spring/module-context.xml job1
**even with a complete target folder you have to provide the classpath information for the java command**, to ease the configuration you can try it with an all-in-one executable jar e.g. with [maven-shad... |
15450163 | "Counter" in Batch | 10 | 2013-03-16 13:59:22 | <p>I'm trying to make a Batch file that will increment a variable by 1 each time it loops, and then check if the variable is equal to 5, and if it isn't, it loops again. I know there's probably a while loop for this, but I didn't know how to do that, and I'm just enjoying learning Batch for fun right now</p>
<p>Here's... | 111,764 | 2,152,304 | 2019-04-03 15:46:08 | 15,450,348 | 28 | 2013-03-16 14:18:41 | 1,019,227 | 2013-03-16 14:29:27 | https://stackoverflow.com/q/15450163 | https://stackoverflow.com/a/15450348 | <p>This is a way to simulate the while loop you are trying to accomplish. Only one <code>goto</code> is needed:</p>
<pre><code>@echo off
set /a x=0
:while
if %x% lss 5 (
echo %x%
pause>nul
set /a x+=1
goto :while
)
echo Test :D
</code></pre>
| <p>This is a way to simulate the while loop you are trying to accomplish. Only one <code>goto</code> is needed:</p> <pre><code>@echo off set /a x=0 :while if %x% lss 5 ( echo %x% pause>nul set /a x+=1 goto :while ) echo Test :D </code></pre> | 7002 | batch-file | <h1>"Counter" in Batch</h1>
<p>I'm trying to make a Batch file that will increment a variable by 1 each time it loops, and then check if the variable is equal to 5, and if it isn't, it loops again. I know there's probably a while loop for this, but I didn't know how to do that, and I'm just enjoying learning Batch for ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,656 | cmd | # "Counter" in Batch
I'm trying to make a Batch file that will increment a variable by 1 each time it loops, and then check if the variable is equal to 5, and if it isn't, it loops again. I know there's probably a while loop for this, but I didn't know how to do that, and I'm just enjoying learning Batch for fun right... | This is a way to simulate the while loop you are trying to accomplish. Only one `goto` is needed:
```
@echo off
set /a x=0
:while
if %x% lss 5 (
echo %x%
pause>nul
set /a x+=1
goto :while
)
echo Test :D
``` |
4267948 | Creating a blank file from a batch file | 9 | 2010-11-24 14:37:32 | <p>I would like create a file from a batch file. I can use the <code>echo. > donald.txt</code>, but it creates it with an initial blank line. What else I can use to a file starting from the first line?</p>
| 30,108 | null | 2018-07-18 20:24:37 | 4,267,994 | 28 | 2010-11-24 14:42:18 | 12,744 | 2010-11-24 14:42:18 | https://stackoverflow.com/q/4267948 | https://stackoverflow.com/a/4267994 | <p>You just want to create a completely empty file? This will do it:</p>
<pre><code>copy /y nul donald.txt
</code></pre>
<p>If you're looking to write something to first line, you want something like this:</p>
<pre><code>echo Hello, World > donald.txt
</code></pre>
| <p>You just want to create a completely empty file? This will do it:</p> <pre><code>copy /y nul donald.txt </code></pre> <p>If you're looking to write something to first line, you want something like this:</p> <pre><code>echo Hello, World > donald.txt </code></pre> | 64, 5310, 7002 | batch-file, file, windows | <h1>Creating a blank file from a batch file</h1>
<p>I would like create a file from a batch file. I can use the <code>echo. > donald.txt</code>, but it creates it with an initial blank line. What else I can use to a file starting from the first line?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,657 | cmd | # Creating a blank file from a batch file
I would like create a file from a batch file. I can use the `echo. > donald.txt`, but it creates it with an initial blank line. What else I can use to a file starting from the first line? | You just want to create a completely empty file? This will do it:
```
copy /y nul donald.txt
```
If you're looking to write something to first line, you want something like this:
```
echo Hello, World > donald.txt
``` |
4796577 | Windows 7 32-bit Program Files path in a Batch file Issue | 8 | 2011-01-25 17:05:21 | <p>I have batch file that I am inheriting and I cannot get to work in a 64bit Windows 7 environment. The batch file makes a call to a java script, and passes two variables in it. The old on looked like this:</p>
<pre><code> C:\Progra~1\salesf~1.com\ApexDa~2.0\bin\process.bat C:\Progra~1\*PATH* *VARIABLE*
</cod... | 56,333 | 589,332 | 2014-01-24 06:17:13 | 4,797,055 | 28 | 2011-01-25 17:53:56 | 188,414 | 2013-07-17 09:29:37 | https://stackoverflow.com/q/4796577 | https://stackoverflow.com/a/4797055 | <p>If you type</p>
<pre><code> dir /x c:\
</code></pre>
<p>then this shows the directory listing in the 8.3 format. <code>Program Files</code> expands to <code>PROGRA~1</code> and <code>Program Files (x86)</code> expands to <code>PROGRA~2</code>. So I think you'll need to change the script to use <code>PROGRA~2</co... | <p>If you type</p> <pre><code> dir /x c:\ </code></pre> <p>then this shows the directory listing in the 8.3 format. <code>Program Files</code> expands to <code>PROGRA~1</code> and <code>Program Files (x86)</code> expands to <code>PROGRA~2</code>. So I think you'll need to change the script to use <code>PROGRA~2</co... | 64, 6268, 7002 | batch-file, path, windows | <h1>Windows 7 32-bit Program Files path in a Batch file Issue</h1>
<p>I have batch file that I am inheriting and I cannot get to work in a 64bit Windows 7 environment. The batch file makes a call to a java script, and passes two variables in it. The old on looked like this:</p>
<pre><code> C:\Progra~1\salesf~1.com\Ape... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,658 | cmd | # Windows 7 32-bit Program Files path in a Batch file Issue
I have batch file that I am inheriting and I cannot get to work in a 64bit Windows 7 environment. The batch file makes a call to a java script, and passes two variables in it. The old on looked like this:
```
C:\Progra~1\salesf~1.com\ApexDa~2.0\bin\process.... | If you type
```
dir /x c:\
```
then this shows the directory listing in the 8.3 format. `Program Files` expands to `PROGRA~1` and `Program Files (x86)` expands to `PROGRA~2`. So I think you'll need to change the script to use `PROGRA~2`
EDIT: I agree with Mark that this isn't ideal -- it depends how much you are ab... |
3667026 | Meaning of %%~dpa? | 7 | 2010-09-08 11:05:28 | <p>I am given to maintain some batch files and i repeatedly see this line in the beginning of every batch file..</p>
<pre><code>FOR /f "usebackq tokens=*" %%a IN ('%0') DO SET this_cmds_dir=%%~dpa
CD /d "%this_cmds_dir%"
</code></pre>
<p>Does anyone know what the first line does? What is %%~dpa? What is %0 ? What is ... | 28,272 | 184,774 | 2017-12-29 10:16:38 | 3,667,093 | 28 | 2010-09-08 11:13:50 | 14,860 | 2010-09-08 11:42:56 | https://stackoverflow.com/q/3667026 | https://stackoverflow.com/a/3667093 | <p><code>%~dpa</code> gives you the drive and the path of the file pointed to by <code>%a</code> (using double <code>%</code> since you're running within a script, of course). From the bottom of the <code>for /?</code> help in <code>cmd.exe</code>:</p>
<pre>In addition, substitution of FOR variable references has been... | <p><code>%~dpa</code> gives you the drive and the path of the file pointed to by <code>%a</code> (using double <code>%</code> since you're running within a script, of course). From the bottom of the <code>for /?</code> help in <code>cmd.exe</code>:</p> <pre>In addition, substitution of FOR variable references has been... | 2631, 7002 | batch-file, cmd | <h1>Meaning of %%~dpa?</h1>
<p>I am given to maintain some batch files and i repeatedly see this line in the beginning of every batch file..</p>
<pre><code>FOR /f "usebackq tokens=*" %%a IN ('%0') DO SET this_cmds_dir=%%~dpa
CD /d "%this_cmds_dir%"
</code></pre>
<p>Does anyone know what the first line does? What is %... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,659 | cmd | # Meaning of %%~dpa?
I am given to maintain some batch files and i repeatedly see this line in the beginning of every batch file..
```
FOR /f "usebackq tokens=*" %%a IN ('%0') DO SET this_cmds_dir=%%~dpa
CD /d "%this_cmds_dir%"
```
Does anyone know what the first line does? What is %%~dpa? What is %0 ? What is useba... | `%~dpa` gives you the drive and the path of the file pointed to by `%a` (using double `%` since you're running within a script, of course). From the bottom of the `for /?` help in `cmd.exe`:
```
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I ... |
4339649 | How to have multiple colors in a Windows batch file? | 80 | 2010-12-02 20:44:00 | <p>I was wondering if its possible to have different colored text on the same line in a Windows batch file, for example if it says</p>
<pre><code>echo hi world
</code></pre>
<p>I want "hi" to be one color, and "world" to be another color. Maybe I could set the COLOR command as a variable:</p>
<pre><code>set color1= ... | 145,845 | 524,670 | 2024-01-11 10:20:29 | 12,695,079 | 27 | 2012-10-02 17:17:18 | 1,715,020 | 2012-10-03 07:28:10 | https://stackoverflow.com/q/4339649 | https://stackoverflow.com/a/12695079 | <p>Actually this can be done without creating a temporary file.
The method described by jeb and dbenham will work even with a target file that contains no backspaces. The critical point is that the line recognized by findstr.exe must not end with a CRLF.
So the obvious text file to scan with a line not ending with a CR... | <p>Actually this can be done without creating a temporary file. The method described by jeb and dbenham will work even with a target file that contains no backspaces. The critical point is that the line recognized by findstr.exe must not end with a CRLF. So the obvious text file to scan with a line not ending with a CR... | 64, 2631, 6439, 7002, 12658 | batch-file, character-encoding, cmd, colors, windows | <h1>How to have multiple colors in a Windows batch file?</h1>
<p>I was wondering if its possible to have different colored text on the same line in a Windows batch file, for example if it says</p>
<pre><code>echo hi world
</code></pre>
<p>I want "hi" to be one color, and "world" to be another color. Maybe I could set... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,660 | cmd | # How to have multiple colors in a Windows batch file?
I was wondering if its possible to have different colored text on the same line in a Windows batch file, for example if it says
```
echo hi world
```
I want "hi" to be one color, and "world" to be another color. Maybe I could set the COLOR command as a variable:... | Actually this can be done without creating a temporary file.
The method described by jeb and dbenham will work even with a target file that contains no backspaces. The critical point is that the line recognized by findstr.exe must not end with a CRLF.
So the obvious text file to scan with a line not ending with a CRLF ... |
61063676 | Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output - while installing auto-py-to-exe through pip | 45 | 2020-04-06 15:48:13 | <p>I am trying to download auto-py-to-exe on a different (windows) device than I usually use through pip. However when run I get the error (sorry it is so very very long): </p>
<pre><code>ERROR: Command errored out with exit status 1:
command: 'c:\users\tom\appdata\local\programs\python\python38-32\python.exe' -c... | 267,609 | 12,903,729 | 2024-06-05 01:00:46 | 61,144,180 | 27 | 2020-04-10 16:10:10 | 2,650,249 | 2020-12-17 13:23:52 | https://stackoverflow.com/q/61063676 | https://stackoverflow.com/a/61144180 | <h3>Edit</h3>
<p>Since this answer was posted, <code>gevent</code> has released several new versions, including prebuilt wheels for Python 3.8 on Windows, so the <code>pip install gevent --pre</code> shouldn't be necessary anymore - just run <code>pip install auto-py-to-exe</code> as usual and it should work.</p>
<h3>O... | <h3>Edit</h3> <p>Since this answer was posted, <code>gevent</code> has released several new versions, including prebuilt wheels for Python 3.8 on Windows, so the <code>pip install gevent --pre</code> shouldn't be necessary anymore - just run <code>pip install auto-py-to-exe</code> as usual and it should work.</p> <h3>O... | 16, 2631, 5119 | cmd, pip, python | <h1>Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output - while installing auto-py-to-exe through pip</h1>
<p>I am trying to download auto-py-to-exe on a different (windows) device than I usually use through pip. However when run I get the error (sorry it is so very v... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,661 | cmd | # Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output - while installing auto-py-to-exe through pip
I am trying to download auto-py-to-exe on a different (windows) device than I usually use through pip. However when run I get the error (sorry it is so very very long)... | ### Edit
Since this answer was posted, `gevent` has released several new versions, including prebuilt wheels for Python 3.8 on Windows, so the `pip install gevent --pre` shouldn't be necessary anymore - just run `pip install auto-py-to-exe` as usual and it should work.
### Original answer
Allow prerelease `gevent` v... |
14762813 | Remove leading zeros in batch file | 25 | 2013-02-07 23:06:55 | <p>In my application, I get a number having leading zeros. I am trying to trim the leading zeros and get the actual number. I tried using <code>/a</code> switch which considers right side of the assignment as an arithmetic expression. So I tried:</p>
<pre><code>SET /a N = 00027
</code></pre>
<p>The above gave me the ... | 23,050 | 528,724 | 2020-02-22 09:57:13 | 14,772,105 | 27 | 2013-02-08 12:00:13 | 1,012,053 | 2019-06-06 15:24:02 | https://stackoverflow.com/q/14762813 | https://stackoverflow.com/a/14772105 | <p>The method you found is very good. It supports numbers up to 99,999,999 and is very fast.</p>
<p>There is a simpler way to use SET /A that works with numbers up to 9999. It uses the modulus operation. The method cannot be extended to larger numbers.</p>
<pre><code> set n=0027
set /a n=10000%n% %% 10000
</code></p... | <p>The method you found is very good. It supports numbers up to 99,999,999 and is very fast.</p> <p>There is a simpler way to use SET /A that works with numbers up to 9999. It uses the modulus operation. The method cannot be extended to larger numbers.</p> <pre><code> set n=0027 set /a n=10000%n% %% 10000 </code></p... | 5641, 7002, 15517 | batch-file, trim, zero | <h1>Remove leading zeros in batch file</h1>
<p>In my application, I get a number having leading zeros. I am trying to trim the leading zeros and get the actual number. I tried using <code>/a</code> switch which considers right side of the assignment as an arithmetic expression. So I tried:</p>
<pre><code>SET /a N = 00... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,663 | cmd | # Remove leading zeros in batch file
In my application, I get a number having leading zeros. I am trying to trim the leading zeros and get the actual number. I tried using `/a` switch which considers right side of the assignment as an arithmetic expression. So I tried:
```
SET /a N = 00027
```
The above gave me the ... | The method you found is very good. It supports numbers up to 99,999,999 and is very fast.
There is a simpler way to use SET /A that works with numbers up to 9999. It uses the modulus operation. The method cannot be extended to larger numbers.
```
set n=0027
set /a n=10000%n% %% 10000
```
The FOR /F method that Dal... |
48828865 | Why is it 'npm install -g @angular/cli'? | 23 | 2018-02-16 14:27:00 | <p>I know there are a lot of questions regarding this npm package installing, but I couldn't find the exact relevant answer.</p>
<p>I have already installed npm and also developed a few applications in my Visual Studio. Every time, before developing the new project of Angular, do we need to install npm again by typing... | 70,585 | 9,322,814 | 2024-11-08 10:34:32 | 48,830,414 | 27 | 2018-02-16 15:54:26 | 3,169,096 | 2023-11-01 03:16:39 | https://stackoverflow.com/q/48828865 | https://stackoverflow.com/a/48830414 | <p>Once you have installed @angular/cli globally, in the next project you just need run <code>ng new app-name</code>.
This command will create a folder named 'app-name' and then will install all dependencies locally, including @angular/cli.</p>
<p>Installing @angular/cli globally allow you to use 'ng' command everywher... | <p>Once you have installed @angular/cli globally, in the next project you just need run <code>ng new app-name</code>. This command will create a folder named 'app-name' and then will install all dependencies locally, including @angular/cli.</p> <p>Installing @angular/cli globally allow you to use 'ng' command everywher... | 2631, 46426, 61387, 125866, 129468 | angular, angular5, cmd, node.js, npm | <h1>Why is it 'npm install -g @angular/cli'?</h1>
<p>I know there are a lot of questions regarding this npm package installing, but I couldn't find the exact relevant answer.</p>
<p>I have already installed npm and also developed a few applications in my Visual Studio. Every time, before developing the new project of ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,664 | cmd | # Why is it 'npm install -g @angular/cli'?
I know there are a lot of questions regarding this npm package installing, but I couldn't find the exact relevant answer.
I have already installed npm and also developed a few applications in my Visual Studio. Every time, before developing the new project of Angular, do we n... | Once you have installed @angular/cli globally, in the next project you just need run `ng new app-name`.
This command will create a folder named 'app-name' and then will install all dependencies locally, including @angular/cli.
Installing @angular/cli globally allow you to use 'ng' command everywhere. It's required to ... |
20218076 | Batch file: Drop elevated privileges (run a command as original user) | 23 | 2013-11-26 13:13:18 | <p>I have a batch file that starts with elevated privileges (my installer spawns it), but at a certain point I need to run a command as the original user who started my installer (i.e. drop from the elevated privileges).</p>
<p>Is it possible to do so?</p>
| 20,261 | 492,336 | 2022-05-04 08:31:00 | 20,218,503 | 27 | 2013-11-26 13:33:21 | 1,083,663 | 2013-11-26 13:49:21 | https://stackoverflow.com/q/20218076 | https://stackoverflow.com/a/20218503 | <p>You can run a command with restricted privileges with:</p>
<pre><code>runas /trustlevel:0x20000 "YourCommandHere"
</code></pre>
<p>You should provide the absolute path to your command including any arguments in double quotes as an argument to <code>runas</code>.</p>
<p>If you would like to run more than one comma... | <p>You can run a command with restricted privileges with:</p> <pre><code>runas /trustlevel:0x20000 "YourCommandHere" </code></pre> <p>You should provide the absolute path to your command including any arguments in double quotes as an argument to <code>runas</code>.</p> <p>If you would like to run more than one comma... | 7002, 60888 | batch-file, elevated-privileges | <h1>Batch file: Drop elevated privileges (run a command as original user)</h1>
<p>I have a batch file that starts with elevated privileges (my installer spawns it), but at a certain point I need to run a command as the original user who started my installer (i.e. drop from the elevated privileges).</p>
<p>Is it possib... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,665 | cmd | # Batch file: Drop elevated privileges (run a command as original user)
I have a batch file that starts with elevated privileges (my installer spawns it), but at a certain point I need to run a command as the original user who started my installer (i.e. drop from the elevated privileges).
Is it possible to do so? | You can run a command with restricted privileges with:
```
runas /trustlevel:0x20000 "YourCommandHere"
```
You should provide the absolute path to your command including any arguments in double quotes as an argument to `runas`.
If you would like to run more than one command with restricted privileges, you can put th... |
10824178 | How do you redirect standard input to a file in the Windows command line? | 21 | 2012-05-30 20:59:06 | <p>On Unix I would do something like:</p>
<pre><code>cat > file.txt
</code></pre>
<p>How can I do this on the Windows command prompt or batch file?</p>
<p><strong>EDIT:</strong> Basically, I am looking for the functionality of <code>cat</code> with no arguments (it reads from stdin and spits it back out to stdout... | 50,834 | 810,671 | 2022-03-11 05:02:53 | 16,566,534 | 27 | 2013-05-15 13:36:08 | 1,156,377 | 2015-10-09 21:39:54 | https://stackoverflow.com/q/10824178 | https://stackoverflow.com/a/16566534 | <p><code>TYPE CON</code></p>
<p>CON is the MS-DOS device for console input. You can redirect to a file as follows:</p>
<p><code>TYPE CON>output.txt</code></p>
<p>To terminate, hit <kbd>Ctrl</kbd> + <kbd>C</kbd> or <kbd>Ctrl</kbd> + <kbd>Z</kbd>, <kbd>Enter</kbd> (<kbd>Ctrl</kbd> + <kbd>Z</kbd> = EOF).</p>
| <p><code>TYPE CON</code></p> <p>CON is the MS-DOS device for console input. You can redirect to a file as follows:</p> <p><code>TYPE CON>output.txt</code></p> <p>To terminate, hit <kbd>Ctrl</kbd> + <kbd>C</kbd> or <kbd>Ctrl</kbd> + <kbd>Z</kbd>, <kbd>Enter</kbd> (<kbd>Ctrl</kbd> + <kbd>Z</kbd> = EOF).</p> | 1701, 2631, 7002, 22820 | batch-file, cat, cmd, stdin | <h1>How do you redirect standard input to a file in the Windows command line?</h1>
<p>On Unix I would do something like:</p>
<pre><code>cat > file.txt
</code></pre>
<p>How can I do this on the Windows command prompt or batch file?</p>
<p><strong>EDIT:</strong> Basically, I am looking for the functionality of <cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,666 | cmd | # How do you redirect standard input to a file in the Windows command line?
On Unix I would do something like:
```
cat > file.txt
```
How can I do this on the Windows command prompt or batch file?
**EDIT:** Basically, I am looking for the functionality of `cat` with no arguments (it reads from stdin and spits it ba... | `TYPE CON`
CON is the MS-DOS device for console input. You can redirect to a file as follows:
`TYPE CON>output.txt`
To terminate, hit `Ctrl` + `C` or `Ctrl` + `Z`, `Enter` (`Ctrl` + `Z` = EOF). |
7846560 | how concatenate two variables in batch script? | 20 | 2011-10-21 07:56:49 | <p>I want to do something like this in batch script. Please let me know if this is the proper or possible way to do it or any other way?</p>
<pre><code>set var1=A
set var2=B
set AB=hi
set newvar=%var1%%var2%
echo %newvar%
</code></pre>
<p>This should produce the value "hi".</p>
| 159,849 | 511,945 | 2016-04-30 12:48:31 | 7,847,023 | 27 | 2011-10-21 08:44:58 | 122,951 | 2011-10-21 08:44:58 | https://stackoverflow.com/q/7846560 | https://stackoverflow.com/a/7847023 | <p>Enabling delayed variable expansion solves you problem, the script produces "hi":</p>
<pre><code>setlocal EnableDelayedExpansion
set var1=A
set var2=B
set AB=hi
set newvar=!%var1%%var2%!
echo %newvar%
</code></pre>
| <p>Enabling delayed variable expansion solves you problem, the script produces "hi":</p> <pre><code>setlocal EnableDelayedExpansion set var1=A set var2=B set AB=hi set newvar=!%var1%%var2%! echo %newvar% </code></pre> | 7002, 9938 | batch-file, command-prompt | <h1>how concatenate two variables in batch script?</h1>
<p>I want to do something like this in batch script. Please let me know if this is the proper or possible way to do it or any other way?</p>
<pre><code>set var1=A
set var2=B
set AB=hi
set newvar=%var1%%var2%
echo %newvar%
</code></pre>
<p>This should produ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,667 | cmd | # how concatenate two variables in batch script?
I want to do something like this in batch script. Please let me know if this is the proper or possible way to do it or any other way?
```
set var1=A
set var2=B
set AB=hi
set newvar=%var1%%var2%
echo %newvar%
```
This should produce the value "hi". | Enabling delayed variable expansion solves you problem, the script produces "hi":
```
setlocal EnableDelayedExpansion
set var1=A
set var2=B
set AB=hi
set newvar=!%var1%%var2%!
echo %newvar%
``` |
1497985 | Batch : Checking the number of parameters | 20 | 2009-09-30 13:06:36 | <p>I'd like to make sure that when calling my batch, no more than 2 parameters are passed.</p>
<p>Is there an easy way to check that, or do I have to call SHIFT as many times as needed until the parameter value is empty ?</p>
| 33,841 | 2,796 | 2017-07-11 15:52:18 | 1,498,013 | 27 | 2009-09-30 13:11:20 | 73,070 | 2013-08-25 10:51:32 | https://stackoverflow.com/q/1497985 | https://stackoverflow.com/a/1498013 | <p>You can simply test for existence of a third parameter and cancel if present:</p>
<pre><code>if not "%~3"=="" (
echo No more than two arguments, please
goto :eof
)
</code></pre>
<p>But more specifically, there is no direct way of getting the number of arguments passed to a batch, short of <code>shift</code... | <p>You can simply test for existence of a third parameter and cancel if present:</p> <pre><code>if not "%~3"=="" ( echo No more than two arguments, please goto :eof ) </code></pre> <p>But more specifically, there is no direct way of getting the number of arguments passed to a batch, short of <code>shift</code... | 7002 | batch-file | <h1>Batch : Checking the number of parameters</h1>
<p>I'd like to make sure that when calling my batch, no more than 2 parameters are passed.</p>
<p>Is there an easy way to check that, or do I have to call SHIFT as many times as needed until the parameter value is empty ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,668 | cmd | # Batch : Checking the number of parameters
I'd like to make sure that when calling my batch, no more than 2 parameters are passed.
Is there an easy way to check that, or do I have to call SHIFT as many times as needed until the parameter value is empty ? | You can simply test for existence of a third parameter and cancel if present:
```
if not "%~3"=="" (
echo No more than two arguments, please
goto :eof
)
```
But more specifically, there is no direct way of getting the number of arguments passed to a batch, short of `shift`ing and counting them. So if you want... |
19798777 | Accessing Batch Functions in another batch file | 19 | 2013-11-05 20:54:44 | <p>Alright, so lets say we have a file called "lib.cmd" it contains</p>
<pre><code>@echo off
GOTO:EXIT
:FUNCTION
echo something
GOTO:EOF
:EXIT
exit /b
</code></pre>
<p>Then we have a file called "init.cmd" it contains</p>
<pre><code>@echo off
call lib.cmd
</code></pre>
<p>Is there anyway to access :FUNCTION... | 9,294 | 2,174,716 | 2021-03-30 16:22:13 | 19,798,865 | 27 | 2013-11-05 21:00:03 | 388,389 | 2017-11-05 18:54:55 | https://stackoverflow.com/q/19798777 | https://stackoverflow.com/a/19798865 | <p>Change your <code>lib.cmd</code> to look like this;</p>
<pre><code>@echo off
call:%~1
goto exit
:function
echo something
goto:eof
:exit
exit /b
</code></pre>
<p>Then the first argument passed to the batch file (<code>%~1</code>) will identify as the function you want to call, so it will be called with <code... | <p>Change your <code>lib.cmd</code> to look like this;</p> <pre><code>@echo off call:%~1 goto exit :function echo something goto:eof :exit exit /b </code></pre> <p>Then the first argument passed to the batch file (<code>%~1</code>) will identify as the function you want to call, so it will be called with <code... | 7002 | batch-file | <h1>Accessing Batch Functions in another batch file</h1>
<p>Alright, so lets say we have a file called "lib.cmd" it contains</p>
<pre><code>@echo off
GOTO:EXIT
:FUNCTION
echo something
GOTO:EOF
:EXIT
exit /b
</code></pre>
<p>Then we have a file called "init.cmd" it contains</p>
<pre><code>@echo off
call lib.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,670 | cmd | # Accessing Batch Functions in another batch file
Alright, so lets say we have a file called "lib.cmd" it contains
```
@echo off
GOTO:EXIT
:FUNCTION
echo something
GOTO:EOF
:EXIT
exit /b
```
Then we have a file called "init.cmd" it contains
```
@echo off
call lib.cmd
```
Is there anyway to access :FUNCTION... | Change your `lib.cmd` to look like this;
```
@echo off
call:%~1
goto exit
:function
echo something
goto:eof
:exit
exit /b
```
Then the first argument passed to the batch file (`%~1`) will identify as the function you want to call, so it will be called with `call:%~1`, and now you can call it in `init.cmd` in t... |
305605 | Weird scope issue in .bat file | 19 | 2008-11-20 15:16:42 | <p>I'm writing a simple .bat file and I've run into some weird behavior. There are a couple places where I have to do a simple if/else, but the code inside the blocks don't seem to be working correctly.</p>
<p>Here's a simple case that demonstrates the error:</p>
<pre><code>@echo off
set MODE=FOOBAR
if "%~1"=="" (... | 7,582 | 1,409 | 2021-12-05 14:11:40 | 305,640 | 27 | 2008-11-20 15:26:58 | 33,675 | 2008-11-20 15:26:58 | https://stackoverflow.com/q/305605 | https://stackoverflow.com/a/305640 | <p>You are running into the problem of cmd's static variable expansion. The MODE variable is only evaluated once. You can see this if you omit the @echo off line.</p>
<p>From the set /? documentation:</p>
<blockquote>
<p>Finally, support for delayed environment variable expansion has
been added. This support is ... | <p>You are running into the problem of cmd's static variable expansion. The MODE variable is only evaluated once. You can see this if you omit the @echo off line.</p> <p>From the set /? documentation:</p> <blockquote> <p>Finally, support for delayed environment variable expansion has been added. This support is ... | 2182, 7002 | batch-file, scope | <h1>Weird scope issue in .bat file</h1>
<p>I'm writing a simple .bat file and I've run into some weird behavior. There are a couple places where I have to do a simple if/else, but the code inside the blocks don't seem to be working correctly.</p>
<p>Here's a simple case that demonstrates the error:</p>
<pre><code>@e... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,671 | cmd | # Weird scope issue in .bat file
I'm writing a simple .bat file and I've run into some weird behavior. There are a couple places where I have to do a simple if/else, but the code inside the blocks don't seem to be working correctly.
Here's a simple case that demonstrates the error:
```
@echo off
set MODE=FOOBAR
if... | You are running into the problem of cmd's static variable expansion. The MODE variable is only evaluated once. You can see this if you omit the @echo off line.
From the set /? documentation:
> Finally, support for delayed environment variable expansion has
> been added. This support is always
> disabled by default, b... |
416957 | Change a shortcut's target from command prompt | 18 | 2009-01-06 15:26:49 | <p>I'm normally a Linux guy, but I need to write a batch script on Windows to change the target of some shortcuts. Is there a command to do that?</p>
| 66,599 | 1,103,052 | 2015-01-02 12:44:00 | 417,036 | 27 | 2009-01-06 15:46:36 | 45,084 | 2009-01-06 15:46:36 | https://stackoverflow.com/q/416957 | https://stackoverflow.com/a/417036 | <p>I doubt there is a way to do it with a batch script. It's <a href="http://msdn.microsoft.com/en-us/library/xk6kst2k(VS.85).aspx" rel="noreferrer">doable</a> in VBScript, though.</p>
<pre><code>Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\Wherever\Shortcut.lnk")
shortcut.TargetPath = "... | <p>I doubt there is a way to do it with a batch script. It's <a href="http://msdn.microsoft.com/en-us/library/xk6kst2k(VS.85).aspx" rel="noreferrer">doable</a> in VBScript, though.</p> <pre><code>Set sh = CreateObject("WScript.Shell") Set shortcut = sh.CreateShortcut("C:\Wherever\Shortcut.lnk") shortcut.TargetPath = "... | 64, 7002, 7201 | batch-file, shortcut, windows | <h1>Change a shortcut's target from command prompt</h1>
<p>I'm normally a Linux guy, but I need to write a batch script on Windows to change the target of some shortcuts. Is there a command to do that?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,672 | cmd | # Change a shortcut's target from command prompt
I'm normally a Linux guy, but I need to write a batch script on Windows to change the target of some shortcuts. Is there a command to do that? | I doubt there is a way to do it with a batch script. It's [doable](http://msdn.microsoft.com/en-us/library/xk6kst2k(VS.85).aspx) in VBScript, though.
```
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\Wherever\Shortcut.lnk")
shortcut.TargetPath = "C:\Wherever\Whatever.txt"
shortcut.Save
``... |
368041 | How to code a spinner for waiting processes in a Batch file? | 18 | 2008-12-15 11:10:02 | <p>I would like to show the user with a spinner, that something is done in background but do not know how this works in a batchfile.</p>
<p>Does anyone have a clue?</p>
| 38,120 | 44,532 | 2024-02-10 04:07:20 | 371,276 | 27 | 2008-12-16 13:19:04 | 14,860 | 2008-12-16 13:19:04 | https://stackoverflow.com/q/368041 | https://stackoverflow.com/a/371276 | <p>This can actually be done quite easily with pure native commands, you just have to know how to use the more tricky of them. No use of external tools like VBScript or nasty side effects like clearing the screen are necessary.</p>
<p>What you're looking for is the equivalent of the bash "<code>echo -n</code>" command... | <p>This can actually be done quite easily with pure native commands, you just have to know how to use the more tricky of them. No use of external tools like VBScript or nasty side effects like clearing the screen are necessary.</p> <p>What you're looking for is the equivalent of the bash "<code>echo -n</code>" command... | 7002, 18685 | batch-file, spinner | <h1>How to code a spinner for waiting processes in a Batch file?</h1>
<p>I would like to show the user with a spinner, that something is done in background but do not know how this works in a batchfile.</p>
<p>Does anyone have a clue?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,673 | cmd | # How to code a spinner for waiting processes in a Batch file?
I would like to show the user with a spinner, that something is done in background but do not know how this works in a batchfile.
Does anyone have a clue? | This can actually be done quite easily with pure native commands, you just have to know how to use the more tricky of them. No use of external tools like VBScript or nasty side effects like clearing the screen are necessary.
What you're looking for is the equivalent of the bash "`echo -n`" command which outputs a line... |
16748148 | Running cmd in python | 16 | 2013-05-25 09:23:37 | <p>Atm I have this as my code, the first line seems to work well but the 2nd gives errrors.</p>
<pre><code>os.chdir('C://Users/Alex/Dropbox/code stuff/test')
subprocess.call('ffmpeg -i test%d0.png output.avi')
</code></pre>
<p>Also when I try to run it as this, it gives a 1s cmd flicker and then nothing happens</p>
<pr... | 49,236 | 1,608,765 | 2021-06-16 07:34:00 | 16,758,328 | 27 | 2013-05-26 10:29:48 | 1,608,765 | 2019-02-18 14:31:57 | https://stackoverflow.com/q/16748148 | https://stackoverflow.com/a/16758328 | <p>For the later generations looking for the answer, this worked. (You have to separate the command by the spaces.)</p>
<pre><code>import os
import subprocess
os.chdir('C://Users/Alex/')
subprocess.call(['ffmpeg', '-i', 'picture%d0.png', 'output.avi'])
subprocess.call(['ffmpeg', '-i', 'output.avi', '-t', '5', 'out.gif... | <p>For the later generations looking for the answer, this worked. (You have to separate the command by the spaces.)</p> <pre><code>import os import subprocess os.chdir('C://Users/Alex/') subprocess.call(['ffmpeg', '-i', 'picture%d0.png', 'output.avi']) subprocess.call(['ffmpeg', '-i', 'output.avi', '-t', '5', 'out.gif... | 16, 2631 | cmd, python | <h1>Running cmd in python</h1>
<p>Atm I have this as my code, the first line seems to work well but the 2nd gives errrors.</p>
<pre><code>os.chdir('C://Users/Alex/Dropbox/code stuff/test')
subprocess.call('ffmpeg -i test%d0.png output.avi')
</code></pre>
<p>Also when I try to run it as this, it gives a 1s cmd flicker a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,674 | cmd | # Running cmd in python
Atm I have this as my code, the first line seems to work well but the 2nd gives errrors.
```
os.chdir('C://Users/Alex/Dropbox/code stuff/test')
subprocess.call('ffmpeg -i test%d0.png output.avi')
```
Also when I try to run it as this, it gives a 1s cmd flicker and then nothing happens
```
os... | For the later generations looking for the answer, this worked. (You have to separate the command by the spaces.)
```
import os
import subprocess
os.chdir('C://Users/Alex/')
subprocess.call(['ffmpeg', '-i', 'picture%d0.png', 'output.avi'])
subprocess.call(['ffmpeg', '-i', 'output.avi', '-t', '5', 'out.gif'])
``` |
39913918 | Spring boot + spring batch without DataSource | 15 | 2016-10-07 09:27:46 | <p>I'm trying to configure spring batch inside spring boot project and I want to use it without data source. I've found that <code>ResourcelessTransactionManager</code> is the way to go but I cannot make it work. Problem is I already have 3 another dataSources defined, but I don't want to use any of them in springBatch... | 41,126 | 1,312,276 | 2018-11-08 06:51:25 | 42,721,313 | 27 | 2017-03-10 14:54:56 | 6,156,347 | 2017-09-06 07:45:49 | https://stackoverflow.com/q/39913918 | https://stackoverflow.com/a/42721313 | <p>I got around this problem by extending the DefaultBatchConfigurer class so that it ignores any DataSource, as a consequence it will configure a map-based JobRepository.</p>
<p>Example:</p>
<pre><code>@Configuration
@EnableBatchProcessing
public class BatchConfig extends DefaultBatchConfigurer {
@Override
... | <p>I got around this problem by extending the DefaultBatchConfigurer class so that it ignores any DataSource, as a consequence it will configure a map-based JobRepository.</p> <p>Example:</p> <pre><code>@Configuration @EnableBatchProcessing public class BatchConfig extends DefaultBatchConfigurer { @Override ... | 17, 1211, 41895, 95875 | java, spring, spring-batch, spring-boot | <h1>Spring boot + spring batch without DataSource</h1>
<p>I'm trying to configure spring batch inside spring boot project and I want to use it without data source. I've found that <code>ResourcelessTransactionManager</code> is the way to go but I cannot make it work. Problem is I already have 3 another dataSources defi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,675 | cmd | # Spring boot + spring batch without DataSource
I'm trying to configure spring batch inside spring boot project and I want to use it without data source. I've found that `ResourcelessTransactionManager` is the way to go but I cannot make it work. Problem is I already have 3 another dataSources defined, but I don't wan... | I got around this problem by extending the DefaultBatchConfigurer class so that it ignores any DataSource, as a consequence it will configure a map-based JobRepository.
Example:
```
@Configuration
@EnableBatchProcessing
public class BatchConfig extends DefaultBatchConfigurer {
@Override
public void setDat... |
30049351 | why I am getting The following usage of the path operator in batch-parameter substitution is invalid | 14 | 2015-05-05 09:39:23 | <p>I have a batch file which should get a directory and process all jpeg files in it using an application that i have.</p>
<p>The batch file is:</p>
<pre><code>for %%I in (%1\*.jpg) do (
bin\process.exe %%I "%~dpI\output\%~nxI"
)
</code></pre>
<p>but when I am running this batch file, I am getting this error:</p>
<... | 10,634 | 654,019 | 2015-05-05 09:42:46 | 30,049,430 | 27 | 2015-05-05 09:42:46 | 4,158,862 | 2015-05-05 09:42:46 | https://stackoverflow.com/q/30049351 | https://stackoverflow.com/a/30049430 | <p>Inside a batch file, you need <em>two</em> % symbols when you're using the for loop variables. Variables like %I would only be for the command line. You should be saying</p>
<pre><code>for %%I in (%1\*.jpg) do (
bin\process.exe %%I "%%~dpI\output\%%~nxI"
)
</code></pre>
| <p>Inside a batch file, you need <em>two</em> % symbols when you're using the for loop variables. Variables like %I would only be for the command line. You should be saying</p> <pre><code>for %%I in (%1\*.jpg) do ( bin\process.exe %%I "%%~dpI\output\%%~nxI" ) </code></pre> | 64, 7002 | batch-file, windows | <h1>why I am getting The following usage of the path operator in batch-parameter substitution is invalid</h1>
<p>I have a batch file which should get a directory and process all jpeg files in it using an application that i have.</p>
<p>The batch file is:</p>
<pre><code>for %%I in (%1\*.jpg) do (
bin\process.exe %%I "... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,676 | cmd | # why I am getting The following usage of the path operator in batch-parameter substitution is invalid
I have a batch file which should get a directory and process all jpeg files in it using an application that i have.
The batch file is:
```
for %%I in (%1\*.jpg) do (
bin\process.exe %%I "%~dpI\output\%~nxI"
)
```
... | Inside a batch file, you need *two* % symbols when you're using the for loop variables. Variables like %I would only be for the command line. You should be saying
```
for %%I in (%1\*.jpg) do (
bin\process.exe %%I "%%~dpI\output\%%~nxI"
)
``` |
7580834 | Script to change ip address on windows | 14 | 2011-09-28 09:07:46 | <p>I use my computer to communicate with a piece of hardware via ethernet. To communicate with this device I set my ip to 192 168 0 11, subnet mask to 255 255 255 0, and default gateway to 192 168 0 1 for IPv4. To use the internet, I choose "Obtain an IP address automatically" via control panel. </p>
<p>I'd like to ha... | 71,729 | 607,846 | 2021-05-26 10:31:06 | 7,581,831 | 27 | 2011-09-28 10:31:10 | 1,002 | 2011-09-28 10:46:48 | https://stackoverflow.com/q/7580834 | https://stackoverflow.com/a/7581831 | <p>You can use the Python <a href="http://timgolden.me.uk/python/wmi/index.html">WMI module</a> to do this (install the <a href="http://starship.python.net/crew/mhammond/win32/Downloads.html">PyWin32 extensions</a> and the WMI module before running these scripts). Here is how to configure things to talk to the hardware... | <p>You can use the Python <a href="http://timgolden.me.uk/python/wmi/index.html">WMI module</a> to do this (install the <a href="http://starship.python.net/crew/mhammond/win32/Downloads.html">PyWin32 extensions</a> and the WMI module before running these scripts). Here is how to configure things to talk to the hardware... | 16, 64, 7002, 7904, 34595 | batch-file, ipv4, python, windows, windows-7 | <h1>Script to change ip address on windows</h1>
<p>I use my computer to communicate with a piece of hardware via ethernet. To communicate with this device I set my ip to 192 168 0 11, subnet mask to 255 255 255 0, and default gateway to 192 168 0 1 for IPv4. To use the internet, I choose "Obtain an IP address automatic... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,677 | cmd | # Script to change ip address on windows
I use my computer to communicate with a piece of hardware via ethernet. To communicate with this device I set my ip to 192 168 0 11, subnet mask to 255 255 255 0, and default gateway to 192 168 0 1 for IPv4. To use the internet, I choose "Obtain an IP address automatically" via... | You can use the Python [WMI module](http://timgolden.me.uk/python/wmi/index.html) to do this (install the [PyWin32 extensions](http://starship.python.net/crew/mhammond/win32/Downloads.html) and the WMI module before running these scripts). Here is how to configure things to talk to the hardware device:
```
import wmi
... |
43500413 | Batch script command automatically stops batch script | 13 | 2017-04-19 15:45:59 | <p>I am experiencing a strange issue with the following batch script run via <code>cmd.exe</code> on Windows:</p>
<pre><code>@echo off
gradle wrapper
gradlew build
pause
</code></pre>
<p>This batch script only ever executes the first command, i.e. <code>gradle wrapper</code>. After that, the batch script automaticall... | 2,926 | 1,197,719 | 2017-04-19 16:37:51 | 43,501,422 | 27 | 2017-04-19 16:37:51 | 6,738,015 | 2017-04-19 16:37:51 | https://stackoverflow.com/q/43500413 | https://stackoverflow.com/a/43501422 | <p>I have a feeling you may need to precede with call:</p>
<pre><code>call gradle…
</code></pre>
| <p>I have a feeling you may need to precede with call:</p> <pre><code>call gradle… </code></pre> | 2631, 7002, 32307 | batch-file, cmd, gradle | <h1>Batch script command automatically stops batch script</h1>
<p>I am experiencing a strange issue with the following batch script run via <code>cmd.exe</code> on Windows:</p>
<pre><code>@echo off
gradle wrapper
gradlew build
pause
</code></pre>
<p>This batch script only ever executes the first command, i.e. <code>g... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,678 | cmd | # Batch script command automatically stops batch script
I am experiencing a strange issue with the following batch script run via `cmd.exe` on Windows:
```
@echo off
gradle wrapper
gradlew build
pause
```
This batch script only ever executes the first command, i.e. `gradle wrapper`. After that, the batch script auto... | I have a feeling you may need to precede with call:
```
call gradle…
``` |
34202512 | Check if file with pattern exist | 12 | 2015-12-10 12:57:00 | <p>I have a strange situation and I don't know what is wrong</p>
<p>I need to check if in a directory exist at least one file with a pattern.</p>
<pre><code>IF EXIST d:\*Backup*.* (
ECHO "file exist"
) ELSE (
ECHO "file not exist"
)
</code></pre>
<p>If on <code>d:\</code> I have a file <code>x... | 49,218 | 1,841,852 | 2022-11-16 08:47:02 | 34,206,104 | 27 | 2015-12-10 15:45:59 | 1,417,694 | 2017-07-10 13:55:29 | https://stackoverflow.com/q/34202512 | https://stackoverflow.com/a/34206104 | <p>There are undocumented wildcards that you can use to achieve this as well.</p>
<pre><code>IF EXIST "D:\*Backup*.<" (
ECHO "file exist"
) ELSE (
ECHO "file not exist"
)
</code></pre>
<p>This wildcard option and other were discussed in length at the following two links.
<a href="http://www.dostips.com/forum... | <p>There are undocumented wildcards that you can use to achieve this as well.</p> <pre><code>IF EXIST "D:\*Backup*.<" ( ECHO "file exist" ) ELSE ( ECHO "file not exist" ) </code></pre> <p>This wildcard option and other were discussed in length at the following two links. <a href="http://www.dostips.com/forum... | 64, 2631, 5997, 6268, 7002 | batch-file, cmd, path, wildcard, windows | <h1>Check if file with pattern exist</h1>
<p>I have a strange situation and I don't know what is wrong</p>
<p>I need to check if in a directory exist at least one file with a pattern.</p>
<pre><code>IF EXIST d:\*Backup*.* (
ECHO "file exist"
) ELSE (
ECHO "file not exist"
)
</code></pre>
<p>If... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,679 | cmd | # Check if file with pattern exist
I have a strange situation and I don't know what is wrong
I need to check if in a directory exist at least one file with a pattern.
```
IF EXIST d:\*Backup*.* (
ECHO "file exist"
) ELSE (
ECHO "file not exist"
)
```
If on `d:\` I have a file `x_Backup.txt` and a folder `Back... | There are undocumented wildcards that you can use to achieve this as well.
```
IF EXIST "D:\*Backup*.<" (
ECHO "file exist"
) ELSE (
ECHO "file not exist"
)
```
This wildcard option and other were discussed in length at the following two links.
<http://www.dostips.com/forum/viewtopic.php?t=6207>
<http://www.do... |
16823518 | Calling Batch File From C# | 10 | 2013-05-29 20:47:48 | <p>I am hoping that this is an easy question, but i have the following code in my C# application and for some reason it will not execute the batch file I am pointing to.</p>
<pre><code>private void filesystemwatcher_Renamed(object sender, System.IO.RenamedEventArgs e)
{
if (File.Exists("C:\\Watcher\\File.txt"))
... | 41,863 | 1,826,971 | 2017-05-29 12:07:33 | 16,823,732 | 27 | 2013-05-29 21:02:15 | 1,197,518 | 2013-05-29 21:02:15 | https://stackoverflow.com/q/16823518 | https://stackoverflow.com/a/16823732 | <p>This should work</p>
<pre><code>System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "C:\\Watcher\\Cleanup.bat";
proc.StartInfo.WorkingDirectory = "C:\\Watcher";
proc.Start();
</code></pre>
<p>You need to set the WorkingDirectory otherwise the command will be executed in wh... | <p>This should work</p> <pre><code>System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = "C:\\Watcher\\Cleanup.bat"; proc.StartInfo.WorkingDirectory = "C:\\Watcher"; proc.Start(); </code></pre> <p>You need to set the WorkingDirectory otherwise the command will be executed in wh... | 9, 2631 | c#, cmd | <h1>Calling Batch File From C#</h1>
<p>I am hoping that this is an easy question, but i have the following code in my C# application and for some reason it will not execute the batch file I am pointing to.</p>
<pre><code>private void filesystemwatcher_Renamed(object sender, System.IO.RenamedEventArgs e)
{
if (File... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,680 | cmd | # Calling Batch File From C#
I am hoping that this is an easy question, but i have the following code in my C# application and for some reason it will not execute the batch file I am pointing to.
```
private void filesystemwatcher_Renamed(object sender, System.IO.RenamedEventArgs e)
{
if (File.Exists("C:\\Watcher... | This should work
```
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "C:\\Watcher\\Cleanup.bat";
proc.StartInfo.WorkingDirectory = "C:\\Watcher";
proc.Start();
```
You need to set the WorkingDirectory otherwise the command will be executed in what is the current directory... |
13311924 | CMD: Set buffer height independently of window height | 10 | 2012-11-09 16:23:37 | <p>I've recently learned that I can control the size of the CMD window running my program with <code>mode x,y</code>. However I just as recently noticed that this sets the <em>buffer</em> size, and the window will adjust to match or max out at the screen size.</p>
<p>I would like to use <code>mode 100,50</code> for th... | 15,668 | 507,674 | 2020-01-28 00:56:14 | 13,351,373 | 27 | 2012-11-12 20:52:06 | 1,012,053 | 2012-11-12 21:49:26 | https://stackoverflow.com/q/13311924 | https://stackoverflow.com/a/13351373 | <p>I don't think there is a native batch command that gives independent control of buffer and window sizes. .NET can control both, but I don't think VBScript or JScript can access that functionality. But powershell can :-) See <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2006/12/04/how-can-i-expand-the-w... | <p>I don't think there is a native batch command that gives independent control of buffer and window sizes. .NET can control both, but I don't think VBScript or JScript can access that functionality. But powershell can :-) See <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2006/12/04/how-can-i-expand-the-w... | 2631 | cmd | <h1>CMD: Set buffer height independently of window height</h1>
<p>I've recently learned that I can control the size of the CMD window running my program with <code>mode x,y</code>. However I just as recently noticed that this sets the <em>buffer</em> size, and the window will adjust to match or max out at the screen si... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,681 | cmd | # CMD: Set buffer height independently of window height
I've recently learned that I can control the size of the CMD window running my program with `mode x,y`. However I just as recently noticed that this sets the *buffer* size, and the window will adjust to match or max out at the screen size.
I would like to use `m... | I don't think there is a native batch command that gives independent control of buffer and window sizes. .NET can control both, but I don't think VBScript or JScript can access that functionality. But powershell can :-) See [How Can I Expand the Width of the Windows PowerShell Console?](http://blogs.technet.com/b/heysc... |
7044985 | How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required? | 278 | 2011-08-12 18:55:13 | <p>I want my batch file to only run elevated. If not elevated, provide an option for the user to relaunch batch as elevated.</p>
<p>I'm writing a batch file to set a system variable, copy two files to a <em>Program Files</em> location, and start a driver installer. If a Windows user (<a href="http://en.wikipedia.org/wi... | 409,477 | 892,288 | 2025-12-31 10:51:29 | 7,045,097 | 26 | 2011-08-12 19:04:29 | 147,320 | 2011-08-12 19:04:29 | https://stackoverflow.com/q/7044985 | https://stackoverflow.com/a/7045097 | <p>You can have the script call itself with <a href="http://technet.microsoft.com/en-us/sysinternals/bb897553" rel="noreferrer">psexec</a>'s <code>-h</code> option to run elevated.</p>
<p>I'm not sure how you would detect if it's already running as elevated or not... maybe re-try with elevated perms only if there's an... | <p>You can have the script call itself with <a href="http://technet.microsoft.com/en-us/sysinternals/bb897553" rel="noreferrer">psexec</a>'s <code>-h</code> option to run elevated.</p> <p>I'm not sure how you would detect if it's already running as elevated or not... maybe re-try with elevated perms only if there's an... | 64, 1980, 7002, 60888, 151610 | batch-file, elevated-privileges, uac, windows, windows-11 | <h1>How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?</h1>
<p>I want my batch file to only run elevated. If not elevated, provide an option for the user to relaunch batch as elevated.</p>
<p>I'm writing a batch file to set a system variable, copy two files to a <em>Pro... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,682 | cmd | # How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?
I want my batch file to only run elevated. If not elevated, provide an option for the user to relaunch batch as elevated.
I'm writing a batch file to set a system variable, copy two files to a *Program Files* locati... | You can have the script call itself with [psexec](http://technet.microsoft.com/en-us/sysinternals/bb897553)'s `-h` option to run elevated.
I'm not sure how you would detect if it's already running as elevated or not... maybe re-try with elevated perms only if there's an Access Denied error?
Or, you could simply have ... |
562038 | Escaping Double Quotes in Batch Script | 122 | 2009-02-18 17:19:38 | <p>How would I go about replacing all of the double quotes in my batch file's parameters with escaped double quotes? This is my current batch file, which expands all of its command line parameters inside the string:</p>
<pre><code>@echo off
call bash --verbose -c "g++-linux-4.1 %*"
</code></pre>
<p>It then uses that ... | 240,416 | 1,370 | 2023-01-02 18:01:46 | 562,131 | 26 | 2009-02-18 17:48:17 | 1,370 | 2009-02-18 17:48:17 | https://stackoverflow.com/q/562038 | https://stackoverflow.com/a/562131 | <p>Google eventually came up with the answer. The syntax for string replacement in batch is this:</p>
<pre><code>set v_myvar=replace me
set v_myvar=%v_myvar:ace=icate%
</code></pre>
<p>Which produces "replicate me". My script now looks like this:</p>
<pre><code>@echo off
set v_params=%*
set v_params=%v_params:"=\"%
... | <p>Google eventually came up with the answer. The syntax for string replacement in batch is this:</p> <pre><code>set v_myvar=replace me set v_myvar=%v_myvar:ace=icate% </code></pre> <p>Which produces "replicate me". My script now looks like this:</p> <pre><code>@echo off set v_params=%* set v_params=%v_params:"=\"% ... | 360, 430, 531, 4804, 7002 | batch-file, escaping, parameters, quotes, scripting | <h1>Escaping Double Quotes in Batch Script</h1>
<p>How would I go about replacing all of the double quotes in my batch file's parameters with escaped double quotes? This is my current batch file, which expands all of its command line parameters inside the string:</p>
<pre><code>@echo off
call bash --verbose -c "g++-li... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,683 | cmd | # Escaping Double Quotes in Batch Script
How would I go about replacing all of the double quotes in my batch file's parameters with escaped double quotes? This is my current batch file, which expands all of its command line parameters inside the string:
```
@echo off
call bash --verbose -c "g++-linux-4.1 %*"
```
It ... | Google eventually came up with the answer. The syntax for string replacement in batch is this:
```
set v_myvar=replace me
set v_myvar=%v_myvar:ace=icate%
```
Which produces "replicate me". My script now looks like this:
```
@echo off
set v_params=%*
set v_params=%v_params:"=\"%
call bash -c "g++-linux-4.1 %v_params%... |
41030190 | Why does "cd" on Windows Command Line not change drives? | 56 | 2016-12-08 01:17:31 | <p>I'm trying to make my Visual Studio build script execute a .bat file that does something important.</p>
<p>Here is what I'm want to do right now:</p>
<pre><code>cd "F:\- Big Packets -\kitterengine\Common\" Template.bat
</code></pre>
<p>But it doesn't work.</p>
<p>I have to do this to make it work:</p>
<pre><cod... | 630,397 | 6,850,480 | 2025-10-07 18:54:55 | 44,879,643 | 26 | 2017-07-03 07:08:07 | 2,339,546 | 2017-07-03 07:52:45 | https://stackoverflow.com/q/41030190 | https://stackoverflow.com/a/44879643 | <p>Can refer to here: <a href="https://ss64.com/nt/start.html" rel="noreferrer">https://ss64.com/nt/start.html</a></p>
<pre><code>start "" /D F:\- Big Packets -\kitterengine\Common\ /W Template.bat
</code></pre>
| <p>Can refer to here: <a href="https://ss64.com/nt/start.html" rel="noreferrer">https://ss64.com/nt/start.html</a></p> <pre><code>start "" /D F:\- Big Packets -\kitterengine\Common\ /W Template.bat </code></pre> | 64, 1796, 2631, 5003 | cmd, command, prompt, windows | <h1>Why does "cd" on Windows Command Line not change drives?</h1>
<p>I'm trying to make my Visual Studio build script execute a .bat file that does something important.</p>
<p>Here is what I'm want to do right now:</p>
<pre><code>cd "F:\- Big Packets -\kitterengine\Common\" Template.bat
</code></pre>
<p>But it doesn... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,684 | cmd | # Why does "cd" on Windows Command Line not change drives?
I'm trying to make my Visual Studio build script execute a .bat file that does something important.
Here is what I'm want to do right now:
```
cd "F:\- Big Packets -\kitterengine\Common\" Template.bat
```
But it doesn't work.
I have to do this to make it w... | Can refer to here: <https://ss64.com/nt/start.html>
```
start "" /D F:\- Big Packets -\kitterengine\Common\ /W Template.bat
``` |
35544871 | Batchfile: What's the best way to declare and use a boolean variable? | 50 | 2016-02-22 02:29:28 | <p>What's the best way to declare and use a boolean variable in Batch files? This is what I'm doing now:</p>
<pre><code>set "condition=true"
:: Some code that may change the condition
if %condition% == true (
:: Some work
)
</code></pre>
<p>Is there a better, more "formal" way to do this? (e.g. In Bash you can ... | 67,092 | 4,077,294 | 2024-09-30 09:29:18 | 35,685,098 | 26 | 2016-02-28 16:27:37 | 4,077,294 | 2016-02-28 16:27:37 | https://stackoverflow.com/q/35544871 | https://stackoverflow.com/a/35685098 | <p>I'm sticking with my original answer for the time being:</p>
<pre><code>set "condition=true"
:: Some code...
if "%condition%" == "true" (
%= Do something... =%
)
</code></pre>
<p>If anyone knows of a better way to do this, please answer this question and I'll gladly accept your answer.</p>
| <p>I'm sticking with my original answer for the time being:</p> <pre><code>set "condition=true" :: Some code... if "%condition%" == "true" ( %= Do something... =% ) </code></pre> <p>If anyone knows of a better way to do this, please answer this question and I'll gladly accept your answer.</p> | 64, 2631, 7002, 9938, 107329 | batch-file, cmd, command-prompt, windows, windows-10 | <h1>Batchfile: What's the best way to declare and use a boolean variable?</h1>
<p>What's the best way to declare and use a boolean variable in Batch files? This is what I'm doing now:</p>
<pre><code>set "condition=true"
:: Some code that may change the condition
if %condition% == true (
:: Some work
)
</code></p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,685 | cmd | # Batchfile: What's the best way to declare and use a boolean variable?
What's the best way to declare and use a boolean variable in Batch files? This is what I'm doing now:
```
set "condition=true"
:: Some code that may change the condition
if %condition% == true (
:: Some work
)
```
Is there a better, more "... | I'm sticking with my original answer for the time being:
```
set "condition=true"
:: Some code...
if "%condition%" == "true" (
%= Do something... =%
)
```
If anyone knows of a better way to do this, please answer this question and I'll gladly accept your answer. |
20786478 | How to run different python versions in cmd | 38 | 2013-12-26 14:27:36 | <p>How can I configure windows command dialog to run different python versions in it? For example when I type <code>python2</code> it runs python 2.7 and when I type <code>python3</code> it runs python 3.3? I know how to configure environment variables for one version but two? I mean something like Linux terminal.</p>
| 245,357 | 2,837,388 | 2017-07-02 13:24:33 | 20,787,065 | 26 | 2013-12-26 15:18:14 | 1,346,705 | 2013-12-27 08:11:46 | https://stackoverflow.com/q/20786478 | https://stackoverflow.com/a/20787065 | <p>Python 3.3 introduces Python Launcher for Windows that is installed into <code>c:\Windows\</code> as <code>py.exe</code> and <code>pyw.exe</code> by the installer. The installer also creates associations with <code>.py</code> and <code>.pyw</code>. Then add <code>#!python3</code> or <code>#!python2</code> as the fir... | <p>Python 3.3 introduces Python Launcher for Windows that is installed into <code>c:\Windows\</code> as <code>py.exe</code> and <code>pyw.exe</code> by the installer. The installer also creates associations with <code>.py</code> and <code>.pyw</code>. Then add <code>#!python3</code> or <code>#!python2</code> as the fir... | 16, 64, 2631, 59047, 60010 | cmd, python, python-2.7, python-3.x, windows | <h1>How to run different python versions in cmd</h1>
<p>How can I configure windows command dialog to run different python versions in it? For example when I type <code>python2</code> it runs python 2.7 and when I type <code>python3</code> it runs python 3.3? I know how to configure environment variables for one versio... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,686 | cmd | # How to run different python versions in cmd
How can I configure windows command dialog to run different python versions in it? For example when I type `python2` it runs python 2.7 and when I type `python3` it runs python 3.3? I know how to configure environment variables for one version but two? I mean something lik... | Python 3.3 introduces Python Launcher for Windows that is installed into `c:\Windows\` as `py.exe` and `pyw.exe` by the installer. The installer also creates associations with `.py` and `.pyw`. Then add `#!python3` or `#!python2` as the first lline. No need to add anything to the `PATH` environment variable.
**Update:... |
6060046 | Windows batch files: multiple if conditions | 35 | 2011-05-19 14:13:53 | <p>Is there a way to say something like</p>
<pre>
if %1 == 1 or %1 == 2
</pre>
<p>in a batch file? Or, even better, if I could specify a set of candidate values like</p>
<pre>
if %1 in [1, 2, 3, 4, ... 20]
</pre>
| 116,537 | 536,607 | 2017-04-11 07:00:00 | 6,060,329 | 26 | 2011-05-19 14:34:42 | 8,090 | 2011-05-19 14:34:42 | https://stackoverflow.com/q/6060046 | https://stackoverflow.com/a/6060329 | <p>One way to implement logical-or is to use multiple conditionals that <code>goto</code> the same label.</p>
<pre><code>if %1 == 1 goto :cond
if %1 == 2 goto :cond
goto :skip
:cond
someCommand
:skip
</code></pre>
<p>To test for set membership, you could use a for-loop:</p>
<pre><code>for %%i in (1 2 3 4 ... 20) do ... | <p>One way to implement logical-or is to use multiple conditionals that <code>goto</code> the same label.</p> <pre><code>if %1 == 1 goto :cond if %1 == 2 goto :cond goto :skip :cond someCommand :skip </code></pre> <p>To test for set membership, you could use a for-loop:</p> <pre><code>for %%i in (1 2 3 4 ... 20) do ... | 2216, 7002 | batch-file, windows-xp | <h1>Windows batch files: multiple if conditions</h1>
<p>Is there a way to say something like</p>
<pre>
if %1 == 1 or %1 == 2
</pre>
<p>in a batch file? Or, even better, if I could specify a set of candidate values like</p>
<pre>
if %1 in [1, 2, 3, 4, ... 20]
</pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,687 | cmd | # Windows batch files: multiple if conditions
Is there a way to say something like
```
if %1 == 1 or %1 == 2
```
in a batch file? Or, even better, if I could specify a set of candidate values like
```
if %1 in [1, 2, 3, 4, ... 20]
``` | One way to implement logical-or is to use multiple conditionals that `goto` the same label.
```
if %1 == 1 goto :cond
if %1 == 2 goto :cond
goto :skip
:cond
someCommand
:skip
```
To test for set membership, you could use a for-loop:
```
for %%i in (1 2 3 4 ... 20) do if %1 == %%i someCommand
```
Note that `==` is t... |
17042476 | CMD: Export all the screen content to a text file | 33 | 2013-06-11 10:59:32 | <p>In command prompt - How do I export all the content of the screen to a text file(basically a copy command, just not by using right-clicking and the clipboard)</p>
<p>This command works, but only for the commands you executed, not the actual output <strong>as well</strong></p>
<pre><code>doskey /HISTORY > histor... | 230,525 | 1,140,828 | 2019-11-19 22:46:06 | 26,241,348 | 26 | 2014-10-07 17:02:48 | 3,543,437 | 2019-11-19 22:46:06 | https://stackoverflow.com/q/17042476 | https://stackoverflow.com/a/26241348 | <p>If you want to append a file instead of constantly making a new one/deleting the old one's content, use double <code>></code> marks. A single <code>></code> mark will overwrite all the file's content.</p>
<p><strong>Overwrite</strong> file</p>
<pre><code>MyCommand.exe>file.txt
</code></pre>
<p>^This will... | <p>If you want to append a file instead of constantly making a new one/deleting the old one's content, use double <code>></code> marks. A single <code>></code> mark will overwrite all the file's content.</p> <p><strong>Overwrite</strong> file</p> <pre><code>MyCommand.exe>file.txt </code></pre> <p>^This will... | 1231, 2631 | cmd, command-line | <h1>CMD: Export all the screen content to a text file</h1>
<p>In command prompt - How do I export all the content of the screen to a text file(basically a copy command, just not by using right-clicking and the clipboard)</p>
<p>This command works, but only for the commands you executed, not the actual output <strong>a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,688 | cmd | # CMD: Export all the screen content to a text file
In command prompt - How do I export all the content of the screen to a text file(basically a copy command, just not by using right-clicking and the clipboard)
This command works, but only for the commands you executed, not the actual output **as well**
```
doskey /... | If you want to append a file instead of constantly making a new one/deleting the old one's content, use double `>` marks. A single `>` mark will overwrite all the file's content.
**Overwrite** file
```
MyCommand.exe>file.txt
```
^This will open file.txt if it already exists and overwrite the data, or create a new fi... |
16692580 | How do I run a .lua script? | 30 | 2013-05-22 13:05:35 | <p>I need to execute a .lua script using windows command line (cmd).
I've got my .lua file in the same folder in which my lua.exe is.</p>
<p>I've tried several ways of running the file but I can't figure out how to do it. =(</p>
<p>(I also have the same script with the extension .out)</p>
| 106,169 | 2,296,422 | 2013-05-22 13:32:16 | 16,693,021 | 26 | 2013-05-22 13:25:13 | 2,303,714 | 2013-05-22 13:32:16 | https://stackoverflow.com/q/16692580 | https://stackoverflow.com/a/16693021 | <p><code>C:\path\to\lua.exe file_name.lua</code>
OR
<code>lua file_name.lua</code> if you've set up envrioment variables. If the prior doesn't work, simply drag and drop the <code>file_name.lua</code> onto the <code>lua.exe</code>.</p>
| <p><code>C:\path\to\lua.exe file_name.lua</code> OR <code>lua file_name.lua</code> if you've set up envrioment variables. If the prior doesn't work, simply drag and drop the <code>file_name.lua</code> onto the <code>lua.exe</code>.</p> | 1018, 2631 | cmd, lua | <h1>How do I run a .lua script?</h1>
<p>I need to execute a .lua script using windows command line (cmd).
I've got my .lua file in the same folder in which my lua.exe is.</p>
<p>I've tried several ways of running the file but I can't figure out how to do it. =(</p>
<p>(I also have the same script with the extension .... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,689 | cmd | # How do I run a .lua script?
I need to execute a .lua script using windows command line (cmd).
I've got my .lua file in the same folder in which my lua.exe is.
I've tried several ways of running the file but I can't figure out how to do it. =(
(I also have the same script with the extension .out) | `C:\path\to\lua.exe file_name.lua`
OR
`lua file_name.lua` if you've set up envrioment variables. If the prior doesn't work, simply drag and drop the `file_name.lua` onto the `lua.exe`. |
10415807 | Output Console.WriteLine from WPF Windows Applications to actual console | 29 | 2012-05-02 14:28:50 | <p>Background: I am struggling to add command line and batch processing capabilities to an existing WPF <em>Windows Application</em>. When I detect some options at startup I suppress the window from appearing, do some processing and quit immedietally. Now, because there's no UI I'd like to output some messages to stdou... | 30,120 | 461,632 | 2023-08-04 14:15:29 | 11,591,223 | 26 | 2012-07-21 10:01:47 | 461,632 | 2012-07-21 10:01:47 | https://stackoverflow.com/q/10415807 | https://stackoverflow.com/a/11591223 | <p>After digging up a bit, I found <a href="https://stackoverflow.com/a/3058921/461632">this answer</a>. The code is now:</p>
<pre><code>namespace WpfConsoleTest
{
public partial class App : Application
{
[DllImport("Kernel32.dll")]
public static extern bool AttachConsole(int processId);
... | <p>After digging up a bit, I found <a href="https://stackoverflow.com/a/3058921/461632">this answer</a>. The code is now:</p> <pre><code>namespace WpfConsoleTest { public partial class App : Application { [DllImport("Kernel32.dll")] public static extern bool AttachConsole(int processId); ... | 9, 378, 2631, 7002 | batch-file, c#, cmd, wpf | <h1>Output Console.WriteLine from WPF Windows Applications to actual console</h1>
<p>Background: I am struggling to add command line and batch processing capabilities to an existing WPF <em>Windows Application</em>. When I detect some options at startup I suppress the window from appearing, do some processing and quit ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,690 | cmd | # Output Console.WriteLine from WPF Windows Applications to actual console
Background: I am struggling to add command line and batch processing capabilities to an existing WPF *Windows Application*. When I detect some options at startup I suppress the window from appearing, do some processing and quit immedietally. No... | After digging up a bit, I found [this answer](https://stackoverflow.com/a/3058921/461632). The code is now:
```
namespace WpfConsoleTest
{
public partial class App : Application
{
[DllImport("Kernel32.dll")]
public static extern bool AttachConsole(int processId);
protected override voi... |
14107975 | Escape ampersands in variables - win batch | 28 | 2013-01-01 05:10:43 | <p>I have a variable that contains ampersands and I need to create another variable that contains the first one. I know the "&" character <a href="https://stackoverflow.com/questions/1327431/how-do-i-escape-ampersands-in-batch-files">can be escaped with carret (^)</a> but I have no idea how to escape the text insid... | 22,691 | 1,596,418 | 2017-05-19 18:36:34 | 14,108,765 | 26 | 2013-01-01 07:38:24 | 1,012,053 | 2013-01-01 07:38:24 | https://stackoverflow.com/q/14107975 | https://stackoverflow.com/a/14108765 | <p>The simplest solution is to use quotes for the assignment, and delayed expansion. This eliminates any need for escaping.</p>
<pre><code>@echo off
setlocal enableDelayedExpansion
set "Name1=Red & Green"
set "Name2=!Name1! & Blue"
echo !Name2!
</code></pre>
<p>If you have a mixture of quoted and unquoted tex... | <p>The simplest solution is to use quotes for the assignment, and delayed expansion. This eliminates any need for escaping.</p> <pre><code>@echo off setlocal enableDelayedExpansion set "Name1=Red & Green" set "Name2=!Name1! & Blue" echo !Name2! </code></pre> <p>If you have a mixture of quoted and unquoted tex... | 64, 4804, 7002 | batch-file, escaping, windows | <h1>Escape ampersands in variables - win batch</h1>
<p>I have a variable that contains ampersands and I need to create another variable that contains the first one. I know the "&" character <a href="https://stackoverflow.com/questions/1327431/how-do-i-escape-ampersands-in-batch-files">can be escaped with carret (^)... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,691 | cmd | # Escape ampersands in variables - win batch
I have a variable that contains ampersands and I need to create another variable that contains the first one. I know the "&" character [can be escaped with carret (^)](https://stackoverflow.com/questions/1327431/how-do-i-escape-ampersands-in-batch-files) but I have no idea ... | The simplest solution is to use quotes for the assignment, and delayed expansion. This eliminates any need for escaping.
```
@echo off
setlocal enableDelayedExpansion
set "Name1=Red & Green"
set "Name2=!Name1! & Blue"
echo !Name2!
```
If you have a mixture of quoted and unquoted text, you sometimes must escape some c... |
11893309 | Escape "double quotes" inside batch's input parameters | 25 | 2012-08-09 23:11:11 | <p>I want to run the following in batch script where it takes an argument (a path)</p>
<pre><code>runas /user:abc "icacls %1 /grant Everyone:(F) /T"
</code></pre>
<p>but the argument <code>%1</code> already contains a <code>"</code> (because it's a path, passed on by context menu's Send To - I don't have much contro... | 61,640 | 1,266,650 | 2021-08-21 19:43:21 | 11,893,337 | 26 | 2012-08-09 23:15:10 | 1,224,272 | 2012-08-10 00:02:13 | https://stackoverflow.com/q/11893309 | https://stackoverflow.com/a/11893337 | <p>You should be able to use <code>\"</code> <a href="http://www.robvanderwoude.com/escapechars.php">Here</a> is a site with a few other escape characters that you might find useful</p>
<p>To perform the string replace:</p>
<pre><code>set temp=%1
set temp=%temp:"=\"%
echo %temp%
</code></pre>
| <p>You should be able to use <code>\"</code> <a href="http://www.robvanderwoude.com/escapechars.php">Here</a> is a site with a few other escape characters that you might find useful</p> <p>To perform the string replace:</p> <pre><code>set temp=%1 set temp=%temp:"=\"% echo %temp% </code></pre> | 64, 7002 | batch-file, windows | <h1>Escape "double quotes" inside batch's input parameters</h1>
<p>I want to run the following in batch script where it takes an argument (a path)</p>
<pre><code>runas /user:abc "icacls %1 /grant Everyone:(F) /T"
</code></pre>
<p>but the argument <code>%1</code> already contains a <code>"</code> (because it's a path... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,692 | cmd | # Escape "double quotes" inside batch's input parameters
I want to run the following in batch script where it takes an argument (a path)
```
runas /user:abc "icacls %1 /grant Everyone:(F) /T"
```
but the argument `%1` already contains a `"` (because it's a path, passed on by context menu's Send To - I don't have muc... | You should be able to use `\"` [Here](http://www.robvanderwoude.com/escapechars.php) is a site with a few other escape characters that you might find useful
To perform the string replace:
```
set temp=%1
set temp=%temp:"=\"%
echo %temp%
``` |
17845809 | 'C:\Program' is not recognized error | 24 | 2013-07-24 22:20:32 | <p>I've recently tried changing my environment variables to set paths to javac.exe (among other things). It was working fine until, all of a sudden, I started getting this error. For example, I declared a JAVA_HOME variable to be </p>
<p><code>C:\Program Files\Java\jdk1.7.0_25</code></p>
<p>After which, I add </p>
<... | 113,009 | 864,574 | 2021-05-26 16:58:06 | 17,866,410 | 26 | 2013-07-25 18:51:31 | 1,248,365 | 2017-03-31 18:25:15 | https://stackoverflow.com/q/17845809 | https://stackoverflow.com/a/17866410 | <p>Okay, that makes it clearer.</p>
<p>There are two main problems here.</p>
<p>First of all, the reason you're getting <code>'C:\Program' is not recognized...</code> is, of course, because it contains spaces. The fact that you have it quoted in the PATH environment variable has no relation to how <strong>%JAVA_HOME%... | <p>Okay, that makes it clearer.</p> <p>There are two main problems here.</p> <p>First of all, the reason you're getting <code>'C:\Program' is not recognized...</code> is, of course, because it contains spaces. The fact that you have it quoted in the PATH environment variable has no relation to how <strong>%JAVA_HOME%... | 64, 2631, 9013 | cmd, environment-variables, windows | <h1>'C:\Program' is not recognized error</h1>
<p>I've recently tried changing my environment variables to set paths to javac.exe (among other things). It was working fine until, all of a sudden, I started getting this error. For example, I declared a JAVA_HOME variable to be </p>
<p><code>C:\Program Files\Java\jdk1.7.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,693 | cmd | # 'C:\Program' is not recognized error
I've recently tried changing my environment variables to set paths to javac.exe (among other things). It was working fine until, all of a sudden, I started getting this error. For example, I declared a JAVA_HOME variable to be
`C:\Program Files\Java\jdk1.7.0_25`
After which, I ... | Okay, that makes it clearer.
There are two main problems here.
First of all, the reason you're getting `'C:\Program' is not recognized...` is, of course, because it contains spaces. The fact that you have it quoted in the PATH environment variable has no relation to how **%JAVA_HOME%** is interpreted at the prompt. Y... |
12825790 | Is it possible to source a batch file in windows cmd like you can in unix? | 24 | 2012-10-10 18:18:17 | <p>I'm a unix guy but I have to write a system in windows, and I'm trying to write a script to move some files around. I'm trying to have the parent batch file CALL a child batch file which contains:</p>
<pre><code>set REPORTFILE=c:\report.txt
</code></pre>
<p>and then I want the parent to be able to use the %REPORTF... | 21,542 | 12,386 | 2021-04-17 07:54:15 | 12,826,137 | 26 | 2012-10-10 18:39:27 | 1,704,964 | 2021-04-17 07:54:15 | https://stackoverflow.com/q/12825790 | https://stackoverflow.com/a/12826137 | <p>if I understand...this seems to work for me in Vista:</p>
<p>caller.bat</p>
<pre><code>echo this is the caller
echo initial value is: %reportfile%
call setter.bat
echo value is: %reportfile%
</code></pre>
<p>setter.bat</p>
<pre><code>echo this is the value setter
set reportfile=c:\report.txt
</code></pre>
<p>C:\temp... | <p>if I understand...this seems to work for me in Vista:</p> <p>caller.bat</p> <pre><code>echo this is the caller echo initial value is: %reportfile% call setter.bat echo value is: %reportfile% </code></pre> <p>setter.bat</p> <pre><code>echo this is the value setter set reportfile=c:\report.txt </code></pre> <p>C:\temp... | 64, 7002, 8632 | batch-file, call, windows | <h1>Is it possible to source a batch file in windows cmd like you can in unix?</h1>
<p>I'm a unix guy but I have to write a system in windows, and I'm trying to write a script to move some files around. I'm trying to have the parent batch file CALL a child batch file which contains:</p>
<pre><code>set REPORTFILE=c:\re... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,694 | cmd | # Is it possible to source a batch file in windows cmd like you can in unix?
I'm a unix guy but I have to write a system in windows, and I'm trying to write a script to move some files around. I'm trying to have the parent batch file CALL a child batch file which contains:
```
set REPORTFILE=c:\report.txt
```
and th... | if I understand...this seems to work for me in Vista:
caller.bat
```
echo this is the caller
echo initial value is: %reportfile%
call setter.bat
echo value is: %reportfile%
```
setter.bat
```
echo this is the value setter
set reportfile=c:\report.txt
```
C:\temp>caller
> C:\temp>echo this is the caller
> `this ... |
5883500 | Call batch file from another passing parameters | 24 | 2011-05-04 12:39:09 | <p>I have the following batch file that when run asks the user for input. This works fine.</p>
<pre><code>@REM Sample batch file
SET PARAM1=""
SET PARAM2=""
SET /P PARAM1=Enter param1: %=%
SET /P PARAM2=Enter param2: %=%
@REM Process the params
</code></pre>
<p>I want to be able now to call this bat... | 119,356 | 373,674 | 2024-08-15 18:47:53 | 5,889,146 | 26 | 2011-05-04 19:56:43 | 653,295 | 2020-09-17 20:21:06 | https://stackoverflow.com/q/5883500 | https://stackoverflow.com/a/5889146 | <p>I believe you want something like this?</p>
<pre><code>@echo off
:: Fetch param1
set "param1=%~1"
goto :param1Check
:param1Prompt
set /p "param1=Enter parameter 1: "
:param1Check
if "%param1%"=="" goto :param1Prompt
:: Fetch param2
set "param2=%~2"
goto :param2... | <p>I believe you want something like this?</p> <pre><code>@echo off :: Fetch param1 set "param1=%~1" goto :param1Check :param1Prompt set /p "param1=Enter parameter 1: " :param1Check if "%param1%"=="" goto :param1Prompt :: Fetch param2 set "param2=%~2" goto :param2... | 2631, 7002 | batch-file, cmd | <h1>Call batch file from another passing parameters</h1>
<p>I have the following batch file that when run asks the user for input. This works fine.</p>
<pre><code>@REM Sample batch file
SET PARAM1=""
SET PARAM2=""
SET /P PARAM1=Enter param1: %=%
SET /P PARAM2=Enter param2: %=%
@REM Process the param... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,695 | cmd | # Call batch file from another passing parameters
I have the following batch file that when run asks the user for input. This works fine.
```
@REM Sample batch file
SET PARAM1=""
SET PARAM2=""
SET /P PARAM1=Enter param1: %=%
SET /P PARAM2=Enter param2: %=%
@REM Process the params
```
I want to be able now to call th... | I believe you want something like this?
```
@echo off
:: Fetch param1
set "param1=%~1"
goto :param1Check
:param1Prompt
set /p "param1=Enter parameter 1: "
:param1Check
if "%param1%"=="" goto :param1Prompt
:: Fetch param2
set "param2=%~2"
goto :param2Check
:param2Prompt
set /p "param2=Enter parameter 2: "
:param2... |
24907104 | Invalid drive specification using XCOPY | 23 | 2014-07-23 09:43:48 | <p>I want to run batch file which copy all relevant folders and sub-folders from a remote computer to my client computer.
I am using the following XCOPY command:</p>
<pre><code>xcopy "\\Server_Name\C$\folder_X\folder_Y" "C:\Users\\folder_Z" /I /S /Y /D:%mydate%
</code></pre>
<p>and got "invalid drive specification"... | 106,917 | 3,306,333 | 2024-03-11 07:41:13 | 24,907,648 | 26 | 2014-07-23 10:10:41 | 445,221 | 2014-07-23 10:10:41 | https://stackoverflow.com/q/24907104 | https://stackoverflow.com/a/24907648 | <p>Try mounting your remote drive locally first:</p>
<pre><code>net use x: \\Server_Name\C$
</code></pre>
<p>Then try copying the files from <code>X:</code> instead:</p>
<pre><code>xcopy x:\folder_X\folder_Y c:\Users\folder_Z ...
</code></pre>
<p>To unmount:</p>
<pre><code>net use x: /delete
</code></pre>
| <p>Try mounting your remote drive locally first:</p> <pre><code>net use x: \\Server_Name\C$ </code></pre> <p>Then try copying the files from <code>X:</code> instead:</p> <pre><code>xcopy x:\folder_X\folder_Y c:\Users\folder_Z ... </code></pre> <p>To unmount:</p> <pre><code>net use x: /delete </code></pre> | 7002 | batch-file | <h1>Invalid drive specification using XCOPY</h1>
<p>I want to run batch file which copy all relevant folders and sub-folders from a remote computer to my client computer.
I am using the following XCOPY command:</p>
<pre><code>xcopy "\\Server_Name\C$\folder_X\folder_Y" "C:\Users\\folder_Z" /I /S /Y /D:%mydate%
</code... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,696 | cmd | # Invalid drive specification using XCOPY
I want to run batch file which copy all relevant folders and sub-folders from a remote computer to my client computer.
I am using the following XCOPY command:
```
xcopy "\\Server_Name\C$\folder_X\folder_Y" "C:\Users\\folder_Z" /I /S /Y /D:%mydate%
```
and got "invalid drive ... | Try mounting your remote drive locally first:
```
net use x: \\Server_Name\C$
```
Then try copying the files from `X:` instead:
```
xcopy x:\folder_X\folder_Y c:\Users\folder_Z ...
```
To unmount:
```
net use x: /delete
``` |
382587 | how to get batch file parameters from Nth position on? | 23 | 2008-12-19 23:39:55 | <p>Further to <a href="https://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-in-batch-file">How to Pass Command Line Parameters in batch file</a> how does one get the rest of the parameters with specifying them exactly? I don't want to use SHIFT because I don't know how many parameters there mig... | 37,497 | 14,420 | 2021-05-19 20:08:25 | 382,785 | 26 | 2008-12-20 02:23:24 | 7,903 | 2008-12-20 02:23:24 | https://stackoverflow.com/q/382587 | https://stackoverflow.com/a/382785 | <p>Here's how you can do it without using <code>SHIFT</code>:</p>
<pre><code>@echo off
for /f "tokens=1-3*" %%a in ("%*") do (
set par1=%%a
set par2=%%b
set par3=%%c
set therest=%%d
)
echo the script is %0
echo Parameter 1 is %par1%
echo Parameter 2 is %par2%
echo Parameter 3 is %par3%
echo and the r... | <p>Here's how you can do it without using <code>SHIFT</code>:</p> <pre><code>@echo off for /f "tokens=1-3*" %%a in ("%*") do ( set par1=%%a set par2=%%b set par3=%%c set therest=%%d ) echo the script is %0 echo Parameter 1 is %par1% echo Parameter 2 is %par2% echo Parameter 3 is %par3% echo and the r... | 64, 7002 | batch-file, windows | <h1>how to get batch file parameters from Nth position on?</h1>
<p>Further to <a href="https://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-in-batch-file">How to Pass Command Line Parameters in batch file</a> how does one get the rest of the parameters with specifying them exactly? I don't want... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,697 | cmd | # how to get batch file parameters from Nth position on?
Further to [How to Pass Command Line Parameters in batch file](https://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-in-batch-file) how does one get the rest of the parameters with specifying them exactly? I don't want to use SHIFT becaus... | Here's how you can do it without using `SHIFT`:
```
@echo off
for /f "tokens=1-3*" %%a in ("%*") do (
set par1=%%a
set par2=%%b
set par3=%%c
set therest=%%d
)
echo the script is %0
echo Parameter 1 is %par1%
echo Parameter 2 is %par2%
echo Parameter 3 is %par3%
echo and the rest are %therest%
``` |
52581576 | Could not import "D": FLASK_APP | 21 | 2018-09-30 19:52:22 | <pre><code>from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
</code></pre>
<p>I am new to Flask. I wrote this basic code and save it in hello.py in my D:\Cat_vs_Dog\scripts folder.</p>
<p>Then in command prompt, I wrote the following commands.</p>
<pre><code... | 69,530 | 7,674,807 | 2022-12-14 10:56:33 | 52,581,926 | 26 | 2018-09-30 20:35:18 | 8,874,154 | 2022-11-09 00:20:56 | https://stackoverflow.com/q/52581576 | https://stackoverflow.com/a/52581926 | <h2>Flask v1.1.x</h2>
<p><a href="https://flask.palletsprojects.com/en/1.1.x/cli/#application-discovery" rel="nofollow noreferrer">https://flask.palletsprojects.com/en/1.1.x/cli/#application-discovery</a></p>
<p>The above documentation link describes:</p>
<blockquote>
<p>The flask command is installed by Flask, not you... | <h2>Flask v1.1.x</h2> <p><a href="https://flask.palletsprojects.com/en/1.1.x/cli/#application-discovery" rel="nofollow noreferrer">https://flask.palletsprojects.com/en/1.1.x/cli/#application-discovery</a></p> <p>The above documentation link describes:</p> <blockquote> <p>The flask command is installed by Flask, not you... | 16, 865, 2631, 54712 | cmd, flask, python, user-interface | <h1>Could not import "D": FLASK_APP</h1>
<pre><code>from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
</code></pre>
<p>I am new to Flask. I wrote this basic code and save it in hello.py in my D:\Cat_vs_Dog\scripts folder.</p>
<p>Then in command prompt, I wrot... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,698 | cmd | # Could not import "D": FLASK_APP
```
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
```
I am new to Flask. I wrote this basic code and save it in hello.py in my D:\Cat_vs_Dog\scripts folder.
Then in command prompt, I wrote the following commands.
```
C:... | ## Flask v1.1.x
<https://flask.palletsprojects.com/en/1.1.x/cli/#application-discovery>
The above documentation link describes:
> The flask command is installed by Flask, not your application; it must be told where to find your application in order to use it. The FLASK_APP environment variable is used to specify how... |
12712905 | How to check if the user input ends with a specific string in batch (.bat) script | 21 | 2012-10-03 16:35:35 | <p>I am writing a batch script where if user input is empty or doesnot ends with "DTO" I need to ask user to enter DTO name again.</p>
<pre><code>:INPUT
SET /P INPUTDTO=Enter the DTO:
IF "%INPUTDTO%"=="" (
IF "%INPUTDTO%" ??????? (
GOTO NODTO
)
)
:NODTO
ECHO ERROR: Please enter a valid DTO.
... | 23,191 | 1,457,209 | 2012-10-03 17:22:38 | 12,713,419 | 26 | 2012-10-03 17:09:40 | 1,012,053 | 2012-10-03 17:09:40 | https://stackoverflow.com/q/12712905 | https://stackoverflow.com/a/12713419 | <p>The existing INPUTDTO value should probably be cleared because SET /P will preserve the existing value if the user does not enter anything.</p>
<pre><code>@echo off
set "INPUTDTO="
:INPUT
SET /P INPUTDTO=Enter the DTO:
if "%INPUTDTO:~-3%" neq "DTO" (
ECHO ERROR: Please enter a valid DTO.
goto INPUT
)
</code></p... | <p>The existing INPUTDTO value should probably be cleared because SET /P will preserve the existing value if the user does not enter anything.</p> <pre><code>@echo off set "INPUTDTO=" :INPUT SET /P INPUTDTO=Enter the DTO: if "%INPUTDTO:~-3%" neq "DTO" ( ECHO ERROR: Please enter a valid DTO. goto INPUT ) </code></p... | 7002, 30645 | batch-file, batch-processing | <h1>How to check if the user input ends with a specific string in batch (.bat) script</h1>
<p>I am writing a batch script where if user input is empty or doesnot ends with "DTO" I need to ask user to enter DTO name again.</p>
<pre><code>:INPUT
SET /P INPUTDTO=Enter the DTO:
IF "%INPUTDTO%"=="" (
IF "%INPUTDTO%"... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,699 | cmd | # How to check if the user input ends with a specific string in batch (.bat) script
I am writing a batch script where if user input is empty or doesnot ends with "DTO" I need to ask user to enter DTO name again.
```
:INPUT
SET /P INPUTDTO=Enter the DTO:
IF "%INPUTDTO%"=="" (
IF "%INPUTDTO%" ??????? (
... | The existing INPUTDTO value should probably be cleared because SET /P will preserve the existing value if the user does not enter anything.
```
@echo off
set "INPUTDTO="
:INPUT
SET /P INPUTDTO=Enter the DTO:
if "%INPUTDTO:~-3%" neq "DTO" (
ECHO ERROR: Please enter a valid DTO.
goto INPUT
)
```
Add the `/I` switch... |
75508267 | How to solve deprecation warning of JobBuilderFactory and StepBuilderFactory | 17 | 2023-02-20 10:48:31 | <p>I'm using the following factories to set up my Spring Batch application:</p>
<pre class="lang-java prettyprint-override"><code>private JobBuilderFactory jobBuilderFactory;
private StepBuilderFactory stepBuilderFactory;
</code></pre>
<p>However, I'm getting the following deprecation warning:</p>
<pre><code>The type J... | 50,828 | 21,249,956 | 2024-04-04 06:50:11 | 75,508,415 | 26 | 2023-02-20 11:01:32 | 1,915,448 | 2023-02-20 11:13:56 | https://stackoverflow.com/q/75508267 | https://stackoverflow.com/a/75508415 | <p>In stead of using <code>JobBuilderFactory</code> and <code>StepBuilderFactory</code>, you can use the <code>JobBuilder</code> and <code>StepBuilder</code> class:</p>
<pre class="lang-java prettyprint-override"><code>@Bean
public Step step1() {
return new StepBuilder("csv-step", jobRepository)
.... | <p>In stead of using <code>JobBuilderFactory</code> and <code>StepBuilderFactory</code>, you can use the <code>JobBuilder</code> and <code>StepBuilder</code> class:</p> <pre class="lang-java prettyprint-override"><code>@Bean public Step step1() { return new StepBuilder("csv-step", jobRepository) .... | 41895, 95875 | spring-batch, spring-boot | <h1>How to solve deprecation warning of JobBuilderFactory and StepBuilderFactory</h1>
<p>I'm using the following factories to set up my Spring Batch application:</p>
<pre class="lang-java prettyprint-override"><code>private JobBuilderFactory jobBuilderFactory;
private StepBuilderFactory stepBuilderFactory;
</code></pre... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,700 | cmd | # How to solve deprecation warning of JobBuilderFactory and StepBuilderFactory
I'm using the following factories to set up my Spring Batch application:
```
private JobBuilderFactory jobBuilderFactory;
private StepBuilderFactory stepBuilderFactory;
```
However, I'm getting the following deprecation warning:
```
The ... | In stead of using `JobBuilderFactory` and `StepBuilderFactory`, you can use the `JobBuilder` and `StepBuilder` class:
```
@Bean
public Step step1() {
return new StepBuilder("csv-step", jobRepository)
.<MSTabcNEUser, MSTabcNEUser>chunk(10, transactionManager)
.reader(reader())
.processor(pro... |
265370 | UTF-16 to UTF-8 conversion (for scripting in Windows) | 16 | 2008-11-05 14:54:55 | <p>what is the best way to convert a UTF-16 files to UTF-8? I need to use this in a cmd script.</p>
| 41,768 | 5,363 | 2021-10-13 20:29:32 | 266,279 | 26 | 2008-11-05 19:28:22 | 12,547 | 2008-11-05 19:28:22 | https://stackoverflow.com/q/265370 | https://stackoverflow.com/a/266279 | <p>There is a GNU tool <a href="http://www.gnu.org/software/recode/recode.html" rel="noreferrer">recode</a> which you can also use on Windows.
E.g.</p>
<pre><code>recode utf16..utf8 text.txt
</code></pre>
| <p>There is a GNU tool <a href="http://www.gnu.org/software/recode/recode.html" rel="noreferrer">recode</a> which you can also use on Windows. E.g.</p> <pre><code>recode utf16..utf8 text.txt </code></pre> | 64, 2631, 7002, 8944, 10016 | batch-file, cmd, utf-16, utf-8, windows | <h1>UTF-16 to UTF-8 conversion (for scripting in Windows)</h1>
<p>what is the best way to convert a UTF-16 files to UTF-8? I need to use this in a cmd script.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,703 | cmd | # UTF-16 to UTF-8 conversion (for scripting in Windows)
what is the best way to convert a UTF-16 files to UTF-8? I need to use this in a cmd script. | There is a GNU tool [recode](http://www.gnu.org/software/recode/recode.html) which you can also use on Windows.
E.g.
```
recode utf16..utf8 text.txt
``` |
23313709 | Play invisible music with batch file? | 15 | 2014-04-26 16:34:10 | <p>I've seen a cfew threads that say how to play music with the play minimized when it starts with <code>start /min</code>, as well as one that creates a VBS script to run the audio minimized. But no matter which way I try to get audio to run minimized, it appears on screen. </p>
<p>Also, if I try <code>start /min</co... | 72,247 | 2,155,331 | 2020-11-29 09:42:35 | 23,316,395 | 26 | 2014-04-26 20:52:23 | 2,414,894 | 2020-03-23 22:47:54 | https://stackoverflow.com/q/23313709 | https://stackoverflow.com/a/23316395 | <pre class="lang-dos prettyprint-override"><code>@echo off
set "file=track12.mp3"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%file%"
echo Sound.Controls.play
echo do while Sound.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(Sound.currentmedia.du... | <pre class="lang-dos prettyprint-override"><code>@echo off set "file=track12.mp3" ( echo Set Sound = CreateObject("WMPlayer.OCX.7"^) echo Sound.URL = "%file%" echo Sound.Controls.play echo do while Sound.currentmedia.duration = 0 echo wscript.sleep 100 echo loop echo wscript.sleep (int(Sound.currentmedia.du... | 348, 1337, 7002 | audio, batch-file, hidden | <h1>Play invisible music with batch file?</h1>
<p>I've seen a cfew threads that say how to play music with the play minimized when it starts with <code>start /min</code>, as well as one that creates a VBS script to run the audio minimized. But no matter which way I try to get audio to run minimized, it appears on scree... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,704 | cmd | # Play invisible music with batch file?
I've seen a cfew threads that say how to play music with the play minimized when it starts with `start /min`, as well as one that creates a VBS script to run the audio minimized. But no matter which way I try to get audio to run minimized, it appears on screen.
Also, if I try `... | ```
@echo off
set "file=track12.mp3"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%file%"
echo Sound.Controls.play
echo do while Sound.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs
start /min soun... |
10711839 | Using a custom Tee command for .bat file | 15 | 2012-05-23 00:17:43 | <p>I am trying to use the <a href="http://www.robvanderwoude.com/unixports.php#TEE" rel="noreferrer">tee</a> code written for a bat file but am having trouble implementing it in my code. I don't want to use any third party installs to solve the tee problem as I want the code to work if I format my computer in a year an... | 25,515 | 779,920 | 2017-07-04 13:27:06 | 10,719,322 | 26 | 2012-05-23 11:51:38 | 1,012,053 | 2017-07-04 13:27:06 | https://stackoverflow.com/q/10711839 | https://stackoverflow.com/a/10719322 | <p>Your attempt to call a batch function within a pipe will always fail because of how Windows pipes work - Windows instantiates both sides of the pipe via new CMD shells. See <a href="https://stackoverflow.com/a/8194279/1012053">https://stackoverflow.com/a/8194279/1012053</a> for more info.</p>
<p>That Rob van der Wo... | <p>Your attempt to call a batch function within a pipe will always fail because of how Windows pipes work - Windows instantiates both sides of the pipe via new CMD shells. See <a href="https://stackoverflow.com/a/8194279/1012053">https://stackoverflow.com/a/8194279/1012053</a> for more info.</p> <p>That Rob van der Wo... | 64, 2631, 7002 | batch-file, cmd, windows | <h1>Using a custom Tee command for .bat file</h1>
<p>I am trying to use the <a href="http://www.robvanderwoude.com/unixports.php#TEE" rel="noreferrer">tee</a> code written for a bat file but am having trouble implementing it in my code. I don't want to use any third party installs to solve the tee problem as I want the... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,705 | cmd | # Using a custom Tee command for .bat file
I am trying to use the [tee](http://www.robvanderwoude.com/unixports.php#TEE) code written for a bat file but am having trouble implementing it in my code. I don't want to use any third party installs to solve the tee problem as I want the code to work if I format my computer... | Your attempt to call a batch function within a pipe will always fail because of how Windows pipes work - Windows instantiates both sides of the pipe via new CMD shells. See <https://stackoverflow.com/a/8194279/1012053> for more info.
That Rob van der Woude version of a batch tee cannot possibly work for you because it... |
38595481 | How do I apply formatting like italic or bold to text using ANSI escaping sequences in a console? | 13 | 2016-07-26 16:40:00 | <p>How do I format text with ANSI escaping?</p>
<p>Like make things <em>italic</em> or <strong>bold</strong> and maybe strikethrough and super script.</p>
| 18,307 | 6,621,301 | 2023-06-10 15:08:53 | 38,600,155 | 26 | 2016-07-26 21:26:42 | 3,536,342 | 2021-09-15 16:19:46 | https://stackoverflow.com/q/38595481 | https://stackoverflow.com/a/38600155 | <h3>How I format like, make things italic or bold using ANSI terminal escape codes?</h3>
<p>Bold: Use <code>ESC[1m</code></p>
<p>Italic, Strike-through and Superscript are not supported.</p>
<p>Some terminals support additional sequences. For example in a Gnome Terminal you can use:</p>
<blockquote>
<pre><code>echo -e ... | <h3>How I format like, make things italic or bold using ANSI terminal escape codes?</h3> <p>Bold: Use <code>ESC[1m</code></p> <p>Italic, Strike-through and Superscript are not supported.</p> <p>Some terminals support additional sequences. For example in a Gnome Terminal you can use:</p> <blockquote> <pre><code>echo -e ... | 1018, 1843, 2631, 6439, 14323 | ansi-escape, ascii, cmd, colors, lua | <h1>How do I apply formatting like italic or bold to text using ANSI escaping sequences in a console?</h1>
<p>How do I format text with ANSI escaping?</p>
<p>Like make things <em>italic</em> or <strong>bold</strong> and maybe strikethrough and super script.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,706 | cmd | # How do I apply formatting like italic or bold to text using ANSI escaping sequences in a console?
How do I format text with ANSI escaping?
Like make things *italic* or **bold** and maybe strikethrough and super script. | ### How I format like, make things italic or bold using ANSI terminal escape codes?
Bold: Use `ESC[1m`
Italic, Strike-through and Superscript are not supported.
Some terminals support additional sequences. For example in a Gnome Terminal you can use:
> ```
> echo -e "\e[1mbold\e[0m"
> echo -e "\e[3mitalic\e[0m"
> e... |
34713621 | Batch - Converting variable to uppercase | 13 | 2016-01-11 03:09:17 | <p>How would I go about changing the <strong>destl</strong> variable to uppercase before it is used. I assume some sort of character swap, however I couldn't get it working. Code is as follows - </p>
<pre><code>@echo off
echo.
set /P "destf=Enter First Name: "
set /P "destl=Enter Last Name: "
set "findest=Z:\Projec... | 69,087 | 5,680,843 | 2024-11-01 14:58:30 | 34,723,215 | 26 | 2016-01-11 13:52:04 | 1,683,264 | 2024-07-10 16:08:34 | https://stackoverflow.com/q/34713621 | https://stackoverflow.com/a/34723215 | <p>The shortest way (without requiring 3rd party downloads) would be to use PowerShell.</p>
<pre class="lang-js prettyprint-override"><code>set "str=The quick brown fox"
for /f "usebackq delims=" %%I in (`powershell "\"%str%\".toUpper()"`) do set "upper=%%~I"
</code></... | <p>The shortest way (without requiring 3rd party downloads) would be to use PowerShell.</p> <pre class="lang-js prettyprint-override"><code>set "str=The quick brown fox" for /f "usebackq delims=" %%I in (`powershell "\"%str%\".toUpper()"`) do set "upper=%%~I" </code></... | 7002 | batch-file | <h1>Batch - Converting variable to uppercase</h1>
<p>How would I go about changing the <strong>destl</strong> variable to uppercase before it is used. I assume some sort of character swap, however I couldn't get it working. Code is as follows - </p>
<pre><code>@echo off
echo.
set /P "destf=Enter First Name: "
set /P... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,707 | cmd | # Batch - Converting variable to uppercase
How would I go about changing the **destl** variable to uppercase before it is used. I assume some sort of character swap, however I couldn't get it working. Code is as follows -
```
@echo off
echo.
set /P "destf=Enter First Name: "
set /P "destl=Enter Last Name: "
set "f... | The shortest way (without requiring 3rd party downloads) would be to use PowerShell.
```
set "str=The quick brown fox"
for /f "usebackq delims=" %%I in (`powershell "\"%str%\".toUpper()"`) do set "upper=%%~I"
```
A faster way but still using less code than any pure batch solution would be to employ WSH.
```
@if (@Co... |
30591387 | My FTP batch script is stuck on "200 PORT command successful" and doesn't upload the files to server | 13 | 2015-06-02 08:48:17 | <p>I've tried everything I found in Google results about</p>
<blockquote>
<p>200 PORT command successful</p>
</blockquote>
<p>but nothing has helped.</p>
<p>Can anyone assist to solve this issue please?</p>
<p><strong>The code of "runScript.bat:</strong></p>
<pre><code>ftp -s:"C:\automation\fileup.bat" m... | 47,241 | 4,457,986 | 2020-10-08 05:54:23 | 30,594,963 | 26 | 2015-06-02 11:34:50 | 850,848 | 2017-02-28 08:12:05 | https://stackoverflow.com/q/30591387 | https://stackoverflow.com/a/30594963 | <p>This looks like a typical problem with the FTP active mode. The server cannot connect back to your machine to establish a data transfer connection.</p>
<p>That typically happens as nowadays most client machines are behind a firewall or NAT or both, what prevents the FTP active mode from working. To make the active ... | <p>This looks like a typical problem with the FTP active mode. The server cannot connect back to your machine to establish a data transfer connection.</p> <p>That typically happens as nowadays most client machines are behind a firewall or NAT or both, what prevents the FTP active mode from working. To make the active ... | 64, 261, 1362, 7002 | automation, batch-file, ftp, windows | <h1>My FTP batch script is stuck on "200 PORT command successful" and doesn't upload the files to server</h1>
<p>I've tried everything I found in Google results about</p>
<blockquote>
<p>200 PORT command successful</p>
</blockquote>
<p>but nothing has helped.</p>
<p>Can anyone assist to solve this issue please?</p>
<p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,708 | cmd | # My FTP batch script is stuck on "200 PORT command successful" and doesn't upload the files to server
I've tried everything I found in Google results about
> 200 PORT command successful
but nothing has helped.
Can anyone assist to solve this issue please?
**The code of "runScript.bat:**
```
ftp -s:"C:\automation... | This looks like a typical problem with the FTP active mode. The server cannot connect back to your machine to establish a data transfer connection.
That typically happens as nowadays most client machines are behind a firewall or NAT or both, what prevents the FTP active mode from working. To make the active mode worki... |
10323317 | Batch processing pandoc conversions | 12 | 2012-04-25 20:33:22 | <p>I've searched high and low to try and work out how to batch process <a href="http://johnmacfarlane.net/pandoc/README.html" rel="nofollow noreferrer">pandoc</a>.</p>
<p>How do I convert a folder and nested folders containing html files to markdown?</p>
<p>I'm using os x 10.6.8</p>
| 7,180 | 1,351,898 | 2020-11-29 06:11:06 | 10,323,583 | 26 | 2012-04-25 20:52:13 | 643,977 | 2012-04-25 20:52:13 | https://stackoverflow.com/q/10323317 | https://stackoverflow.com/a/10323583 | <p>You can apply any command across the files in a directory tree using <code>find</code>:</p>
<pre><code>find . -name \*.md -type f -exec pandoc -o {}.txt {} \;
</code></pre>
<p>would run <code>pandoc</code> on all files with a <code>.md</code> suffix, creating a file with a <code>.md.txt</code> suffix. (You will n... | <p>You can apply any command across the files in a directory tree using <code>find</code>:</p> <pre><code>find . -name \*.md -type f -exec pandoc -o {}.txt {} \; </code></pre> <p>would run <code>pandoc</code> on all files with a <code>.md</code> suffix, creating a file with a <code>.md.txt</code> suffix. (You will n... | 30645, 32395, 66036 | batch-processing, osx-snow-leopard, pandoc | <h1>Batch processing pandoc conversions</h1>
<p>I've searched high and low to try and work out how to batch process <a href="http://johnmacfarlane.net/pandoc/README.html" rel="nofollow noreferrer">pandoc</a>.</p>
<p>How do I convert a folder and nested folders containing html files to markdown?</p>
<p>I'm using os x 10... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,709 | cmd | # Batch processing pandoc conversions
I've searched high and low to try and work out how to batch process [pandoc](http://johnmacfarlane.net/pandoc/README.html).
How do I convert a folder and nested folders containing html files to markdown?
I'm using os x 10.6.8 | You can apply any command across the files in a directory tree using `find`:
```
find . -name \*.md -type f -exec pandoc -o {}.txt {} \;
```
would run `pandoc` on all files with a `.md` suffix, creating a file with a `.md.txt` suffix. (You will need a wrapper script if you want to get a `.txt` suffix without the `.md... |
36228474 | Batch file if string starts with | 11 | 2016-03-25 21:38:56 | <p>I'm trying to figure out if a string starts with a substring :</p>
<pre><code>rem GetInput
if "%result%"=="cd *" goto Cd
:Cd
if "%result%"=="cd meow" Echo Going to directory 'meow'...
</code></pre>
<p>Unfortunately this not looping back to :Cd when it should. How can I detect ... | 32,675 | 6,115,738 | 2023-11-16 12:59:28 | 36,229,976 | 26 | 2016-03-25 23:58:35 | 4,084,981 | 2016-03-27 15:18:54 | https://stackoverflow.com/q/36228474 | https://stackoverflow.com/a/36229976 | <p>If I understand this correctly, you're trying to determine whether that value for <code>%result%</code> begins with 'cd', and you're unsuccessfully using a <code>*</code> as a wildcard to determine this.</p>
<p>There are a few different ways to handle this. Here's one way: You can check to see if the first two ch... | <p>If I understand this correctly, you're trying to determine whether that value for <code>%result%</code> begins with 'cd', and you're unsuccessfully using a <code>*</code> as a wildcard to determine this.</p> <p>There are a few different ways to handle this. Here's one way: You can check to see if the first two ch... | 7002 | batch-file | <h1>Batch file if string starts with</h1>
<p>I'm trying to figure out if a string starts with a substring :</p>
<pre><code>rem GetInput
if "%result%"=="cd *" goto Cd
:Cd
if "%result%"=="cd meow" Echo Going to directory 'meow'...
</code></pre>
<p>Unfortunately this not looping bac... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,710 | cmd | # Batch file if string starts with
I'm trying to figure out if a string starts with a substring :
```
rem GetInput
if "%result%"=="cd *" goto Cd
:Cd
if "%result%"=="cd meow" Echo Going to directory 'meow'...
```
Unfortunately this not looping back to :Cd when it should. How can I detect if th string starts with `cd`... | If I understand this correctly, you're trying to determine whether that value for `%result%` begins with 'cd', and you're unsuccessfully using a `*` as a wildcard to determine this.
There are a few different ways to handle this. Here's one way: You can check to see if the first two characters are equal to 'cd':
```
i... |
48999274 | List all folders and subfolders in cmd, but not the files | 10 | 2018-02-27 00:27:31 | <p>New to using cmd, just wanted to know is there a way to list all folders their subfolders, if any, but not the files.</p>
<p>e.g.<code>D:\Movies\ dir /s /b</code> gives me list of all files and folders located in <code>Movies</code>, and also its subfolders e.g. <code>D:\Movies\Watched</code>. </p>
<p>I would like... | 67,128 | 2,363,861 | 2018-04-04 07:52:29 | 49,002,126 | 26 | 2018-02-27 06:03:02 | 3,074,564 | 2018-04-04 07:52:29 | https://stackoverflow.com/q/48999274 | https://stackoverflow.com/a/49002126 | <p>Yes, this is possible as it can be read on running in a command prompt window <code>dir /?</code> which outputs the help for command <strong>DIR</strong>.</p>
<pre><code>dir D:\Movies\* /AD /B /ON /S
</code></pre>
<p>This command outputs</p>
<ul>
<li>only directories because of <code>/AD</code> (attribute directo... | <p>Yes, this is possible as it can be read on running in a command prompt window <code>dir /?</code> which outputs the help for command <strong>DIR</strong>.</p> <pre><code>dir D:\Movies\* /AD /B /ON /S </code></pre> <p>This command outputs</p> <ul> <li>only directories because of <code>/AD</code> (attribute directo... | 64, 218, 1231, 2631 | cmd, command-line, directory, windows | <h1>List all folders and subfolders in cmd, but not the files</h1>
<p>New to using cmd, just wanted to know is there a way to list all folders their subfolders, if any, but not the files.</p>
<p>e.g.<code>D:\Movies\ dir /s /b</code> gives me list of all files and folders located in <code>Movies</code>, and also its su... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,711 | cmd | # List all folders and subfolders in cmd, but not the files
New to using cmd, just wanted to know is there a way to list all folders their subfolders, if any, but not the files.
e.g.`D:\Movies\ dir /s /b` gives me list of all files and folders located in `Movies`, and also its subfolders e.g. `D:\Movies\Watched`.
I ... | Yes, this is possible as it can be read on running in a command prompt window `dir /?` which outputs the help for command **DIR**.
```
dir D:\Movies\* /AD /B /ON /S
```
This command outputs
- only directories because of `/AD` (attribute directory) including those with hidden attribute set,
- with only the names of t... |
45008564 | container start up failed in jenkins | 9 | 2017-07-10 09:36:34 | <p>When I use the command prompt in windows to run the command <code>java -jar jenkins.war</code> It is giving me the following error:</p>
<pre><code>SEVERE: Container startup failedjava.io.IOException: Failed to start Jetty
at winstone.Launcher.<init>(Launcher.java:154)
at winstone.Launcher.main(Launche... | 38,976 | 7,410,454 | 2021-02-04 15:30:13 | 45,008,667 | 26 | 2017-07-10 09:41:19 | 2,563,754 | 2021-02-04 15:30:13 | https://stackoverflow.com/q/45008564 | https://stackoverflow.com/a/45008667 | <p>The cause of your error:</p>
<blockquote>
<p>Caused by: java.net.BindException: Address already in use: bind</p>
</blockquote>
<p>Explanation: As a default, Jenkins uses the port 8080 (like many other web applications do, too). Obviously, you already have another application listening on port 8080.</p>
<p>So you sho... | <p>The cause of your error:</p> <blockquote> <p>Caused by: java.net.BindException: Address already in use: bind</p> </blockquote> <p>Explanation: As a default, Jenkins uses the port 8080 (like many other web applications do, too). Obviously, you already have another application listening on port 8080.</p> <p>So you sho... | 17, 2631, 7647, 64999 | cmd, java, jenkins, war | <h1>container start up failed in jenkins</h1>
<p>When I use the command prompt in windows to run the command <code>java -jar jenkins.war</code> It is giving me the following error:</p>
<pre><code>SEVERE: Container startup failedjava.io.IOException: Failed to start Jetty
at winstone.Launcher.<init>(Launcher.j... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,713 | cmd | # container start up failed in jenkins
When I use the command prompt in windows to run the command `java -jar jenkins.war` It is giving me the following error:
```
SEVERE: Container startup failedjava.io.IOException: Failed to start Jetty
at winstone.Launcher.<init>(Launcher.java:154)
at winstone.Launcher.mai... | The cause of your error:
> Caused by: java.net.BindException: Address already in use: bind
Explanation: As a default, Jenkins uses the port 8080 (like many other web applications do, too). Obviously, you already have another application listening on port 8080.
So you should bind Jenkins to another port. See [Startin... |
3093631 | Java heap space Xmx Xms parameters ignored | 7 | 2010-06-22 13:40:11 | <p>I have a .JAR that apparently uses up too much memory, and throws an exception "Java heap space" (or something similar).</p>
<p>So I tried running the .JAR via the CMD like this:</p>
<pre><code>C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m
</code></pre>
<p>That did not solve the problem. Same error.
Now, w... | 19,070 | 319,182 | 2016-10-17 07:52:06 | 3,093,662 | 26 | 2010-06-22 13:43:27 | 102,281 | 2010-06-22 13:43:27 | https://stackoverflow.com/q/3093631 | https://stackoverflow.com/a/3093662 | <p>The Command</p>
<pre><code>javaw -jar MyJar.jar -Xms64m -Xmx128m
</code></pre>
<p>will use -Xms... and -Xmx... as parameters to the "main(String[] args)" method.<br>
Parameters <em>to</em> the JVM must be passed before the -jar part: </p>
<pre><code>javaw -Xms64m -Xmx128m -jar MyJar.jar
</code></pre>
<p>The rea... | <p>The Command</p> <pre><code>javaw -jar MyJar.jar -Xms64m -Xmx128m </code></pre> <p>will use -Xms... and -Xmx... as parameters to the "main(String[] args)" method.<br> Parameters <em>to</em> the JVM must be passed before the -jar part: </p> <pre><code>javaw -Xms64m -Xmx128m -jar MyJar.jar </code></pre> <p>The rea... | 17, 360, 1850, 2631, 7428 | cmd, garbage-collection, heap-memory, java, parameters | <h1>Java heap space Xmx Xms parameters ignored</h1>
<p>I have a .JAR that apparently uses up too much memory, and throws an exception "Java heap space" (or something similar).</p>
<p>So I tried running the .JAR via the CMD like this:</p>
<pre><code>C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m
</code></pre>
<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,718 | cmd | # Java heap space Xmx Xms parameters ignored
I have a .JAR that apparently uses up too much memory, and throws an exception "Java heap space" (or something similar).
So I tried running the .JAR via the CMD like this:
```
C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m
```
That did not solve the problem. Same erro... | The Command
```
javaw -jar MyJar.jar -Xms64m -Xmx128m
```
will use -Xms... and -Xmx... as parameters to the "main(String[] args)" method.
Parameters *to* the JVM must be passed before the -jar part:
```
javaw -Xms64m -Xmx128m -jar MyJar.jar
```
The reason for that can be seen when we execute "java -version" :
``... |
578302 | How to print a newline in an MS-DOS script? | 7 | 2009-02-23 16:33:40 | <p>I want to print the output of a program in MS-DOS so I wrote a .bat file that says:</p>
<pre><code>cls
ruby foo.rb
</code></pre>
<p>But the output - as it appears on my command prompt - looks like this:</p>
<pre><code>c:\workspace>ruby foo.rb
foo output
c:\workspace>
</code></pre>
<p>I wanted to insert a n... | 30,277 | 66,282 | 2015-10-21 09:20:01 | 578,312 | 26 | 2009-02-23 16:37:13 | null | 2015-10-21 09:20:01 | https://stackoverflow.com/q/578302 | https://stackoverflow.com/a/578312 | <p><code>echo.</code> will produce a new line.</p>
<p>So your script should look something like this:</p>
<pre><code>@ECHO OFF
cls
echo.
ruby foo.rb
</code></pre>
| <p><code>echo.</code> will produce a new line.</p> <p>So your script should look something like this:</p> <pre><code>@ECHO OFF cls echo. ruby foo.rb </code></pre> | 555, 3705, 5370, 7002 | batch-file, dos, formatting, newline | <h1>How to print a newline in an MS-DOS script?</h1>
<p>I want to print the output of a program in MS-DOS so I wrote a .bat file that says:</p>
<pre><code>cls
ruby foo.rb
</code></pre>
<p>But the output - as it appears on my command prompt - looks like this:</p>
<pre><code>c:\workspace>ruby foo.rb
foo output
c:\w... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,719 | cmd | # How to print a newline in an MS-DOS script?
I want to print the output of a program in MS-DOS so I wrote a .bat file that says:
```
cls
ruby foo.rb
```
But the output - as it appears on my command prompt - looks like this:
```
c:\workspace>ruby foo.rb
foo output
c:\workspace>
```
I wanted to insert a newline int... | `echo.` will produce a new line.
So your script should look something like this:
```
@ECHO OFF
cls
echo.
ruby foo.rb
``` |
21031171 | How to run a command in the background on Windows? | 70 | 2014-01-09 21:08:52 | <p>In linux you can use <em>command</em> <strong>&</strong> to run command on the background, the same will continue after the shell is offline. I was wondering is there something like that for windows…</p>
| 240,194 | 974,687 | 2024-08-02 15:13:41 | 21,031,281 | 25 | 2014-01-09 21:14:29 | 3,061,617 | 2014-01-09 21:14:29 | https://stackoverflow.com/q/21031171 | https://stackoverflow.com/a/21031281 | <p>I'm assuming what you want to do is run a command without an interface (possibly automatically?). On windows there are a number of options for what you are looking for:</p>
<ul>
<li><p>Best: write your program as a windows service. These will start when no one logs into the server. They let you select the user acco... | <p>I'm assuming what you want to do is run a command without an interface (possibly automatically?). On windows there are a number of options for what you are looking for:</p> <ul> <li><p>Best: write your program as a windows service. These will start when no one logs into the server. They let you select the user acco... | 64, 2631, 15292 | background-process, cmd, windows | <h1>How to run a command in the background on Windows?</h1>
<p>In linux you can use <em>command</em> <strong>&</strong> to run command on the background, the same will continue after the shell is offline. I was wondering is there something like that for windows…</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,720 | cmd | # How to run a command in the background on Windows?
In linux you can use *command* **&** to run command on the background, the same will continue after the shell is offline. I was wondering is there something like that for windows… | I'm assuming what you want to do is run a command without an interface (possibly automatically?). On windows there are a number of options for what you are looking for:
- Best: write your program as a windows service. These will start when no one logs into the server. They let you select the user account (which can be... |
8385454 | Batch files: List all files in a directory with relative paths | 67 | 2011-12-05 12:40:39 | <p>Concerning Windows batch files: Is there a way to list all the files (or all of a specific type) in a certain directory and its subdirectories, including the paths relative to the current (or the search) directory in the list?</p>
<p>For example, if I want all the .txt files in the current directory and subdirector... | 226,819 | 808,151 | 2022-10-28 13:07:42 | 8,387,078 | 25 | 2011-12-05 14:47:26 | 463,115 | 2013-09-08 11:03:49 | https://stackoverflow.com/q/8385454 | https://stackoverflow.com/a/8387078 | <p>You could simply get the character length of the current directory, and remove them from your <em>absolute list</em></p>
<pre><code>setlocal EnableDelayedExpansion
for /L %%n in (1 1 500) do if "!__cd__:~%%n,1!" neq "" set /a "len=%%n+1"
setlocal DisableDelayedExpansion
for /r . %%g in (*.log) do (
set "absPath=%... | <p>You could simply get the character length of the current directory, and remove them from your <em>absolute list</em></p> <pre><code>setlocal EnableDelayedExpansion for /L %%n in (1 1 500) do if "!__cd__:~%%n,1!" neq "" set /a "len=%%n+1" setlocal DisableDelayedExpansion for /r . %%g in (*.log) do ( set "absPath=%... | 64, 2631, 7002, 8877 | batch-file, cmd, relative-path, windows | <h1>Batch files: List all files in a directory with relative paths</h1>
<p>Concerning Windows batch files: Is there a way to list all the files (or all of a specific type) in a certain directory and its subdirectories, including the paths relative to the current (or the search) directory in the list?</p>
<p>For exampl... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,721 | cmd | # Batch files: List all files in a directory with relative paths
Concerning Windows batch files: Is there a way to list all the files (or all of a specific type) in a certain directory and its subdirectories, including the paths relative to the current (or the search) directory in the list?
For example, if I want all... | You could simply get the character length of the current directory, and remove them from your *absolute list*
```
setlocal EnableDelayedExpansion
for /L %%n in (1 1 500) do if "!__cd__:~%%n,1!" neq "" set /a "len=%%n+1"
setlocal DisableDelayedExpansion
for /r . %%g in (*.log) do (
set "absPath=%%g"
setlocal Enable... |
14354502 | Difference between %variable% and !variable! in batch file | 51 | 2013-01-16 08:58:48 | <p>I am writing a batch file where I need to output a string containing '!' to another file. But when I echo that string to another file, it removes "!" from the output. </p>
<p>Eg:
Input:</p>
<pre><code>set LINE=Hi this is! output
echo !LINE!>>new_file.txt
</code></pre>
<p>Output in new_file.txt is:</p>
<pr... | 82,504 | 1,503,667 | 2023-12-05 14:13:13 | 14,355,389 | 25 | 2013-01-16 09:46:06 | 463,115 | 2020-01-16 10:11:42 | https://stackoverflow.com/q/14354502 | https://stackoverflow.com/a/14355389 | <p>If you have delayed expansion enabled and want to output an exclamation mark, you need to escape it.</p>
<p>Escaping of exclamation marks needs none, one or two carets, depending on the placement.</p>
<pre><code>@echo off
REM No escaping required, if delayed expansion is disabled
set test1=Test1!
setlocal EnableD... | <p>If you have delayed expansion enabled and want to output an exclamation mark, you need to escape it.</p> <p>Escaping of exclamation marks needs none, one or two carets, depending on the placement.</p> <pre><code>@echo off REM No escaping required, if delayed expansion is disabled set test1=Test1! setlocal EnableD... | 64, 1231, 7002 | batch-file, command-line, windows | <h1>Difference between %variable% and !variable! in batch file</h1>
<p>I am writing a batch file where I need to output a string containing '!' to another file. But when I echo that string to another file, it removes "!" from the output. </p>
<p>Eg:
Input:</p>
<pre><code>set LINE=Hi this is! output
echo !LINE!>&g... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,722 | cmd | # Difference between %variable% and !variable! in batch file
I am writing a batch file where I need to output a string containing '!' to another file. But when I echo that string to another file, it removes "!" from the output.
Eg:
Input:
```
set LINE=Hi this is! output
echo !LINE!>>new_file.txt
```
Output in new_f... | If you have delayed expansion enabled and want to output an exclamation mark, you need to escape it.
Escaping of exclamation marks needs none, one or two carets, depending on the placement.
```
@echo off
REM No escaping required, if delayed expansion is disabled
set test1=Test1!
setlocal EnableDelayedExpansion
REM O... |
9363080 | How to make SHIFT work with %* in batch files | 48 | 2012-02-20 14:52:18 | <p>In my batch file on Windows XP, I want to use <code>%*</code> to expand to all parameters except the first.<br/><strong>Test file</strong> (<em>foo.bat</em>):</p>
<pre><code>@echo off
echo %*
shift
echo %*
</code></pre>
<p>Call:</p>
<pre><code>C:\> foo a b c d e f
</code></pre>
<p><strong>Actual</strong> resu... | 18,209 | 1,005,481 | 2025-09-11 00:46:46 | 9,363,989 | 25 | 2012-02-20 15:49:12 | 1,012,053 | 2012-02-20 15:49:12 | https://stackoverflow.com/q/9363080 | https://stackoverflow.com/a/9363989 | <p>Wouldn't it be wonderful if CMD.EXE worked that way! Unfortunately there is not a good syntax that will do what you want. The best you can do is parse the command line yourself and build a new argument list.</p>
<p>Something like this can work.</p>
<pre><code>@echo off
setlocal
echo %*
shift
set "args="
:parse
if ... | <p>Wouldn't it be wonderful if CMD.EXE worked that way! Unfortunately there is not a good syntax that will do what you want. The best you can do is parse the command line yourself and build a new argument list.</p> <p>Something like this can work.</p> <pre><code>@echo off setlocal echo %* shift set "args=" :parse if ... | 2216, 7002 | batch-file, windows-xp | <h1>How to make SHIFT work with %* in batch files</h1>
<p>In my batch file on Windows XP, I want to use <code>%*</code> to expand to all parameters except the first.<br/><strong>Test file</strong> (<em>foo.bat</em>):</p>
<pre><code>@echo off
echo %*
shift
echo %*
</code></pre>
<p>Call:</p>
<pre><code>C:\> foo a b... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,723 | cmd | # How to make SHIFT work with %* in batch files
In my batch file on Windows XP, I want to use `%*` to expand to all parameters except the first.
**Test file** (*foo.bat*):
```
@echo off
echo %*
shift
echo %*
```
Call:
```
C:\> foo a b c d e f
```
**Actual** result:
```
a b c d e f
a b c d e f
```
**Desired** r... | Wouldn't it be wonderful if CMD.EXE worked that way! Unfortunately there is not a good syntax that will do what you want. The best you can do is parse the command line yourself and build a new argument list.
Something like this can work.
```
@echo off
setlocal
echo %*
shift
set "args="
:parse
if "%~1" neq "" (
set ... |
9038926 | How to send a simple email from a Windows batch file? | 37 | 2012-01-27 19:28:40 | <p>I'm running Windows 2003 Service Pack 2. I have a batch file that runs on demand. I want to have an email sent every time the batch file runs. The email is simple, just a sentence indicating that the batch file ran; it is the same every time.</p>
<p>I've tried a couple of things to get this done. I thought of telne... | 368,047 | 448,810 | 2021-09-23 09:19:36 | 9,039,810 | 25 | 2012-01-27 20:45:21 | 964,043 | 2012-01-27 20:45:21 | https://stackoverflow.com/q/9038926 | https://stackoverflow.com/a/9039810 | <p>Max is on he right track with the suggestion to use Windows Scripting for a way to do it without installing any additional executables on the machine. His code will work if you have the IIS SMTP service setup to forward outbound email using the "smart host" setting, or the machine also happens to be running Microsof... | <p>Max is on he right track with the suggestion to use Windows Scripting for a way to do it without installing any additional executables on the machine. His code will work if you have the IIS SMTP service setup to forward outbound email using the "smart host" setting, or the machine also happens to be running Microsof... | 64, 146, 7002 | batch-file, email, windows | <h1>How to send a simple email from a Windows batch file?</h1>
<p>I'm running Windows 2003 Service Pack 2. I have a batch file that runs on demand. I want to have an email sent every time the batch file runs. The email is simple, just a sentence indicating that the batch file ran; it is the same every time.</p>
<p>I'v... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,724 | cmd | # How to send a simple email from a Windows batch file?
I'm running Windows 2003 Service Pack 2. I have a batch file that runs on demand. I want to have an email sent every time the batch file runs. The email is simple, just a sentence indicating that the batch file ran; it is the same every time.
I've tried a couple... | Max is on he right track with the suggestion to use Windows Scripting for a way to do it without installing any additional executables on the machine. His code will work if you have the IIS SMTP service setup to forward outbound email using the "smart host" setting, or the machine also happens to be running Microsoft E... |
5735146 | Windows 7 batch files: How to check if parameter has been passed to batch file | 31 | 2011-04-20 18:49:21 | <p>Back in the mid-90's, I remember doing something like this:</p>
<pre><code>if %1==. dir
</code></pre>
<p>basically, if you put the above code in <code>dodir.bat</code> and run it on its own without passing it any parameters, it would run the dir command. However, if you passed it anything at all as a parameter, i... | 43,834 | 701,346 | 2017-11-23 10:24:41 | 5,736,533 | 25 | 2011-04-20 20:55:28 | 297,408 | 2015-12-28 19:35:50 | https://stackoverflow.com/q/5735146 | https://stackoverflow.com/a/5736533 | <p>Actually it was <code>if %1<b>.</b>==. <i>command</i></code> (note the <code>.</code> after <code>%1</code>) back then. And you can use that now in Windows 7, it should work.</p>
<p>Example usage:</p>
<pre><code>if %1.==. (
echo No parameters have been provided.
) else (
echo Parameters:
echo %*
)
</co... | <p>Actually it was <code>if %1<b>.</b>==. <i>command</i></code> (note the <code>.</code> after <code>%1</code>) back then. And you can use that now in Windows 7, it should work.</p> <p>Example usage:</p> <pre><code>if %1.==. ( echo No parameters have been provided. ) else ( echo Parameters: echo %* ) </co... | 7002, 34595 | batch-file, windows-7 | <h1>Windows 7 batch files: How to check if parameter has been passed to batch file</h1>
<p>Back in the mid-90's, I remember doing something like this:</p>
<pre><code>if %1==. dir
</code></pre>
<p>basically, if you put the above code in <code>dodir.bat</code> and run it on its own without passing it any parameters, it... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,725 | cmd | # Windows 7 batch files: How to check if parameter has been passed to batch file
Back in the mid-90's, I remember doing something like this:
```
if %1==. dir
```
basically, if you put the above code in `dodir.bat` and run it on its own without passing it any parameters, it would run the dir command. However, if you ... | Actually it was `if %1.==. command` (note the `.` after `%1`) back then. And you can use that now in Windows 7, it should work.
Example usage:
```
if %1.==. (
echo No parameters have been provided.
) else (
echo Parameters:
echo %*
)
``` |
8609028 | Copying Files with Wildcards in the Path | 25 | 2011-12-22 19:52:35 | <p>Assume there exists the directory structure C:\users\myuser\Desktop\bob\marley.</p>
<p>In windows, from the starting directory C:\users\myuser\Desktop I can do "cd bo*\mar*" and cd in to the directory bob\marley. However, I can't do a "copy bo*\mar* C:\"</p>
<p>I need to use the copy, xcopy, or some standard wind... | 97,849 | 549,939 | 2017-10-27 16:16:20 | 8,609,187 | 25 | 2011-12-22 20:10:17 | 1,012,053 | 2011-12-22 20:40:53 | https://stackoverflow.com/q/8609028 | https://stackoverflow.com/a/8609187 | <p>No - you cannot do that with COPY or XCOPY. There is a fundamental flaw with what you are asking.</p>
<p>What if you also have a directory named "boston\marathon"? Which directory do you want to copy from?</p>
<p>You might answer - "I want both". But now you have a nasty potential problem. What if both source dire... | <p>No - you cannot do that with COPY or XCOPY. There is a fundamental flaw with what you are asking.</p> <p>What if you also have a directory named "boston\marathon"? Which directory do you want to copy from?</p> <p>You might answer - "I want both". But now you have a nasty potential problem. What if both source dire... | 7002 | batch-file | <h1>Copying Files with Wildcards in the Path</h1>
<p>Assume there exists the directory structure C:\users\myuser\Desktop\bob\marley.</p>
<p>In windows, from the starting directory C:\users\myuser\Desktop I can do "cd bo*\mar*" and cd in to the directory bob\marley. However, I can't do a "copy bo*\mar* C:\"</p>
<p>I ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,727 | cmd | # Copying Files with Wildcards in the Path
Assume there exists the directory structure C:\users\myuser\Desktop\bob\marley.
In windows, from the starting directory C:\users\myuser\Desktop I can do "cd bo*\mar*" and cd in to the directory bob\marley. However, I can't do a "copy bo*\mar* C:\"
I need to use the copy, xc... | No - you cannot do that with COPY or XCOPY. There is a fundamental flaw with what you are asking.
What if you also have a directory named "boston\marathon"? Which directory do you want to copy from?
You might answer - "I want both". But now you have a nasty potential problem. What if both source directories contain a... |
11419046 | How do I return a value from a function in a batch file? | 23 | 2012-07-10 17:52:43 | <p>I have the following batch file</p>
<pre><code>@echo off
setlocal EnableDelayedExpansion
for /f "delims==" %%J in (File_List.txt) do (
call :setDate %%J MYD
echo/Date is: %MYD%
)
endlocal &goto :eof
:setDate
SETLOCAL ENABLEEXTENSIONS
echo %1
echo %~2
set NAME=%1
set NAME=%NAME:~-11%
echo %NAME%
echo %~2
endloc... | 60,650 | 1,064,780 | 2024-08-05 10:55:44 | 11,419,412 | 25 | 2012-07-10 18:16:44 | 1,336,150 | 2012-07-10 18:16:44 | https://stackoverflow.com/q/11419046 | https://stackoverflow.com/a/11419412 | <p>The batch interpreter evaluates <code>%MYD%</code> at parse time, and at that time it's empty. That's why you have <a href="http://ss64.com/nt/delayedexpansion.html" rel="noreferrer">Delayed Expansion</a>. Change this line:</p>
<pre><code>echo/Date is: %MYD%
</code></pre>
<p>to this:</p>
<pre><code>echo/Date is: ... | <p>The batch interpreter evaluates <code>%MYD%</code> at parse time, and at that time it's empty. That's why you have <a href="http://ss64.com/nt/delayedexpansion.html" rel="noreferrer">Delayed Expansion</a>. Change this line:</p> <pre><code>echo/Date is: %MYD% </code></pre> <p>to this:</p> <pre><code>echo/Date is: ... | 64, 7002 | batch-file, windows | <h1>How do I return a value from a function in a batch file?</h1>
<p>I have the following batch file</p>
<pre><code>@echo off
setlocal EnableDelayedExpansion
for /f "delims==" %%J in (File_List.txt) do (
call :setDate %%J MYD
echo/Date is: %MYD%
)
endlocal &goto :eof
:setDate
SETLOCAL ENABLEEXTENSIONS
echo %1
ech... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,728 | cmd | # How do I return a value from a function in a batch file?
I have the following batch file
```
@echo off
setlocal EnableDelayedExpansion
for /f "delims==" %%J in (File_List.txt) do (
call :setDate %%J MYD
echo/Date is: %MYD%
)
endlocal &goto :eof
:setDate
SETLOCAL ENABLEEXTENSIONS
echo %1
echo %~2
set NAME=%1
set NA... | The batch interpreter evaluates `%MYD%` at parse time, and at that time it's empty. That's why you have [Delayed Expansion](http://ss64.com/nt/delayedexpansion.html). Change this line:
```
echo/Date is: %MYD%
```
to this:
```
echo/Date is: !MYD!
```
and it will work like you want, because then it tells the interpre... |
50985087 | How to reduce the file size (reduce quality) on a batch of JPEG images? (Mac) | 20 | 2018-06-22 09:39:41 | <p>I have a list of .JPG files on a Mac. I want to export them to a format taking less than 500 kilobytes per image.
I know how to do that using the Preview application one image at a time; but I want to be able to do the same in batch, meaning on several files at once. Is there a command line way to do it so I could w... | 20,221 | 611,201 | 2024-06-09 19:45:03 | 50,986,282 | 25 | 2018-06-22 10:48:52 | 1,135,424 | 2024-06-09 19:45:03 | https://stackoverflow.com/q/50985087 | https://stackoverflow.com/a/50986282 | <p>This is an example from the command line using <a href="https://www.imagemagick.org/script/convert.php" rel="nofollow noreferrer">convert</a> (<code>brew info imagemagick</code>) converting all <code>*.jpg</code> images in one directory to <code>.png</code>:</p>
<pre class="lang-bash prettyprint-override"><code>for ... | <p>This is an example from the command line using <a href="https://www.imagemagick.org/script/convert.php" rel="nofollow noreferrer">convert</a> (<code>brew info imagemagick</code>) converting all <code>*.jpg</code> images in one directory to <code>.png</code>:</p> <pre class="lang-bash prettyprint-override"><code>for ... | 1231, 1585, 30645 | batch-processing, command-line, jpeg | <h1>How to reduce the file size (reduce quality) on a batch of JPEG images? (Mac)</h1>
<p>I have a list of .JPG files on a Mac. I want to export them to a format taking less than 500 kilobytes per image.
I know how to do that using the Preview application one image at a time; but I want to be able to do the same in bat... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,730 | cmd | # How to reduce the file size (reduce quality) on a batch of JPEG images? (Mac)
I have a list of .JPG files on a Mac. I want to export them to a format taking less than 500 kilobytes per image.
I know how to do that using the Preview application one image at a time; but I want to be able to do the same in batch, meani... | This is an example from the command line using [convert](https://www.imagemagick.org/script/convert.php) (`brew info imagemagick`) converting all `*.jpg` images in one directory to `.png`:
```
for i in *.jpg; do
convert "$i" "${i%.jpg}.png"
done
```
For a dry run (test) you can use `echo` instead of the `<command... |
29303155 | How does Spring Batch transaction management work? | 20 | 2015-03-27 14:31:29 | <p>I'm trying to understand how Spring Batch does transaction management. This is not a technical question but more of conceptual one: what approach does Spring Batch use and what are the consequences of that approach?</p>
<p>Let me try to clarify this question a bit. For instance, looking at the TaskletStep, I see th... | 34,792 | 1,688,586 | 2022-02-10 15:08:08 | 29,304,822 | 25 | 2015-03-27 15:51:12 | 618,059 | 2015-03-27 15:51:12 | https://stackoverflow.com/q/29303155 | https://stackoverflow.com/a/29304822 | <p>There are two fundamental types of steps in Spring Batch, a Tasklet Step and a chunk based step. Each has it's own transaction details. Let's look at each:</p>
<p><strong>Tasklet Based Step</strong><br>
When a developer implements their own tasklet, the transactionality is pretty straight forward. Each call to t... | <p>There are two fundamental types of steps in Spring Batch, a Tasklet Step and a chunk based step. Each has it's own transaction details. Let's look at each:</p> <p><strong>Tasklet Based Step</strong><br> When a developer implements their own tasklet, the transactionality is pretty straight forward. Each call to t... | 41895 | spring-batch | <h1>How does Spring Batch transaction management work?</h1>
<p>I'm trying to understand how Spring Batch does transaction management. This is not a technical question but more of conceptual one: what approach does Spring Batch use and what are the consequences of that approach?</p>
<p>Let me try to clarify this questi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,731 | cmd | # How does Spring Batch transaction management work?
I'm trying to understand how Spring Batch does transaction management. This is not a technical question but more of conceptual one: what approach does Spring Batch use and what are the consequences of that approach?
Let me try to clarify this question a bit. For in... | There are two fundamental types of steps in Spring Batch, a Tasklet Step and a chunk based step. Each has it's own transaction details. Let's look at each:
**Tasklet Based Step**
When a developer implements their own tasklet, the transactionality is pretty straight forward. Each call to the `Tasklet#execute` method ... |
21711180 | How to list all folder with size via batch file | 19 | 2014-02-11 19:26:07 | <p>I want a simple solution for list of folders and size of them in either txt or csv format.</p>
<p>I use this code for folder list</p>
<pre><code>dir C:\Temp\*.* /b /a:d > C:\folderList.txt
</code></pre>
<p>current output</p>
<pre><code><<folderList.txt>>
folder1
folder2
folder3
</code></pre>
<p>d... | 90,169 | 2,355,899 | 2018-08-23 05:54:42 | 21,712,766 | 25 | 2014-02-11 20:52:35 | 2,861,476 | 2014-02-12 10:45:33 | https://stackoverflow.com/q/21711180 | https://stackoverflow.com/a/21712766 | <p>For each folder in the list, use <code>dir</code> command to retrieve the size of the files under the folder</p>
<pre><code>@echo off
setlocal disabledelayedexpansion
set "folder=%~1"
if not defined folder set "folder=%cd%"
for /d %%a in ("%folder%\*") do (
set "size=0"
for /f "tok... | <p>For each folder in the list, use <code>dir</code> command to retrieve the size of the files under the folder</p> <pre><code>@echo off setlocal disabledelayedexpansion set "folder=%~1" if not defined folder set "folder=%cd%" for /d %%a in ("%folder%\*") do ( set "size=0" for /f "tok... | 64, 218, 314, 7002, 14208 | batch-file, dir, directory, size, windows | <h1>How to list all folder with size via batch file</h1>
<p>I want a simple solution for list of folders and size of them in either txt or csv format.</p>
<p>I use this code for folder list</p>
<pre><code>dir C:\Temp\*.* /b /a:d > C:\folderList.txt
</code></pre>
<p>current output</p>
<pre><code><<folderLis... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,732 | cmd | # How to list all folder with size via batch file
I want a simple solution for list of folders and size of them in either txt or csv format.
I use this code for folder list
```
dir C:\Temp\*.* /b /a:d > C:\folderList.txt
```
current output
```
<<folderList.txt>>
folder1
folder2
folder3
```
desired output
```
<<f... | For each folder in the list, use `dir` command to retrieve the size of the files under the folder
```
@echo off
setlocal disabledelayedexpansion
set "folder=%~1"
if not defined folder set "folder=%cd%"
for /d %%a in ("%folder%\*") do (
set "size=0"
for /f "tokens=3,5" %%b in ('dir /-c... |
6487766 | How to start 2 programs simultaneously in windows command prompt | 18 | 2011-06-27 01:00:42 | <p>I am using Windows 7 64bit</p>
<p>Here is the code snippet I am using to start</p>
<pre><code>@echo off
call "C:\Program Files (x86)\LOLReplay\LOLRecorder.exe"
call "G:\League of Legends\lol.launcher.exe"
exit
</code></pre>
<p>But unless I close LOLRecorder.exe it won't start my lol.launcher.exe.... basically I w... | 44,648 | 728,863 | 2023-08-25 14:08:22 | 6,487,961 | 25 | 2011-06-27 01:55:11 | 232,593 | 2011-06-27 01:55:11 | https://stackoverflow.com/q/6487766 | https://stackoverflow.com/a/6487961 | <blockquote>
<p>With the start command it just starts 2 terminal windows and nothing starts!</p>
</blockquote>
<p>The problem is the quotes (which are unfortunately required, due to the spaces in the paths). The <code>start</code> command doesn't seem to like them.</p>
<p>You can work around this by using the shor... | <blockquote> <p>With the start command it just starts 2 terminal windows and nothing starts!</p> </blockquote> <p>The problem is the quotes (which are unfortunately required, due to the spaces in the paths). The <code>start</code> command doesn't seem to like them.</p> <p>You can work around this by using the shor... | 1231, 2631, 9938, 34595, 40232 | cmd, command-line, command-prompt, windows-7, windows-console | <h1>How to start 2 programs simultaneously in windows command prompt</h1>
<p>I am using Windows 7 64bit</p>
<p>Here is the code snippet I am using to start</p>
<pre><code>@echo off
call "C:\Program Files (x86)\LOLReplay\LOLRecorder.exe"
call "G:\League of Legends\lol.launcher.exe"
exit
</code></pre>
<p>But unless I ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,733 | cmd | # How to start 2 programs simultaneously in windows command prompt
I am using Windows 7 64bit
Here is the code snippet I am using to start
```
@echo off
call "C:\Program Files (x86)\LOLReplay\LOLRecorder.exe"
call "G:\League of Legends\lol.launcher.exe"
exit
```
But unless I close LOLRecorder.exe it won't start my ... | > With the start command it just starts 2 terminal windows and nothing starts!
The problem is the quotes (which are unfortunately required, due to the spaces in the paths). The `start` command doesn't seem to like them.
You can work around this by using the short DOS names for all the directories (and remove quotes),... |
23557720 | Execute Batch File without Command line visible | 16 | 2014-05-09 06:09:41 | <p>I have to run a batch file without showing the command line but the Command line keeps on popping up. This is my code: </p>
<pre><code>@echo off
:SAMPLE
cd /d C:
md %RANDOM%
cd /d D:
md %RANDOM%
cd /d E:
md %RANDOM%
goto SAMPLE
</code></pre>
| 59,355 | 2,747,210 | 2018-06-21 08:29:57 | 23,558,301 | 25 | 2014-05-09 06:52:32 | 2,746,670 | 2014-05-09 07:15:43 | https://stackoverflow.com/q/23557720 | https://stackoverflow.com/a/23558301 | <p><strong>Solution-1</strong>:</p>
<p>Save your code in a batch file lets say <code>My.bat</code></p>
<p>Create a VBScript file lets say <code>Master.vbs</code> and call your <code>My.bat</code> file within it.</p>
<p>Lets assume your batch file is at <code>C:\Test\My.bat</code> then:</p>
<p><strong>Master.vbs:</s... | <p><strong>Solution-1</strong>:</p> <p>Save your code in a batch file lets say <code>My.bat</code></p> <p>Create a VBScript file lets say <code>Master.vbs</code> and call your <code>My.bat</code> file within it.</p> <p>Lets assume your batch file is at <code>C:\Test\My.bat</code> then:</p> <p><strong>Master.vbs:</s... | 2631, 7002 | batch-file, cmd | <h1>Execute Batch File without Command line visible</h1>
<p>I have to run a batch file without showing the command line but the Command line keeps on popping up. This is my code: </p>
<pre><code>@echo off
:SAMPLE
cd /d C:
md %RANDOM%
cd /d D:
md %RANDOM%
cd /d E:
md %RANDOM%
goto SAMPLE
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,735 | cmd | # Execute Batch File without Command line visible
I have to run a batch file without showing the command line but the Command line keeps on popping up. This is my code:
```
@echo off
:SAMPLE
cd /d C:
md %RANDOM%
cd /d D:
md %RANDOM%
cd /d E:
md %RANDOM%
goto SAMPLE
``` | **Solution-1**:
Save your code in a batch file lets say `My.bat`
Create a VBScript file lets say `Master.vbs` and call your `My.bat` file within it.
Lets assume your batch file is at `C:\Test\My.bat` then:
**Master.vbs:**
```
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\Test\My.bat" & Ch... |
20245053 | Running Microsoft Access as a Scheduled Task | 16 | 2013-11-27 14:27:57 | <p>I am seeking comments on how to schedule auto updates of a database (.accdb) since I am not very comfortable with the process I have set up.</p>
<p>Currently, it works as follow:</p>
<ol>
<li>Task Scheduler calls a .bat</li>
<li>.bat calls a .vbs</li>
<li>.vbs opens the database and calls a macro</li>
<li>The macr... | 76,422 | 2,830,928 | 2024-08-22 18:31:05 | 20,251,788 | 25 | 2013-11-27 19:50:46 | 2,144,390 | 2013-11-27 19:55:48 | https://stackoverflow.com/q/20245053 | https://stackoverflow.com/a/20251788 | <p>To the best of my knowledge the shortest path for a Windows Scheduled Task to "do something useful in Access VBA" is:</p>
<p>Create a Public Function (not Sub) in the database. For example:</p>
<pre class="lang-vbs prettyprint-override"><code>Option Compare Database
Option Explicit
Public Function WriteToTable1()... | <p>To the best of my knowledge the shortest path for a Windows Scheduled Task to "do something useful in Access VBA" is:</p> <p>Create a Public Function (not Sub) in the database. For example:</p> <pre class="lang-vbs prettyprint-override"><code>Option Compare Database Option Explicit Public Function WriteToTable1()... | 494, 930, 7002, 9187 | auto-update, batch-file, ms-access, vbscript | <h1>Running Microsoft Access as a Scheduled Task</h1>
<p>I am seeking comments on how to schedule auto updates of a database (.accdb) since I am not very comfortable with the process I have set up.</p>
<p>Currently, it works as follow:</p>
<ol>
<li>Task Scheduler calls a .bat</li>
<li>.bat calls a .vbs</li>
<li>.vbs ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,736 | cmd | # Running Microsoft Access as a Scheduled Task
I am seeking comments on how to schedule auto updates of a database (.accdb) since I am not very comfortable with the process I have set up.
Currently, it works as follow:
1. Task Scheduler calls a .bat
2. .bat calls a .vbs
3. .vbs opens the database and calls a macro
4... | To the best of my knowledge the shortest path for a Windows Scheduled Task to "do something useful in Access VBA" is:
Create a Public Function (not Sub) in the database. For example:
```
Option Compare Database
Option Explicit
Public Function WriteToTable1()
Dim cdb As DAO.Database
Set cdb = CurrentDb
cd... |
18316538 | For loop and delims in batch files | 16 | 2013-08-19 14:38:55 | <p>Can someone please help me understand command file syntax</p>
<pre><code>IF "%INPUT_PATH%"=="" (
echo Searching for latest test results in: %TEST_RESULTS%
FOR /F "delims=" %%i in ('dir /O-D /B "%TEST_RESULTS%\*.trx"') DO (
SET INPUT_PATH=%TEST_RESULTS%\%%~ni
GOTO :DoneInputPath
) )
</code></... | 84,927 | 493,957 | 2023-01-29 10:52:55 | 18,318,417 | 25 | 2013-08-19 16:15:49 | 1,012,053 | 2013-08-19 16:15:49 | https://stackoverflow.com/q/18316538 | https://stackoverflow.com/a/18318417 | <p>Most of the information you need is available in the built-in help, though it can be daunting if you are new to batch programming. For example, type <code>HELP FOR</code> or <code>FOR /?</code> from the command prompt to get help on the FOR command.</p>
<p><strong>Explanation:</strong></p>
<pre><code>FOR /F "delim... | <p>Most of the information you need is available in the built-in help, though it can be daunting if you are new to batch programming. For example, type <code>HELP FOR</code> or <code>FOR /?</code> from the command prompt to get help on the FOR command.</p> <p><strong>Explanation:</strong></p> <pre><code>FOR /F "delim... | 64, 2531, 2631, 7002 | batch-file, cmd, for-loop, windows | <h1>For loop and delims in batch files</h1>
<p>Can someone please help me understand command file syntax</p>
<pre><code>IF "%INPUT_PATH%"=="" (
echo Searching for latest test results in: %TEST_RESULTS%
FOR /F "delims=" %%i in ('dir /O-D /B "%TEST_RESULTS%\*.trx"') DO (
SET INPUT_PATH=%TEST_RESULTS%\%%~... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,737 | cmd | # For loop and delims in batch files
Can someone please help me understand command file syntax
```
IF "%INPUT_PATH%"=="" (
echo Searching for latest test results in: %TEST_RESULTS%
FOR /F "delims=" %%i in ('dir /O-D /B "%TEST_RESULTS%\*.trx"') DO (
SET INPUT_PATH=%TEST_RESULTS%\%%~ni
GOTO :Don... | Most of the information you need is available in the built-in help, though it can be daunting if you are new to batch programming. For example, type `HELP FOR` or `FOR /?` from the command prompt to get help on the FOR command.
**Explanation:**
```
FOR /F "delims=" %%i in ('dir /O-D /B "%TEST_RESULTS%\*.trx"') ...
``... |
8807118 | how to avoid cmd will be closed after a batch was executed? | 16 | 2012-01-10 16:52:00 | <p>I have a batch file with for example</p>
<pre><code>cd c:\test
</code></pre>
<p>But there is more then this in the batch, it's just an example.</p>
<p>So, if I call it from explorer, I see a cmd window for short time and then it will be closed. How can I avoid this?</p>
<p>I tried to call PAUSE at the end, but f... | 27,022 | 408,780 | 2016-05-25 09:05:54 | 8,807,497 | 25 | 2012-01-10 17:16:26 | 1,012,053 | 2012-01-10 17:16:26 | https://stackoverflow.com/q/8807118 | https://stackoverflow.com/a/8807497 | <p>I presume you are double clicking on the batch file from within Windows Explorer (or else right clicking and selecting open). If so, then you are getting the expected behavior. When you double click on any executable, the window should close once the executable completes.</p>
<p>Putting a PAUSE before the end is th... | <p>I presume you are double clicking on the batch file from within Windows Explorer (or else right clicking and selecting open). If so, then you are getting the expected behavior. When you double click on any executable, the window should close once the executable completes.</p> <p>Putting a PAUSE before the end is th... | 2631, 7002 | batch-file, cmd | <h1>how to avoid cmd will be closed after a batch was executed?</h1>
<p>I have a batch file with for example</p>
<pre><code>cd c:\test
</code></pre>
<p>But there is more then this in the batch, it's just an example.</p>
<p>So, if I call it from explorer, I see a cmd window for short time and then it will be closed. ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,738 | cmd | # how to avoid cmd will be closed after a batch was executed?
I have a batch file with for example
```
cd c:\test
```
But there is more then this in the batch, it's just an example.
So, if I call it from explorer, I see a cmd window for short time and then it will be closed. How can I avoid this?
I tried to call P... | I presume you are double clicking on the batch file from within Windows Explorer (or else right clicking and selecting open). If so, then you are getting the expected behavior. When you double click on any executable, the window should close once the executable completes.
Putting a PAUSE before the end is the appropri... |
574777 | Creating folder using bat file | 16 | 2009-02-22 11:30:04 | <p>I need to write a bat file which creates a new folder using current date and time for folder name.
I came up with the following:</p>
<pre><code>for /f "tokens=1-3 delims=:," %%i in ("%TIME%") do md %DATE%-%%i.%%j.%%k
</code></pre>
<p>Does this code has any flaws? Is there an easier / more natural way to do it?</p... | 86,559 | 69,552 | 2013-09-26 06:38:46 | 575,374 | 25 | 2009-02-22 18:18:26 | 7,903 | 2013-09-26 06:38:46 | https://stackoverflow.com/q/574777 | https://stackoverflow.com/a/575374 | <p>You can use a substring and the built-in %DATE% and %TIME% variables to do this:</p>
<pre><code>@echo OFF
:: Use date /t and time /t from the command line to get the format of your date and
:: time; change the substring below as needed.
:: This will create a timestamp like yyyy-mm-dd-hh-mm-ss.
set TIMESTAMP=%DATE... | <p>You can use a substring and the built-in %DATE% and %TIME% variables to do this:</p> <pre><code>@echo OFF :: Use date /t and time /t from the command line to get the format of your date and :: time; change the substring below as needed. :: This will create a timestamp like yyyy-mm-dd-hh-mm-ss. set TIMESTAMP=%DATE... | 7002 | batch-file | <h1>Creating folder using bat file</h1>
<p>I need to write a bat file which creates a new folder using current date and time for folder name.
I came up with the following:</p>
<pre><code>for /f "tokens=1-3 delims=:," %%i in ("%TIME%") do md %DATE%-%%i.%%j.%%k
</code></pre>
<p>Does this code has any flaws? Is there a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,739 | cmd | # Creating folder using bat file
I need to write a bat file which creates a new folder using current date and time for folder name.
I came up with the following:
```
for /f "tokens=1-3 delims=:," %%i in ("%TIME%") do md %DATE%-%%i.%%j.%%k
```
Does this code has any flaws? Is there an easier / more natural way to do ... | You can use a substring and the built-in %DATE% and %TIME% variables to do this:
```
@echo OFF
:: Use date /t and time /t from the command line to get the format of your date and
:: time; change the substring below as needed.
:: This will create a timestamp like yyyy-mm-dd-hh-mm-ss.
set TIMESTAMP=%DATE:~10,4%-%DATE:... |
37333620 | Special Characters in Batch File | 15 | 2016-05-19 20:40:20 | <p>Special characters in batch files are a pain, but I haven't found the right workaround for properly escaping the first two characters of this particular string I'm trying to pass the application.</p>
<pre><code>SET pass=^&AntiBatchfileString
A_Program.exe /pass=%pass%
</code></pre>
<p>Things I have tried:</p>
... | 76,779 | 834,579 | 2025-05-22 11:49:17 | 37,336,554 | 25 | 2016-05-20 01:29:42 | 5,047,996 | 2025-05-22 11:49:17 | https://stackoverflow.com/q/37333620 | https://stackoverflow.com/a/37336554 | <p>Supposing you want the string <code>^&AntiBatchfileString</code> literally, this is the best <code>set</code> syntax, as most special characters (<code>^</code> <code>&</code> <code>(</code> <code>)</code> <code><</code> <code>></code> <code>|</code> and also the standard delimiters <code>,</code> <cod... | <p>Supposing you want the string <code>^&AntiBatchfileString</code> literally, this is the best <code>set</code> syntax, as most special characters (<code>^</code> <code>&</code> <code>(</code> <code>)</code> <code><</code> <code>></code> <code>|</code> and also the standard delimiters <code>,</code> <cod... | 64, 2631, 4804, 7002 | batch-file, cmd, escaping, windows | <h1>Special Characters in Batch File</h1>
<p>Special characters in batch files are a pain, but I haven't found the right workaround for properly escaping the first two characters of this particular string I'm trying to pass the application.</p>
<pre><code>SET pass=^&AntiBatchfileString
A_Program.exe /pass=%pass%
<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,740 | cmd | # Special Characters in Batch File
Special characters in batch files are a pain, but I haven't found the right workaround for properly escaping the first two characters of this particular string I'm trying to pass the application.
```
SET pass=^&AntiBatchfileString
A_Program.exe /pass=%pass%
```
Things I have tried:... | Supposing you want the string `^&AntiBatchfileString` literally, this is the best `set` syntax, as most special characters (`^` `&` `(` `)` `<` `>` `|` and also the standard delimiters `,` `;` `=` `SPACE` `TAB`) lose their particular meaning as soon as they are placed in between `""`, and the `""` themselves do not bec... |
14385122 | How to kill a windows process running longer than 30 minutes | 15 | 2013-01-17 17:52:27 | <p>I basically need to achieve two things, </p>
<ol>
<li>Find all "firefox.exe" processes running on a windows server</li>
<li>Kill the ones that have been running longer than 30 mins</li>
</ol>
<p>I have bits and pieces, but not sure how to integrate all of it to make it working as a windows service.</p>
<p>What I ... | 27,674 | 895,733 | 2019-02-07 19:20:46 | 14,390,012 | 25 | 2013-01-17 23:27:09 | 514,485 | 2019-02-07 19:20:46 | https://stackoverflow.com/q/14385122 | https://stackoverflow.com/a/14390012 | <p>It's easy to think, "You can't do that in .bat". I know that was my first reaction. The problem is you need date manipulation which is not directly supported and is non-trivial. But then <a href="http://www.commandline.co.uk/index.html" rel="noreferrer">Ritchie Lawrence</a> comes to the rescue, having done all the h... | <p>It's easy to think, "You can't do that in .bat". I know that was my first reaction. The problem is you need date manipulation which is not directly supported and is non-trivial. But then <a href="http://www.commandline.co.uk/index.html" rel="noreferrer">Ritchie Lawrence</a> comes to the rescue, having done all the h... | 64, 627, 5910, 7002 | batch-file, process, service, windows | <h1>How to kill a windows process running longer than 30 minutes</h1>
<p>I basically need to achieve two things, </p>
<ol>
<li>Find all "firefox.exe" processes running on a windows server</li>
<li>Kill the ones that have been running longer than 30 mins</li>
</ol>
<p>I have bits and pieces, but not sure how to integr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,741 | cmd | # How to kill a windows process running longer than 30 minutes
I basically need to achieve two things,
1. Find all "firefox.exe" processes running on a windows server
2. Kill the ones that have been running longer than 30 mins
I have bits and pieces, but not sure how to integrate all of it to make it working as a wi... | It's easy to think, "You can't do that in .bat". I know that was my first reaction. The problem is you need date manipulation which is not directly supported and is non-trivial. But then [Ritchie Lawrence](http://www.commandline.co.uk/index.html) comes to the rescue, having done all the hard work of writing the necessa... |
11385030 | Batch: Timestamp to UNIX Time | 15 | 2012-07-08 17:13:31 | <p>For all I know, Batch does not have a command that gives the UNIX time. The closest one I can find is <code>%time%</code>, which only displays the timestamp.</p>
<p>Is there a command, or set of commands in Batch with which you can get the UNIX time?</p>
| 33,844 | 1,220,067 | 2021-05-28 14:00:35 | 11,385,908 | 25 | 2012-07-08 19:14:19 | 1,336,150 | 2020-02-12 12:50:24 | https://stackoverflow.com/q/11385030 | https://stackoverflow.com/a/11385908 | <p>There's <a href="https://github.com/ritchielawrence/batchfunctionlibrary" rel="noreferrer">Richie Lawrence's batch library</a> that has all those nifty handy scripts. The one you need is <a href="https://github.com/ritchielawrence/batchfunctionlibrary/blob/master/Date%20and%20Time%20Functions/DateToSecs.html" rel="n... | <p>There's <a href="https://github.com/ritchielawrence/batchfunctionlibrary" rel="noreferrer">Richie Lawrence's batch library</a> that has all those nifty handy scripts. The one you need is <a href="https://github.com/ritchielawrence/batchfunctionlibrary/blob/master/Date%20and%20Time%20Functions/DateToSecs.html" rel="n... | 7002, 32842 | batch-file, unix-timestamp | <h1>Batch: Timestamp to UNIX Time</h1>
<p>For all I know, Batch does not have a command that gives the UNIX time. The closest one I can find is <code>%time%</code>, which only displays the timestamp.</p>
<p>Is there a command, or set of commands in Batch with which you can get the UNIX time?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10 | 12,742 | cmd | # Batch: Timestamp to UNIX Time
For all I know, Batch does not have a command that gives the UNIX time. The closest one I can find is `%time%`, which only displays the timestamp.
Is there a command, or set of commands in Batch with which you can get the UNIX time? | There's [Richie Lawrence's batch library](https://github.com/ritchielawrence/batchfunctionlibrary) that has all those nifty handy scripts. The one you need is [DateToSec](https://github.com/ritchielawrence/batchfunctionlibrary/blob/master/Date%20and%20Time%20Functions/DateToSecs.html) (which uses [GetDate](https://gith... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.