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
4756203
How to delete files recursively
36
2011-01-21 06:55:19
<p>I have the directory structure /foo/bar/fooBar/.. . I want to write a Windows command where I can mention the path till foo directory and it deletes all the files and directory recursively in /foo, but it should NOT delete the foo directory.</p> <p>I have been using <code>rmdir /q /s [path to foo]</code> but this ...
100,110
367,097
2017-02-16 14:49:44
4,756,250
50
2011-01-21 07:02:44
4,086
2011-01-21 07:02:44
https://stackoverflow.com/q/4756203
https://stackoverflow.com/a/4756250
<pre><code>rd /s /q /path/to/foo md /path/to/foo </code></pre>
<pre><code>rd /s /q /path/to/foo md /path/to/foo </code></pre>
64, 2631
cmd, windows
<h1>How to delete files recursively</h1> <p>I have the directory structure /foo/bar/fooBar/.. . I want to write a Windows command where I can mention the path till foo directory and it deletes all the files and directory recursively in /foo, but it should NOT delete the foo directory.</p> <p>I have been using <code>r...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,303
cmd
# How to delete files recursively I have the directory structure /foo/bar/fooBar/.. . I want to write a Windows command where I can mention the path till foo directory and it deletes all the files and directory recursively in /foo, but it should NOT delete the foo directory. I have been using `rmdir /q /s [path to fo...
``` rd /s /q /path/to/foo md /path/to/foo ```
3729187
How to open file with default application in cmd?
35
2010-09-16 17:35:04
<p>I'm trying to open a file in it's default editor after the user has created the file. So far my script is:</p> <pre><code>@echo off @echo --- Create A New File --- @echo - @echo Where should we put the new file? set /p fileLocation=@ %UserProfile%\ @echo - @echo What do you want to call your new file? set /p fileNa...
43,321
363,551
2022-06-04 15:33:21
3,729,202
50
2010-09-16 17:36:45
422,597
2022-06-04 15:33:21
https://stackoverflow.com/q/3729187
https://stackoverflow.com/a/3729202
<p>You can use <code>start</code> to open the file with the associated application.</p> <hr /> <p><strong>Resources :</strong></p> <ul> <li><a href="http://web.archive.org/web/20101030061633/http://frank.neatstep.com/node/84" rel="noreferrer">Open a File in the Default Application using the Windows Command Line (withou...
<p>You can use <code>start</code> to open the file with the associated application.</p> <hr /> <p><strong>Resources :</strong></p> <ul> <li><a href="http://web.archive.org/web/20101030061633/http://frank.neatstep.com/node/84" rel="noreferrer">Open a File in the Default Application using the Windows Command Line (withou...
64, 2631, 7002
batch-file, cmd, windows
<h1>How to open file with default application in cmd?</h1> <p>I'm trying to open a file in it's default editor after the user has created the file. So far my script is:</p> <pre><code>@echo off @echo --- Create A New File --- @echo - @echo Where should we put the new file? set /p fileLocation=@ %UserProfile%\ @echo - ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,304
cmd
# How to open file with default application in cmd? I'm trying to open a file in it's default editor after the user has created the file. So far my script is: ``` @echo off @echo --- Create A New File --- @echo - @echo Where should we put the new file? set /p fileLocation=@ %UserProfile%\ @echo - @echo What do you wa...
You can use `start` to open the file with the associated application. --- **Resources :** - [Open a File in the Default Application using the Windows Command Line (without JDIC)](http://web.archive.org/web/20101030061633/http://frank.neatstep.com/node/84) (waybackmachine capture from Oct 30, 2010)
27238746
How to load all files of a folder to a list of Resources in Spring?
28
2014-12-01 22:43:39
<p>I have a folder and want to load all txt files to a list using Spring and wildcards:</p> <p>By annotation I could do the following:</p> <pre><code>@Value("classpath*:../../dir/*.txt") private Resource[] files; </code></pre> <p>But how can I achieve the same using spring programmatically?</p>
36,094
1,194,415
2022-05-14 15:02:06
27,239,061
50
2014-12-01 23:08:58
1,160,445
2022-05-14 15:02:06
https://stackoverflow.com/q/27238746
https://stackoverflow.com/a/27239061
<p>Use <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/io/ResourceLoader.html" rel="noreferrer">ResourceLoader</a> and <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/io/support/ResourcePatternUtils.html" rel="noreferrer">ResourcePatternUti...
<p>Use <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/io/ResourceLoader.html" rel="noreferrer">ResourceLoader</a> and <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/io/support/ResourcePatternUtils.html" rel="noreferrer">ResourcePatternUti...
17, 1211, 41895
java, spring, spring-batch
<h1>How to load all files of a folder to a list of Resources in Spring?</h1> <p>I have a folder and want to load all txt files to a list using Spring and wildcards:</p> <p>By annotation I could do the following:</p> <pre><code>@Value("classpath*:../../dir/*.txt") private Resource[] files; </code></pre> <p>But how ca...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,305
cmd
# How to load all files of a folder to a list of Resources in Spring? I have a folder and want to load all txt files to a list using Spring and wildcards: By annotation I could do the following: ``` @Value("classpath*:../../dir/*.txt") private Resource[] files; ``` But how can I achieve the same using spring progra...
Use [ResourceLoader](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/io/ResourceLoader.html) and [ResourcePatternUtils](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/io/support/ResourcePatternUtils.html): ``` class Foobar { private final ResourceLoade...
6130312
Execute multiple maven project from MS bat file?
26
2011-05-25 20:12:40
<p>I need to build 3 independent maven projects using a build.bat file (because of tycho aggregation is not an option - see comments on romaintaz answer). I have tried (executed from the build folder - see below):</p> <pre><code>cd ../projectA mvn clean install -U cd .. cd ../projectB mvn clean install -U cd .. cd ../...
23,539
363,603
2019-03-29 10:06:15
6,139,219
50
2011-05-26 13:25:31
367,285
2019-03-29 10:06:15
https://stackoverflow.com/q/6130312
https://stackoverflow.com/a/6139219
<p>Use the <code>call</code> command to execute your mvn processes, like:</p> <pre><code>call mvn clean install -U </code></pre> <p>See <a href="https://ss64.com/nt/call.html" rel="nofollow noreferrer">online doc for call</a> or</p> <pre><code>help call </code></pre> <p>for further explanations on the call command....
<p>Use the <code>call</code> command to execute your mvn processes, like:</p> <pre><code>call mvn clean install -U </code></pre> <p>See <a href="https://ss64.com/nt/call.html" rel="nofollow noreferrer">online doc for call</a> or</p> <pre><code>help call </code></pre> <p>for further explanations on the call command....
7002, 41127
batch-file, maven
<h1>Execute multiple maven project from MS bat file?</h1> <p>I need to build 3 independent maven projects using a build.bat file (because of tycho aggregation is not an option - see comments on romaintaz answer). I have tried (executed from the build folder - see below):</p> <pre><code>cd ../projectA mvn clean install...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,306
cmd
# Execute multiple maven project from MS bat file? I need to build 3 independent maven projects using a build.bat file (because of tycho aggregation is not an option - see comments on romaintaz answer). I have tried (executed from the build folder - see below): ``` cd ../projectA mvn clean install -U cd .. cd ../proj...
Use the `call` command to execute your mvn processes, like: ``` call mvn clean install -U ``` See [online doc for call](https://ss64.com/nt/call.html) or ``` help call ``` for further explanations on the call command. To avoid having all these `cd` commands you can also use the `-f` option to specify the path to y...
4222045
How to edit hosts file via CMD?
26
2010-11-19 04:18:56
<p>Hello I'd like to block some websites directly from the command prompt.</p> <p>echo like this:</p> <pre><code>0.0.0.0 websitename.com </code></pre> <p>How can I do this? (OS: Windows 7)</p>
128,556
363,551
2021-11-06 08:49:53
4,222,089
50
2010-11-19 04:29:17
237,838
2013-11-27 14:44:21
https://stackoverflow.com/q/4222045
https://stackoverflow.com/a/4222089
<p><code>echo 0.0.0.0 websitename.com &gt;&gt; %WINDIR%\System32\Drivers\Etc\Hosts</code></p> <p>the <code>&gt;&gt;</code> appends the output of <code>echo</code> to the file.</p> <p>Note that there are two reasons this might not work like you want it to. You may be aware of these, but I mention them just in case.</p...
<p><code>echo 0.0.0.0 websitename.com &gt;&gt; %WINDIR%\System32\Drivers\Etc\Hosts</code></p> <p>the <code>&gt;&gt;</code> appends the output of <code>echo</code> to the file.</p> <p>Note that there are two reasons this might not work like you want it to. You may be aware of these, but I mention them just in case.</p...
2631, 6088, 34595
cmd, hosts, windows-7
<h1>How to edit hosts file via CMD?</h1> <p>Hello I'd like to block some websites directly from the command prompt.</p> <p>echo like this:</p> <pre><code>0.0.0.0 websitename.com </code></pre> <p>How can I do this? (OS: Windows 7)</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,307
cmd
# How to edit hosts file via CMD? Hello I'd like to block some websites directly from the command prompt. echo like this: ``` 0.0.0.0 websitename.com ``` How can I do this? (OS: Windows 7)
`echo 0.0.0.0 websitename.com >> %WINDIR%\System32\Drivers\Etc\Hosts` the `>>` appends the output of `echo` to the file. Note that there are two reasons this might not work like you want it to. You may be aware of these, but I mention them just in case. First, it won't affect a web browser, for example, that already...
1427218
How to store the result of a command expression in a variable using bat scripts?
26
2009-09-15 13:35:23
<p>I have the command below to count all directories that that follow the pattern <code>20??????</code> :</p> <pre><code>'dir /b "20??????" | find /c "2"' </code></pre> <p>For example, if I have the following directories, the command would return 6:</p> <pre><code>20090901 20090902 20090903 20090904 20090905 2009090...
103,582
64,138
2018-08-02 18:41:53
1,427,511
50
2009-09-15 14:23:55
55,452
2016-08-08 18:19:37
https://stackoverflow.com/q/1427218
https://stackoverflow.com/a/1427511
<pre><code>set cmd="dir /b "20??????" | find /c "2" " FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET X=%%i </code></pre>
<pre><code>set cmd="dir /b "20??????" | find /c "2" " FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET X=%%i </code></pre>
7002
batch-file
<h1>How to store the result of a command expression in a variable using bat scripts?</h1> <p>I have the command below to count all directories that that follow the pattern <code>20??????</code> :</p> <pre><code>'dir /b "20??????" | find /c "2"' </code></pre> <p>For example, if I have the following directories, the co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,308
cmd
# How to store the result of a command expression in a variable using bat scripts? I have the command below to count all directories that that follow the pattern `20??????` : ``` 'dir /b "20??????" | find /c "2"' ``` For example, if I have the following directories, the command would return 6: ``` 20090901 20090902...
``` set cmd="dir /b "20??????" | find /c "2" " FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET X=%%i ```
2227596
JDBC Batch Insert OutOfMemoryError
25
2010-02-09 08:05:21
<p>I have written a method <code>insert()</code> in which I am trying to use JDBC Batch for inserting half a million records into a MySQL database:</p> <pre class="lang-java prettyprint-override"><code>public void insert(int nameListId, String[] names) { String sql = "INSERT INTO name_list_subscribers (name_list_i...
20,093
162,461
2020-01-14 13:26:54
2,227,712
50
2010-02-09 08:34:51
21,234
2010-02-09 08:34:51
https://stackoverflow.com/q/2227596
https://stackoverflow.com/a/2227712
<p><code>addBatch</code> and <code>executeBatch</code> give you the mechanism to perform batch inserts, but you still need to do the batching algorithm yourself.</p> <p>If you simply pile every statement into the same batch, as you are doing, then you'll run out of memory. You need to execute/clear the batch every <c...
<p><code>addBatch</code> and <code>executeBatch</code> give you the mechanism to perform batch inserts, but you still need to do the batching algorithm yourself.</p> <p>If you simply pile every statement into the same batch, as you are doing, then you'll run out of memory. You need to execute/clear the batch every <c...
5617, 6479, 7002, 9511
batch-file, jdbc, large-data-volumes, out-of-memory
<h1>JDBC Batch Insert OutOfMemoryError</h1> <p>I have written a method <code>insert()</code> in which I am trying to use JDBC Batch for inserting half a million records into a MySQL database:</p> <pre class="lang-java prettyprint-override"><code>public void insert(int nameListId, String[] names) { String sql = "IN...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,309
cmd
# JDBC Batch Insert OutOfMemoryError I have written a method `insert()` in which I am trying to use JDBC Batch for inserting half a million records into a MySQL database: ``` public void insert(int nameListId, String[] names) { String sql = "INSERT INTO name_list_subscribers (name_list_id, name, date_added)" + ...
`addBatch` and `executeBatch` give you the mechanism to perform batch inserts, but you still need to do the batching algorithm yourself. If you simply pile every statement into the same batch, as you are doing, then you'll run out of memory. You need to execute/clear the batch every `n` records. The value of `n` is up...
10935693
Foolproof way to check for nonzero (error) return code in windows batch file
22
2012-06-07 16:13:09
<h1>Intro</h1> <p>There's a lot of advice out there for dealing with return codes in batch files (using the ERROLEVEL mechanism), e.g.</p> <ul> <li><a href="https://stackoverflow.com/questions/3452046/get-error-code-from-within-a-batch-file">Get error code from within a batch file</a></li> <li><a href="https://stacko...
37,685
116,891
2022-01-08 08:12:42
10,936,093
50
2012-06-07 16:38:48
1,012,053
2016-06-03 21:42:39
https://stackoverflow.com/q/10935693
https://stackoverflow.com/a/10936093
<p>Sorry, your attempt is not even close. <code>if not errorlevel 0</code> is only true if errorlevel is negative.</p> <p>If you know that errorlevel will never be negative, then</p> <pre><code>if errorlevel 1 (echo error level is greater than 0) </code></pre> <p>If you must allow for negative errorlevel, and are no...
<p>Sorry, your attempt is not even close. <code>if not errorlevel 0</code> is only true if errorlevel is negative.</p> <p>If you know that errorlevel will never be negative, then</p> <pre><code>if errorlevel 1 (echo error level is greater than 0) </code></pre> <p>If you must allow for negative errorlevel, and are no...
64, 7002
batch-file, windows
<h1>Foolproof way to check for nonzero (error) return code in windows batch file</h1> <h1>Intro</h1> <p>There's a lot of advice out there for dealing with return codes in batch files (using the ERROLEVEL mechanism), e.g.</p> <ul> <li><a href="https://stackoverflow.com/questions/3452046/get-error-code-from-within-a-ba...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,310
cmd
# Foolproof way to check for nonzero (error) return code in windows batch file # Intro There's a lot of advice out there for dealing with return codes in batch files (using the ERROLEVEL mechanism), e.g. - [Get error code from within a batch file](https://stackoverflow.com/questions/3452046/get-error-code-from-withi...
Sorry, your attempt is not even close. `if not errorlevel 0` is only true if errorlevel is negative. If you know that errorlevel will never be negative, then ``` if errorlevel 1 (echo error level is greater than 0) ``` If you must allow for negative errorlevel, and are not within a parenthesized block of code, then ...
32706000
Error in Maven build: mvn.bat not recognized
20
2015-09-21 23:18:28
<p>While trying to build a Java project under NetBeans (with an external Maven configured), I got the following error:</p> <blockquote> <p>"C:\Users......\bin\mvn.bat"" is not recognized as an internal or external command, operable program or batch file"</p> </blockquote> <p><strong>Edit</strong>: Using Maven 3.3.3...
28,515
819,651
2023-04-16 05:29:26
32,706,001
50
2015-09-21 23:18:28
819,651
2018-03-26 16:29:17
https://stackoverflow.com/q/32706000
https://stackoverflow.com/a/32706001
<p>To solve it:</p> <ol> <li>Go to the Maven installation folder</li> <li>Go to <code>bin</code></li> <li>Make sure you can see file extensions</li> <li>Duplicate <code>mvn.cmd</code> and <code>mvnDebug.cmd</code> and rename those copies to have the extension <code>.bat</code></li> <li>Try building the project now</li...
<p>To solve it:</p> <ol> <li>Go to the Maven installation folder</li> <li>Go to <code>bin</code></li> <li>Make sure you can see file extensions</li> <li>Duplicate <code>mvn.cmd</code> and <code>mvnDebug.cmd</code> and rename those copies to have the extension <code>.bat</code></li> <li>Try building the project now</li...
17, 2176, 7002, 41127
batch-file, java, maven, netbeans
<h1>Error in Maven build: mvn.bat not recognized</h1> <p>While trying to build a Java project under NetBeans (with an external Maven configured), I got the following error:</p> <blockquote> <p>"C:\Users......\bin\mvn.bat"" is not recognized as an internal or external command, operable program or batch file"</p> </bl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,311
cmd
# Error in Maven build: mvn.bat not recognized While trying to build a Java project under NetBeans (with an external Maven configured), I got the following error: > "C:\Users......\bin\mvn.bat"" is not recognized as an internal or external command, operable program or batch file" **Edit**: Using Maven 3.3.3, Windows...
To solve it: 1. Go to the Maven installation folder 2. Go to `bin` 3. Make sure you can see file extensions 4. Duplicate `mvn.cmd` and `mvnDebug.cmd` and rename those copies to have the extension `.bat` 5. Try building the project now [source](https://netbeans.org/bugzilla/show_bug.cgi?id=251380#c1)
17743757
How to concatenate strings in windows batch file for loop?
75
2013-07-19 10:21:22
<p>I'm familiar with Unix shell scripting, but new to windows scripting. </p> <p>I have a list of strings containing str1, str2, str3...str10. I want to do like this:</p> <pre><code>for string in string_list do var = string+"xyz" svn co var end </code></pre> <p>I do found some thread describing how to concatenat...
353,323
2,288,882
2020-05-26 04:26:38
17,745,392
49
2013-07-19 11:48:36
1,630,171
2019-02-15 17:11:31
https://stackoverflow.com/q/17743757
https://stackoverflow.com/a/17745392
<p>In batch you could do it like this:</p> <pre><code>@echo off setlocal EnableDelayedExpansion set "string_list=str1 str2 str3 ... str10" for %%s in (%string_list%) do ( set "var=%%sxyz" svn co "!var!" ) </code></pre> <p>If you don't need the variable <code>!var!</code> elsewhere in the loop, you could simpli...
<p>In batch you could do it like this:</p> <pre><code>@echo off setlocal EnableDelayedExpansion set "string_list=str1 str2 str3 ... str10" for %%s in (%string_list%) do ( set "var=%%sxyz" svn co "!var!" ) </code></pre> <p>If you don't need the variable <code>!var!</code> elsewhere in the loop, you could simpli...
64, 7002
batch-file, windows
<h1>How to concatenate strings in windows batch file for loop?</h1> <p>I'm familiar with Unix shell scripting, but new to windows scripting. </p> <p>I have a list of strings containing str1, str2, str3...str10. I want to do like this:</p> <pre><code>for string in string_list do var = string+"xyz" svn co var end <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,312
cmd
# How to concatenate strings in windows batch file for loop? I'm familiar with Unix shell scripting, but new to windows scripting. I have a list of strings containing str1, str2, str3...str10. I want to do like this: ``` for string in string_list do var = string+"xyz" svn co var end ``` I do found some thread d...
In batch you could do it like this: ``` @echo off setlocal EnableDelayedExpansion set "string_list=str1 str2 str3 ... str10" for %%s in (%string_list%) do ( set "var=%%sxyz" svn co "!var!" ) ``` If you don't need the variable `!var!` elsewhere in the loop, you could simplify that to ``` @echo off setlocal s...
12514475
How can you create pop up messages in a batch script?
49
2012-09-20 14:10:38
<p>I need to know how to make popup messages in batch scripts <strong>without</strong> using VBScript or KiXtart or any other external scripting/programming language. I have zero clue about this... had no starting point even. I am aware of <code>NET SEND</code> but the Messenger service is disabled in my current enviro...
411,866
1,652,866
2023-07-17 23:47:40
12,516,524
49
2012-09-20 16:04:12
1,012,053
2015-12-03 13:18:01
https://stackoverflow.com/q/12514475
https://stackoverflow.com/a/12516524
<p>With regard to LittleBobbyTable's answer - NET SEND does not work on Vista or Windows 7. It has been replaced by MSG.EXE</p> <p>There is a crude solution that works on all versions of Windows - A crude popup message can be sent by STARTing a new cmd.exe window that closes once a key is pressed.</p> <pre><code>star...
<p>With regard to LittleBobbyTable's answer - NET SEND does not work on Vista or Windows 7. It has been replaced by MSG.EXE</p> <p>There is a crude solution that works on all versions of Windows - A crude popup message can be sent by STARTing a new cmd.exe window that closes once a key is pressed.</p> <pre><code>star...
7002, 7346
batch-file, popup
<h1>How can you create pop up messages in a batch script?</h1> <p>I need to know how to make popup messages in batch scripts <strong>without</strong> using VBScript or KiXtart or any other external scripting/programming language. I have zero clue about this... had no starting point even. I am aware of <code>NET SEND</c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,313
cmd
# How can you create pop up messages in a batch script? I need to know how to make popup messages in batch scripts **without** using VBScript or KiXtart or any other external scripting/programming language. I have zero clue about this... had no starting point even. I am aware of `NET SEND` but the Messenger service is...
With regard to LittleBobbyTable's answer - NET SEND does not work on Vista or Windows 7. It has been replaced by MSG.EXE There is a crude solution that works on all versions of Windows - A crude popup message can be sent by STARTing a new cmd.exe window that closes once a key is pressed. ``` start "" cmd /c "echo Hel...
21381705
Create a txt file using batch file in a specific folder
36
2014-01-27 13:05:46
<p>I am trying to create a batch file which will create a text file in a specific folder. I am able to create a text file on my desktop, but I need to create a file in a specific file path.</p> <p>For example in <code>D:/Testing</code> folder I wants to create a user defined text file.</p> <pre><code>@echo off echo...
273,162
1,926,138
2024-01-19 12:34:05
21,382,039
49
2014-01-27 13:22:45
2,861,476
2020-04-28 16:25:14
https://stackoverflow.com/q/21381705
https://stackoverflow.com/a/21382039
<p>You have it almost done. Just explicitly say where to create the file</p> <pre><code>@echo off echo.&gt;"d:\testing\dblank.txt" </code></pre> <p>This creates a file containing a blank line (CR + LF = 2 bytes).</p> <p>If you want the file empty (0 bytes)</p> <pre><code>@echo off break&gt;"d:\testing\dblank.tx...
<p>You have it almost done. Just explicitly say where to create the file</p> <pre><code>@echo off echo.&gt;"d:\testing\dblank.txt" </code></pre> <p>This creates a file containing a blank line (CR + LF = 2 bytes).</p> <p>If you want the file empty (0 bytes)</p> <pre><code>@echo off break&gt;"d:\testing\dblank.tx...
218, 6083, 7002
batch-file, creation, directory
<h1>Create a txt file using batch file in a specific folder</h1> <p>I am trying to create a batch file which will create a text file in a specific folder. I am able to create a text file on my desktop, but I need to create a file in a specific file path.</p> <p>For example in <code>D:/Testing</code> folder I wants to...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,314
cmd
# Create a txt file using batch file in a specific folder I am trying to create a batch file which will create a text file in a specific folder. I am able to create a text file on my desktop, but I need to create a file in a specific file path. For example in `D:/Testing` folder I wants to create a user defined text ...
You have it almost done. Just explicitly say where to create the file ``` @echo off echo.>"d:\testing\dblank.txt" ``` This creates a file containing a blank line (CR + LF = 2 bytes). If you want the file empty (0 bytes) ``` @echo off break>"d:\testing\dblank.txt" ```
2309968
What are "%1" and "%2" in batch files?
33
2010-02-22 09:36:46
<p>What does the following <strong>%1</strong> means (in a .bat file)?</p> <pre><code>jsmin &lt;%1 &gt;%2 </code></pre>
120,086
149,578
2010-02-22 09:42:59
2,309,971
49
2010-02-22 09:38:01
33,708
2010-02-22 09:38:01
https://stackoverflow.com/q/2309968
https://stackoverflow.com/a/2309971
<p>It represents the first command line argument passed to the batch file.</p> <p>If you run your batch file with:</p> <pre><code>myfile.bat firstArg secondArg </code></pre> <p><code>%1</code> becomes "firstArg" and <code>%2</code> becomes "secondArg" </p> <p>The related <code>shift</code> command shifts the positi...
<p>It represents the first command line argument passed to the batch file.</p> <p>If you run your batch file with:</p> <pre><code>myfile.bat firstArg secondArg </code></pre> <p><code>%1</code> becomes "firstArg" and <code>%2</code> becomes "secondArg" </p> <p>The related <code>shift</code> command shifts the positi...
64, 7002
batch-file, windows
<h1>What are "%1" and "%2" in batch files?</h1> <p>What does the following <strong>%1</strong> means (in a .bat file)?</p> <pre><code>jsmin &lt;%1 &gt;%2 </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,315
cmd
# What are "%1" and "%2" in batch files? What does the following **%1** means (in a .bat file)? ``` jsmin <%1 >%2 ```
It represents the first command line argument passed to the batch file. If you run your batch file with: ``` myfile.bat firstArg secondArg ``` `%1` becomes "firstArg" and `%2` becomes "secondArg" The related `shift` command shifts the position of arguments one to the left. Running `shift` once in a batch file will ...
18711380
Batch - copy file using relative path
32
2013-09-10 05:37:24
<p>I'm a beginner with batch. I would like to copy file in <code>\Debug\test.ext</code> into <code>..\..\new</code> by batch command.</p> <p>I tried <code>copy "\Debug\text.txt" "..\..\new"</code>, but get error "the system cannot find the file specified"</p>
94,140
2,763,626
2021-04-15 19:57:51
18,713,448
49
2013-09-10 07:55:59
2,152,082
2013-09-10 07:55:59
https://stackoverflow.com/q/18711380
https://stackoverflow.com/a/18713448
<p>if you start your path with <code>\</code>, it's an absolute, not a relative path. Try <code>copy "Debug\text.txt" "..\..\new"</code> instead</p>
<p>if you start your path with <code>\</code>, it's an absolute, not a relative path. Try <code>copy "Debug\text.txt" "..\..\new"</code> instead</p>
2631, 4710, 7002
batch-file, cmd, xcopy
<h1>Batch - copy file using relative path</h1> <p>I'm a beginner with batch. I would like to copy file in <code>\Debug\test.ext</code> into <code>..\..\new</code> by batch command.</p> <p>I tried <code>copy "\Debug\text.txt" "..\..\new"</code>, but get error "the system cannot find the file specified"</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,316
cmd
# Batch - copy file using relative path I'm a beginner with batch. I would like to copy file in `\Debug\test.ext` into `..\..\new` by batch command. I tried `copy "\Debug\text.txt" "..\..\new"`, but get error "the system cannot find the file specified"
if you start your path with `\`, it's an absolute, not a relative path. Try `copy "Debug\text.txt" "..\..\new"` instead
1243240
Drag and drop batch file for multiple files?
32
2009-08-07 06:37:00
<p>I wrote a batch file to use PngCrush to optimize a .png image when I drag and drop it onto the batch file.</p> <p>In the what's next section, I wrote about what I thought would be a good upgrade to the batch file.</p> <p><strong>My question is:</strong> is it possible to create a batch file like I did in the post,...
38,409
61,320
2018-08-21 08:28:03
1,244,045
49
2009-08-07 10:33:15
73,070
2009-08-07 12:33:33
https://stackoverflow.com/q/1243240
https://stackoverflow.com/a/1244045
<p>Yes, of course this is possible. When dragging multiple files on a batch file you get the list of dropped files as a space-separated list. You can verify this with the simple following batch:</p> <pre><code>@echo %* @pause </code></pre> <p>Now you have two options:</p> <ol> <li><p><em>PngCrush can already handle ...
<p>Yes, of course this is possible. When dragging multiple files on a batch file you get the list of dropped files as a space-separated list. You can verify this with the simple following batch:</p> <pre><code>@echo %* @pause </code></pre> <p>Now you have two options:</p> <ol> <li><p><em>PngCrush can already handle ...
543, 1383, 4985, 7002
batch-file, image, optimization, png
<h1>Drag and drop batch file for multiple files?</h1> <p>I wrote a batch file to use PngCrush to optimize a .png image when I drag and drop it onto the batch file.</p> <p>In the what's next section, I wrote about what I thought would be a good upgrade to the batch file.</p> <p><strong>My question is:</strong> is it p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,317
cmd
# Drag and drop batch file for multiple files? I wrote a batch file to use PngCrush to optimize a .png image when I drag and drop it onto the batch file. In the what's next section, I wrote about what I thought would be a good upgrade to the batch file. **My question is:** is it possible to create a batch file like ...
Yes, of course this is possible. When dragging multiple files on a batch file you get the list of dropped files as a space-separated list. You can verify this with the simple following batch: ``` @echo %* @pause ``` Now you have two options: 1. *PngCrush can already handle multiple file names given to it on the comm...
16623780
How to get windows batch's parent folder
23
2013-05-18 11:31:03
<p>I'm writing a batch file, I need to get the parent folder of this bat file. Is it possibile? NB I mean the parent folder of the batch file not of the current directory of the prompt calling that batch.</p> <p>Thanks</p>
70,011
861,646
2021-12-23 20:49:02
16,623,984
49
2013-05-18 11:55:42
2,098,699
2019-04-09 17:57:29
https://stackoverflow.com/q/16623780
https://stackoverflow.com/a/16623984
<p>The parent folder of a Batch is in the Variable <code>%~dp0</code> located. Example:</p> <pre><code>@echo off&amp;setlocal for %%i in ("%~dp0.") do set "folder=%%~fi" echo %folder% </code></pre>
<p>The parent folder of a Batch is in the Variable <code>%~dp0</code> located. Example:</p> <pre><code>@echo off&amp;setlocal for %%i in ("%~dp0.") do set "folder=%%~fi" echo %folder% </code></pre>
64, 218, 7002, 7748
batch-file, directory, parent, windows
<h1>How to get windows batch's parent folder</h1> <p>I'm writing a batch file, I need to get the parent folder of this bat file. Is it possibile? NB I mean the parent folder of the batch file not of the current directory of the prompt calling that batch.</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,318
cmd
# How to get windows batch's parent folder I'm writing a batch file, I need to get the parent folder of this bat file. Is it possibile? NB I mean the parent folder of the batch file not of the current directory of the prompt calling that batch. Thanks
The parent folder of a Batch is in the Variable `%~dp0` located. Example: ``` @echo off&setlocal for %%i in ("%~dp0.") do set "folder=%%~fi" echo %folder% ```
1039221
Forfiles Batch Script (Escaping @ character)
23
2009-06-24 15:48:33
<p>I'm working on a batch script that will let me delete files older then a set period using <a href="http://www.ss64.com/nt/forfiles.html" rel="noreferrer">forfiles</a>. For now, I'm aiming at printing the files that will be deleted.</p> <p>The forfiles invocation I'm using works flawlessly from a cmd.exe shell, but ...
73,109
108,027
2022-01-27 23:26:54
1,039,284
49
2009-06-24 15:59:00
null
2011-08-16 19:24:11
https://stackoverflow.com/q/1039221
https://stackoverflow.com/a/1039284
<p>I had the same problem until I removed the quotation marks around the directory path , like this:</p> <pre><code>forfiles /S /P r:\ /m *.bak /d -10 /c "cmd /c echo @PATH" </code></pre> <p>Hope that helps.</p>
<p>I had the same problem until I removed the quotation marks around the directory path , like this:</p> <pre><code>forfiles /S /P r:\ /m *.bak /d -10 /c "cmd /c echo @PATH" </code></pre> <p>Hope that helps.</p>
7002, 136758
batch-file, forfiles
<h1>Forfiles Batch Script (Escaping @ character)</h1> <p>I'm working on a batch script that will let me delete files older then a set period using <a href="http://www.ss64.com/nt/forfiles.html" rel="noreferrer">forfiles</a>. For now, I'm aiming at printing the files that will be deleted.</p> <p>The forfiles invocation...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,319
cmd
# Forfiles Batch Script (Escaping @ character) I'm working on a batch script that will let me delete files older then a set period using [forfiles](http://www.ss64.com/nt/forfiles.html). For now, I'm aiming at printing the files that will be deleted. The forfiles invocation I'm using works flawlessly from a cmd.exe s...
I had the same problem until I removed the quotation marks around the directory path , like this: ``` forfiles /S /P r:\ /m *.bak /d -10 /c "cmd /c echo @PATH" ``` Hope that helps.
3452046
Get error code from within a batch file
46
2010-08-10 18:12:05
<p>I have a batch file that runs a couple executables, and I want it to exit on success, but stop if the exit code &lt;> 0. How do I do this?</p>
63,973
148,041
2019-09-24 11:47:42
3,452,100
48
2010-08-10 18:20:05
163,109
2010-08-10 18:20:05
https://stackoverflow.com/q/3452046
https://stackoverflow.com/a/3452100
<p>Sounds like you'll want the "If Errorlevel" command. Assuming your executable returns a non-0 exit code on failure, you do something like:</p> <pre><code>myProgram.exe if errorlevel 1 goto somethingbad echo Success! exit :somethingbad echo Something Bad Happened. </code></pre> <p>Errorlevel checking is done as a ...
<p>Sounds like you'll want the "If Errorlevel" command. Assuming your executable returns a non-0 exit code on failure, you do something like:</p> <pre><code>myProgram.exe if errorlevel 1 goto somethingbad echo Success! exit :somethingbad echo Something Bad Happened. </code></pre> <p>Errorlevel checking is done as a ...
64, 7002, 10021
batch-file, exit-code, windows
<h1>Get error code from within a batch file</h1> <p>I have a batch file that runs a couple executables, and I want it to exit on success, but stop if the exit code &lt;> 0. How do I do this?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,320
cmd
# Get error code from within a batch file I have a batch file that runs a couple executables, and I want it to exit on success, but stop if the exit code <> 0. How do I do this?
Sounds like you'll want the "If Errorlevel" command. Assuming your executable returns a non-0 exit code on failure, you do something like: ``` myProgram.exe if errorlevel 1 goto somethingbad echo Success! exit :somethingbad echo Something Bad Happened. ``` Errorlevel checking is done as a greater-or-equal check, so a...
28197540
How to script remote SSH commands in Batch (Windows)
40
2015-01-28 16:36:22
<p>I am looking to script something in batch which will need to run remote SSH commands on Linux. I would want the output returned so I can either display it on the screen or log it.</p> <p>I tried <code>putty.exe -ssh user@host -pw password -m command_run</code>, but it doesn't return anything on my screen.</p> <p>How...
276,803
1,292,036
2025-12-18 22:22:15
28,208,665
48
2015-01-29 06:55:38
850,848
2017-12-14 06:06:36
https://stackoverflow.com/q/28197540
https://stackoverflow.com/a/28208665
<p>The <code>-m</code> switch of PuTTY takes a <em>path to a script file</em> as an argument, not a <em>command</em>.</p> <p>Reference: <a href="https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cmdline-m" rel="noreferrer">https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cm...
<p>The <code>-m</code> switch of PuTTY takes a <em>path to a script file</em> as an argument, not a <em>command</em>.</p> <p>Reference: <a href="https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cmdline-m" rel="noreferrer">https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cm...
58, 64, 386, 1768, 7002
batch-file, linux, putty, ssh, windows
<h1>How to script remote SSH commands in Batch (Windows)</h1> <p>I am looking to script something in batch which will need to run remote SSH commands on Linux. I would want the output returned so I can either display it on the screen or log it.</p> <p>I tried <code>putty.exe -ssh user@host -pw password -m command_run</...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,321
cmd
# How to script remote SSH commands in Batch (Windows) I am looking to script something in batch which will need to run remote SSH commands on Linux. I would want the output returned so I can either display it on the screen or log it. I tried `putty.exe -ssh user@host -pw password -m command_run`, but it doesn't retu...
The `-m` switch of PuTTY takes a *path to a script file* as an argument, not a *command*. Reference: <https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cmdline-m> So you have to save your command (`command_run`) to a plain text file (e.g. `c:\path\command.txt`) and pass that to PuTTY: ``` putty...
23735282
"if not exist" command in batch file
40
2014-05-19 10:22:16
<p>I need to write some code in a windows batch file.</p> <p>The interested part of this script should create a folder <strong>if this folder doesn't exist yet</strong>, but, if this folder already exists, it should <strong>NOT</strong> overwrite the content.</p> <p>I tried something like this:</p> <pre><code>if not...
284,894
2,509,085
2024-06-13 21:36:29
23,736,306
48
2014-05-19 11:14:47
2,861,476
2014-05-19 14:06:02
https://stackoverflow.com/q/23735282
https://stackoverflow.com/a/23736306
<pre><code>if not exist "%USERPROFILE%\.qgis-custom\" ( mkdir "%USERPROFILE%\.qgis-custom" 2&gt;nul if not errorlevel 1 ( xcopy "%OSGEO4W_ROOT%\qgisconfig" "%USERPROFILE%\.qgis-custom" /s /v /e ) ) </code></pre> <p>You have it almost done. The logic is correct, just some little changes. </p> <p>Th...
<pre><code>if not exist "%USERPROFILE%\.qgis-custom\" ( mkdir "%USERPROFILE%\.qgis-custom" 2&gt;nul if not errorlevel 1 ( xcopy "%OSGEO4W_ROOT%\qgisconfig" "%USERPROFILE%\.qgis-custom" /s /v /e ) ) </code></pre> <p>You have it almost done. The logic is correct, just some little changes. </p> <p>Th...
2631, 7002
batch-file, cmd
<h1>"if not exist" command in batch file</h1> <p>I need to write some code in a windows batch file.</p> <p>The interested part of this script should create a folder <strong>if this folder doesn't exist yet</strong>, but, if this folder already exists, it should <strong>NOT</strong> overwrite the content.</p> <p>I tri...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,322
cmd
# "if not exist" command in batch file I need to write some code in a windows batch file. The interested part of this script should create a folder **if this folder doesn't exist yet**, but, if this folder already exists, it should **NOT** overwrite the content. I tried something like this: ``` if not exist %USERPR...
``` if not exist "%USERPROFILE%\.qgis-custom\" ( mkdir "%USERPROFILE%\.qgis-custom" 2>nul if not errorlevel 1 ( xcopy "%OSGEO4W_ROOT%\qgisconfig" "%USERPROFILE%\.qgis-custom" /s /v /e ) ) ``` You have it almost done. The logic is correct, just some little changes. This code checks for the existenc...
19448522
Batch File Set Variable not working
30
2013-10-18 11:24:32
<p>I'm doing some simple setting of a variable in a BAT file. It's not setting the variable. There aren't any odd constructs, it's simple variable substitution using the same variable name. I reduced the BAT file to a simple proof of concept version:</p> <pre><code>set TESTVAR = "No Value" ECHO var = %TESTVAR% set TES...
88,820
923,382
2016-01-05 14:54:02
19,457,442
48
2013-10-18 19:17:46
null
2014-10-08 19:19:58
https://stackoverflow.com/q/19448522
https://stackoverflow.com/a/19457442
<p>The problem is the spaces around the equal sign. This should do what you want.</p> <pre><code>set TESTVAR="No Value" ECHO var = %TESTVAR% set TESTVAR="" ECHO var = %TESTVAR% set TESTVAR="New value" ECHO var = %TESTVAR% </code></pre>
<p>The problem is the spaces around the equal sign. This should do what you want.</p> <pre><code>set TESTVAR="No Value" ECHO var = %TESTVAR% set TESTVAR="" ECHO var = %TESTVAR% set TESTVAR="New value" ECHO var = %TESTVAR% </code></pre>
276, 7002, 8470
batch-file, set, variables
<h1>Batch File Set Variable not working</h1> <p>I'm doing some simple setting of a variable in a BAT file. It's not setting the variable. There aren't any odd constructs, it's simple variable substitution using the same variable name. I reduced the BAT file to a simple proof of concept version:</p> <pre><code>set TEST...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,323
cmd
# Batch File Set Variable not working I'm doing some simple setting of a variable in a BAT file. It's not setting the variable. There aren't any odd constructs, it's simple variable substitution using the same variable name. I reduced the BAT file to a simple proof of concept version: ``` set TESTVAR = "No Value" ECH...
The problem is the spaces around the equal sign. This should do what you want. ``` set TESTVAR="No Value" ECHO var = %TESTVAR% set TESTVAR="" ECHO var = %TESTVAR% set TESTVAR="New value" ECHO var = %TESTVAR% ```
1855009
batch echo pipe symbol causing unexpected behaviour
28
2009-12-06 10:31:08
<p>I have a variable in my batch file and it contains the pipe symbol (this one: |) so when I echo the variable I get an error about a unrecognized internal/external command.</p> <p>I need a way to either get it to echo it correctly or better yet remove everything after and including the | symbol as well as any extra ...
42,953
51,310
2021-01-22 11:30:53
1,855,020
48
2009-12-06 10:38:14
161,201
2009-12-06 10:43:22
https://stackoverflow.com/q/1855009
https://stackoverflow.com/a/1855020
<p>There are several special characters that generally must be escaped when used in Windows batch files. Here is a partial list: <code>&lt; &gt; &amp; | ^ %</code></p> <p>The escape character is <code>^</code>. So to get a literal <code>|</code>, you should do this:</p> <pre><code>echo ^| </code></pre> <p>When the...
<p>There are several special characters that generally must be escaped when used in Windows batch files. Here is a partial list: <code>&lt; &gt; &amp; | ^ %</code></p> <p>The escape character is <code>^</code>. So to get a literal <code>|</code>, you should do this:</p> <pre><code>echo ^| </code></pre> <p>When the...
7002
batch-file
<h1>batch echo pipe symbol causing unexpected behaviour</h1> <p>I have a variable in my batch file and it contains the pipe symbol (this one: |) so when I echo the variable I get an error about a unrecognized internal/external command.</p> <p>I need a way to either get it to echo it correctly or better yet remove ever...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,324
cmd
# batch echo pipe symbol causing unexpected behaviour I have a variable in my batch file and it contains the pipe symbol (this one: |) so when I echo the variable I get an error about a unrecognized internal/external command. I need a way to either get it to echo it correctly or better yet remove everything after and...
There are several special characters that generally must be escaped when used in Windows batch files. Here is a partial list: `< > & | ^ %` The escape character is `^`. So to get a literal `|`, you should do this: ``` echo ^| ``` When the special character is in a variable, it becomes a bit harder. But if you use sp...
19037339
Run Java file as Administrator with full privileges
25
2013-09-26 19:47:22
<p>I have made a Java Application and I tested it in my pc and my coined pc, so far so good... But this application is for another friend of mine that have a disco, when I "installed" my application on his pc (Windows Vista 32 bits) it didn't work, then i go searching and searching and I find out that the problem as th...
72,584
2,486,919
2018-08-23 11:20:56
22,110,928
48
2014-03-01 06:18:39
1,569,514
2018-08-23 11:20:13
https://stackoverflow.com/q/19037339
https://stackoverflow.com/a/22110928
<p>This answer is for those who are wiling to provide administrative privileges to their jars or java classes. After successfully developing an exe to edit files kept in admin. restricted directories, I have developed these steps to follow for you, hope this may help you: Things to understand: 1) Jars won't be dire...
<p>This answer is for those who are wiling to provide administrative privileges to their jars or java classes. After successfully developing an exe to edit files kept in admin. restricted directories, I have developed these steps to follow for you, hope this may help you: Things to understand: 1) Jars won't be dire...
17, 64, 5623, 7002, 18449
administrator, batch-file, java, runas, windows
<h1>Run Java file as Administrator with full privileges</h1> <p>I have made a Java Application and I tested it in my pc and my coined pc, so far so good... But this application is for another friend of mine that have a disco, when I "installed" my application on his pc (Windows Vista 32 bits) it didn't work, then i go ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,326
cmd
# Run Java file as Administrator with full privileges I have made a Java Application and I tested it in my pc and my coined pc, so far so good... But this application is for another friend of mine that have a disco, when I "installed" my application on his pc (Windows Vista 32 bits) it didn't work, then i go searching...
This answer is for those who are wiling to provide administrative privileges to their jars or java classes. After successfully developing an exe to edit files kept in admin. restricted directories, I have developed these steps to follow for you, hope this may help you: Things to understand: 1) Jars won't be directly co...
9603926
Restart an application by itself
21
2012-03-07 15:07:49
<p>I want to build my application with the function to restart itself. I found on codeproject</p> <pre><code>ProcessStartInfo Info=new ProcessStartInfo(); Info.Arguments="/C choice /C Y /N /D Y /T 3 &amp; Del "+ Application.ExecutablePath; Info.WindowStyle=ProcessWindowStyle.Hidden; Info.CreateNoWindow=...
106,359
876,724
2024-07-14 18:27:41
9,615,697
48
2012-03-08 09:54:34
799,586
2012-03-08 09:54:34
https://stackoverflow.com/q/9603926
https://stackoverflow.com/a/9615697
<p>I use similar code to the code you tried when restarting apps. I send a timed cmd command to restart the app for me like this:</p> <pre><code>ProcessStartInfo Info = new ProcessStartInfo(); Info.Arguments = "/C ping 127.0.0.1 -n 2 &amp;&amp; \"" + Application.ExecutablePath + "\""; Info.WindowStyle = ProcessWindowS...
<p>I use similar code to the code you tried when restarting apps. I send a timed cmd command to restart the app for me like this:</p> <pre><code>ProcessStartInfo Info = new ProcessStartInfo(); Info.Arguments = "/C ping 127.0.0.1 -n 2 &amp;&amp; \"" + Application.ExecutablePath + "\""; Info.WindowStyle = ProcessWindowS...
1, 9, 64, 7002, 48594
.net, application-restart, batch-file, c#, windows
<h1>Restart an application by itself</h1> <p>I want to build my application with the function to restart itself. I found on codeproject</p> <pre><code>ProcessStartInfo Info=new ProcessStartInfo(); Info.Arguments="/C choice /C Y /N /D Y /T 3 &amp; Del "+ Application.ExecutablePath; Info.WindowStyle=Proce...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,327
cmd
# Restart an application by itself I want to build my application with the function to restart itself. I found on codeproject ``` ProcessStartInfo Info=new ProcessStartInfo(); Info.Arguments="/C choice /C Y /N /D Y /T 3 & Del "+ Application.ExecutablePath; Info.WindowStyle=ProcessWindowStyle.Hidden; In...
I use similar code to the code you tried when restarting apps. I send a timed cmd command to restart the app for me like this: ``` ProcessStartInfo Info = new ProcessStartInfo(); Info.Arguments = "/C ping 127.0.0.1 -n 2 && \"" + Application.ExecutablePath + "\""; Info.WindowStyle = ProcessWindowStyle.Hidden; Info.Crea...
8612324
Is this possible to write list of file names into a text file using batch file Windows Xp?
18
2011-12-23 04:43:39
<p>I want to write the list of file names from a Given directory path in to text file whenever clicking a windows XP batch file.I don't know whether it is possible or not in Windows Xp?</p> <p>So,Can u please enlighten me on this?</p>
56,186
452,680
2018-08-15 16:06:40
8,612,328
48
2011-12-23 04:44:56
751,158
2011-12-23 04:44:56
https://stackoverflow.com/q/8612324
https://stackoverflow.com/a/8612328
<p>How about something like this?</p> <pre><code>dir /b "C:\My Path" &gt; myFiles.txt </code></pre>
<p>How about something like this?</p> <pre><code>dir /b "C:\My Path" &gt; myFiles.txt </code></pre>
2631, 7002
batch-file, cmd
<h1>Is this possible to write list of file names into a text file using batch file Windows Xp?</h1> <p>I want to write the list of file names from a Given directory path in to text file whenever clicking a windows XP batch file.I don't know whether it is possible or not in Windows Xp?</p> <p>So,Can u please enlighten ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,328
cmd
# Is this possible to write list of file names into a text file using batch file Windows Xp? I want to write the list of file names from a Given directory path in to text file whenever clicking a windows XP batch file.I don't know whether it is possible or not in Windows Xp? So,Can u please enlighten me on this?
How about something like this? ``` dir /b "C:\My Path" > myFiles.txt ```
47425520
Activate virtualenv and run .py script from .bat
71
2017-11-22 01:39:44
<p>I'd like to use Windows Task Scheduler to run a python script within a virtual environment. I'd like the Scheduler to run a .bat file that will</p> <ol> <li>activate the virtualenv</li> <li>run the script</li> </ol> <p>These steps work together from the command line, and they work individually in a .bat, but I can...
134,490
6,268,449
2026-01-09 12:00:19
47,428,897
47
2017-11-22 07:19:00
null
2019-12-17 20:59:05
https://stackoverflow.com/q/47425520
https://stackoverflow.com/a/47428897
<p>You can use an ampersand <code>&amp;</code> operator in a oneliner batch file.</p> <pre><code>call workon venv &amp; cd path/to/Python/proj &amp; python -m script.py </code></pre> <p>It will run each command after the other.</p> <p>You can also double up the ampersand to make it a conditional operator. <code>&amp...
<p>You can use an ampersand <code>&amp;</code> operator in a oneliner batch file.</p> <pre><code>call workon venv &amp; cd path/to/Python/proj &amp; python -m script.py </code></pre> <p>It will run each command after the other.</p> <p>You can also double up the ampersand to make it a conditional operator. <code>&amp...
16, 2631, 7002, 14529
batch-file, cmd, python, virtualenv
<h1>Activate virtualenv and run .py script from .bat</h1> <p>I'd like to use Windows Task Scheduler to run a python script within a virtual environment. I'd like the Scheduler to run a .bat file that will</p> <ol> <li>activate the virtualenv</li> <li>run the script</li> </ol> <p>These steps work together from the com...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,329
cmd
# Activate virtualenv and run .py script from .bat I'd like to use Windows Task Scheduler to run a python script within a virtual environment. I'd like the Scheduler to run a .bat file that will 1. activate the virtualenv 2. run the script These steps work together from the command line, and they work individually i...
You can use an ampersand `&` operator in a oneliner batch file. ``` call workon venv & cd path/to/Python/proj & python -m script.py ``` It will run each command after the other. You can also double up the ampersand to make it a conditional operator. `&&`: ``` call workon venv && cd path/to/Python/proj && python -m ...
21120465
CMD what does /im (taskkill)?
37
2014-01-14 17:51:38
<p>I just read the following command:</p> <p><code>taskkill /f /im something.exe</code></p> <p>I read that <code>/f</code> forces the task to close, but what does <code>/im</code> do?</p>
166,768
2,808,183
2018-11-03 14:42:10
21,120,526
47
2014-01-14 17:54:32
1,550,186
2014-01-14 17:54:32
https://stackoverflow.com/q/21120465
https://stackoverflow.com/a/21120526
<p>It tells <code>taskkill</code> that the next parameter <code>something.exe</code> is an image name, a.k.a executable name</p> <pre><code>C:\&gt;taskkill /? TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F] Description: This tool is used to ...
<p>It tells <code>taskkill</code> that the next parameter <code>something.exe</code> is an image name, a.k.a executable name</p> <pre><code>C:\&gt;taskkill /? TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F] Description: This tool is used to ...
2631, 12488
cmd, taskkill
<h1>CMD what does /im (taskkill)?</h1> <p>I just read the following command:</p> <p><code>taskkill /f /im something.exe</code></p> <p>I read that <code>/f</code> forces the task to close, but what does <code>/im</code> do?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,330
cmd
# CMD what does /im (taskkill)? I just read the following command: `taskkill /f /im something.exe` I read that `/f` forces the task to close, but what does `/im` do?
It tells `taskkill` that the next parameter `something.exe` is an image name, a.k.a executable name ``` C:\>taskkill /? TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F] Description: This tool is used to terminate tasks by process id (PID) or ...
38318719
Run a shortcut with a batch file
34
2016-07-12 01:38:22
<p>I am trying to set up multiple steam accounts, and you can instantly launch an account by making a shortcut for it, blah blah blah. The shortcuts works fine but I want to make a batch file to select which account to use, then launch the shortcut for that account. For some reason I can't find out how to launch a shor...
119,877
4,922,978
2020-11-10 14:36:14
38,318,765
47
2016-07-12 01:46:54
2,378,643
2016-07-12 01:46:54
https://stackoverflow.com/q/38318719
https://stackoverflow.com/a/38318765
<p>The help for <code>start</code> contains this tidbit:</p> <pre><code>START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/NODE &lt;NUMA node&gt;] [/AFFINITY &lt;hex affinity mask&gt;] [/WAIT] [/B] [command/program] ...
<p>The help for <code>start</code> contains this tidbit:</p> <pre><code>START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/NODE &lt;NUMA node&gt;] [/AFFINITY &lt;hex affinity mask&gt;] [/WAIT] [/B] [command/program] ...
64, 2631, 7002, 7201
batch-file, cmd, shortcut, windows
<h1>Run a shortcut with a batch file</h1> <p>I am trying to set up multiple steam accounts, and you can instantly launch an account by making a shortcut for it, blah blah blah. The shortcuts works fine but I want to make a batch file to select which account to use, then launch the shortcut for that account. For some re...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,331
cmd
# Run a shortcut with a batch file I am trying to set up multiple steam accounts, and you can instantly launch an account by making a shortcut for it, blah blah blah. The shortcuts works fine but I want to make a batch file to select which account to use, then launch the shortcut for that account. For some reason I ca...
The help for `start` contains this tidbit: ``` START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B] [command/program] [parameters] "title" Title t...
23089159
Why does destroy method 'close' fail for JPAPagingItemReader configured with Java config?
28
2014-04-15 16:15:10
<p>We are trying to convert our Spring-Batch jobs from XML configuration to Java configuration. We are using Spring 4.0.1.RELEASE and Spring Batch 2.2.1.RELEASE.</p> <p>After converting one job, the following warning started to appear in the log file:</p> <blockquote> <p>15-Apr-2014 09:59:26.335 [Thread-2] WARN o....
49,224
953,327
2017-04-18 16:04:54
23,089,536
47
2014-04-15 16:32:58
953,327
2017-04-18 16:04:54
https://stackoverflow.com/q/23089159
https://stackoverflow.com/a/23089536
<p><strong>TLDR;</strong></p> <p>Spring tries to automatically infer a <code>destroyMethod</code> when using Java configuration (but it does not do so when using XML configuration). To disable this automatic inference, use:</p> <p><code>@Bean(destroyMethod="")</code></p> <hr> <p>The answer is in the JavaDoc of the ...
<p><strong>TLDR;</strong></p> <p>Spring tries to automatically infer a <code>destroyMethod</code> when using Java configuration (but it does not do so when using XML configuration). To disable this automatic inference, use:</p> <p><code>@Bean(destroyMethod="")</code></p> <hr> <p>The answer is in the JavaDoc of the ...
17, 1211, 41895
java, spring, spring-batch
<h1>Why does destroy method 'close' fail for JPAPagingItemReader configured with Java config?</h1> <p>We are trying to convert our Spring-Batch jobs from XML configuration to Java configuration. We are using Spring 4.0.1.RELEASE and Spring Batch 2.2.1.RELEASE.</p> <p>After converting one job, the following warning sta...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,332
cmd
# Why does destroy method 'close' fail for JPAPagingItemReader configured with Java config? We are trying to convert our Spring-Batch jobs from XML configuration to Java configuration. We are using Spring 4.0.1.RELEASE and Spring Batch 2.2.1.RELEASE. After converting one job, the following warning started to appear i...
**TLDR;** Spring tries to automatically infer a `destroyMethod` when using Java configuration (but it does not do so when using XML configuration). To disable this automatic inference, use: `@Bean(destroyMethod="")` --- The answer is in the JavaDoc of the `@Bean` annotation; specifically on the `org.springframework...
9307512
Create a batch file with multiple options
28
2012-02-16 07:56:40
<p>Hi I want to create a <code>batch</code> which performs more than one operations. Like it should display</p> <pre><code>1.Restart 2.Shutdown 3.Close all Windows 4.Log off 5.Switch User </code></pre> <p>Then "<code>Enter your choice</code>:(<code>User Choice</code>) Then it should perform the operation</p> <p>Can ...
135,609
289,436
2019-12-16 18:29:42
9,307,766
47
2012-02-16 08:23:09
1,197,635
2012-02-16 08:23:09
https://stackoverflow.com/q/9307512
https://stackoverflow.com/a/9307766
<p>This should get you started. The CHOICE command is available in most versions of Windows but may require that you get the Windows NT 4 resource kit. The CHOICE command is available in Windows 7.</p> <pre><code>@ECHO OFF CLS ECHO 1.Restart ECHO 2.Shutdown ECHO 3.Close all Windows ECHO 4.Log off ECHO 5.Switch User ...
<p>This should get you started. The CHOICE command is available in most versions of Windows but may require that you get the Windows NT 4 resource kit. The CHOICE command is available in Windows 7.</p> <pre><code>@ECHO OFF CLS ECHO 1.Restart ECHO 2.Shutdown ECHO 3.Close all Windows ECHO 4.Log off ECHO 5.Switch User ...
2631, 7002
batch-file, cmd
<h1>Create a batch file with multiple options</h1> <p>Hi I want to create a <code>batch</code> which performs more than one operations. Like it should display</p> <pre><code>1.Restart 2.Shutdown 3.Close all Windows 4.Log off 5.Switch User </code></pre> <p>Then "<code>Enter your choice</code>:(<code>User Choice</code>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,333
cmd
# Create a batch file with multiple options Hi I want to create a `batch` which performs more than one operations. Like it should display ``` 1.Restart 2.Shutdown 3.Close all Windows 4.Log off 5.Switch User ``` Then "`Enter your choice`:(`User Choice`) Then it should perform the operation Can you help in this?
This should get you started. The CHOICE command is available in most versions of Windows but may require that you get the Windows NT 4 resource kit. The CHOICE command is available in Windows 7. ``` @ECHO OFF CLS ECHO 1.Restart ECHO 2.Shutdown ECHO 3.Close all Windows ECHO 4.Log off ECHO 5.Switch User ECHO. CHOICE /C...
31460643
How do I unzip all files in a folder using 7-zip in batch?
27
2015-07-16 17:19:40
<p>The title kind of says it all. I'm not sure how to do this, and the other post at <a href="https://stackoverflow.com/questions/18984789/unzip-all-files-in-a-folder-using-7zip-in-cmd-line/18985107#18985107">Unzip all files in a folder using 7zip in CMD line</a></p> <p>explains nothing to me very coherently. Could so...
165,564
5,116,987
2021-06-04 08:36:19
31,460,816
47
2015-07-16 17:28:48
5,097,372
2018-01-13 21:24:55
https://stackoverflow.com/q/31460643
https://stackoverflow.com/a/31460816
<p>This will unzip all zip files in the current folder(into the same folder), assuming you have installed 7zip into <code>C:\Program Files\7-Zip</code> location.</p> <p>If you have added your 7zip folder into the path, you can just enter 7z instead of the fullpath</p> <pre class="lang-sh prettyprint-override"><code>"...
<p>This will unzip all zip files in the current folder(into the same folder), assuming you have installed 7zip into <code>C:\Program Files\7-Zip</code> location.</p> <p>If you have added your 7zip folder into the path, you can just enter 7z instead of the fullpath</p> <pre class="lang-sh prettyprint-override"><code>"...
7002
batch-file
<h1>How do I unzip all files in a folder using 7-zip in batch?</h1> <p>The title kind of says it all. I'm not sure how to do this, and the other post at <a href="https://stackoverflow.com/questions/18984789/unzip-all-files-in-a-folder-using-7zip-in-cmd-line/18985107#18985107">Unzip all files in a folder using 7zip in C...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,334
cmd
# How do I unzip all files in a folder using 7-zip in batch? The title kind of says it all. I'm not sure how to do this, and the other post at [Unzip all files in a folder using 7zip in CMD line](https://stackoverflow.com/questions/18984789/unzip-all-files-in-a-folder-using-7zip-in-cmd-line/18985107#18985107) explain...
This will unzip all zip files in the current folder(into the same folder), assuming you have installed 7zip into `C:\Program Files\7-Zip` location. If you have added your 7zip folder into the path, you can just enter 7z instead of the fullpath ``` "C:\Program Files\7-Zip\7z.exe" e *.zip ```
4390732
Running ant from a batch file: Later commands don't run
27
2010-12-08 18:03:48
<p>I have a batch file that runs ant and then copies one of the files that were produced:</p> <pre><code>ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar D:\dir2\MyJar.jar </code></pre> <p>When I run the batch file, ant runs successfully, but the copy statement never happens, although it will...
10,341
7,648
2012-01-28 23:05:17
4,390,751
47
2010-12-08 18:06:41
255,756
2012-01-28 23:05:17
https://stackoverflow.com/q/4390732
https://stackoverflow.com/a/4390751
<p>I had the same problem once and the magic <code>call</code> did it.</p> <p>In that batch file of yours try:</p> <pre><code>call ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar D:\dir2\MyJar.jar </code></pre> <p>Cannot tell you why it worked, though. Guess it's Microsoft logic.</p>
<p>I had the same problem once and the magic <code>call</code> did it.</p> <p>In that batch file of yours try:</p> <pre><code>call ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar D:\dir2\MyJar.jar </code></pre> <p>Cannot tell you why it worked, though. Guess it's Microsoft logic.</p>
142, 4330, 7002
ant, batch-file, copy
<h1>Running ant from a batch file: Later commands don't run</h1> <p>I have a batch file that runs ant and then copies one of the files that were produced:</p> <pre><code>ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar D:\dir2\MyJar.jar </code></pre> <p>When I run the batch file, ant runs suc...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,335
cmd
# Running ant from a batch file: Later commands don't run I have a batch file that runs ant and then copies one of the files that were produced: ``` ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar D:\dir2\MyJar.jar ``` When I run the batch file, ant runs successfully, but the copy statement...
I had the same problem once and the magic `call` did it. In that batch file of yours try: ``` call ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar D:\dir2\MyJar.jar ``` Cannot tell you why it worked, though. Guess it's Microsoft logic.
13476663
How to check if text file contain certain text in batch?
25
2012-11-20 15:37:14
<p>I have text file in same folder as where my batch file is.<br></p> <p>so I want my batch file to read content of the text file and depending on content of that text file I want it to perform action. </p> <p>example if text file contains "Hello World" then do like Start VLC if it doesn't contain Hello World then d...
77,765
1,512,440
2021-03-15 21:06:52
13,476,936
47
2012-11-20 15:52:40
1,012,053
2016-05-02 12:55:10
https://stackoverflow.com/q/13476663
https://stackoverflow.com/a/13476936
<p>You should use either FIND or FINDSTR. Type <code>HELP FIND</code> and <code>HELP FINDSTR</code> from a command prompt to get documentation. FIND is very simple and reliable. FINDSTR is much more powerful, but also tempermental. See <a href="https://stackoverflow.com/q/8844868/1012053">What are the undocumented feat...
<p>You should use either FIND or FINDSTR. Type <code>HELP FIND</code> and <code>HELP FINDSTR</code> from a command prompt to get documentation. FIND is very simple and reliable. FINDSTR is much more powerful, but also tempermental. See <a href="https://stackoverflow.com/q/8844868/1012053">What are the undocumented feat...
7002
batch-file
<h1>How to check if text file contain certain text in batch?</h1> <p>I have text file in same folder as where my batch file is.<br></p> <p>so I want my batch file to read content of the text file and depending on content of that text file I want it to perform action. </p> <p>example if text file contains "Hello World...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,336
cmd
# How to check if text file contain certain text in batch? I have text file in same folder as where my batch file is. so I want my batch file to read content of the text file and depending on content of that text file I want it to perform action. example if text file contains "Hello World" then do like Start VLC if ...
You should use either FIND or FINDSTR. Type `HELP FIND` and `HELP FINDSTR` from a command prompt to get documentation. FIND is very simple and reliable. FINDSTR is much more powerful, but also tempermental. See [What are the undocumented features and limitations of the Windows FINDSTR command?](https://stackoverflow.co...
47385508
Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files
23
2017-11-20 05:21:32
<p>In batch I always use <code>==</code> when using the <code>if</code> command. (For example: <code>if "19"=="3" echo My computer doesnt know maths</code>)</p> <p>What about for all of the others (<code>LSS</code>, <code>LEQ</code>, <code>NEQ</code>, etc.)? Isn't there something like <code>!=</code> for <code>NEQ</co...
120,092
7,498,582
2025-12-12 12:29:21
47,385,593
47
2017-11-20 05:32:32
790,387
2021-07-22 16:07:47
https://stackoverflow.com/q/47385508
https://stackoverflow.com/a/47385593
<p>The reason operators like <code>&gt;</code> are not used is because they have special meanings in shell scripts. The <code>&gt;</code> is used to redirect output; <code>&lt;</code> used to redirect input, etc.</p> <p>The <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if" re...
<p>The reason operators like <code>&gt;</code> are not used is because they have special meanings in shell scripts. The <code>&gt;</code> is used to redirect output; <code>&lt;</code> used to redirect input, etc.</p> <p>The <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if" re...
64, 2631, 2773, 7002
batch-file, cmd, if-statement, windows
<h1>Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files</h1> <p>In batch I always use <code>==</code> when using the <code>if</code> command. (For example: <code>if "19"=="3" echo My computer doesnt know maths</code>)</p> <p>What about for all of the others (<code>LSS</code>, <code>LEQ</code>, <code>NEQ</c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,337
cmd
# Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files In batch I always use `==` when using the `if` command. (For example: `if "19"=="3" echo My computer doesnt know maths`) What about for all of the others (`LSS`, `LEQ`, `NEQ`, etc.)? Isn't there something like `!=` for `NEQ`, or am I thinking Unix? Th...
The reason operators like `>` are not used is because they have special meanings in shell scripts. The `>` is used to redirect output; `<` used to redirect input, etc. The [documentation from Microsoft](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if) lists the following operators: ...
38307449
Difference between "@echo off" and "@echo %off"?
21
2016-07-11 12:51:51
<p>At the beginning of a batch script, I saw the command:</p> <pre><code>@echo %off </code></pre> <p>To my surprise it has the same effect of:</p> <pre><code>@echo off </code></pre> <p>What is the effect of the '%' prefix?</p>
72,121
423,913
2016-07-11 13:22:43
38,308,114
47
2016-07-11 13:22:43
1,683,264
2016-07-11 13:22:43
https://stackoverflow.com/q/38307449
https://stackoverflow.com/a/38308114
<p>I've never seen it before. It doesn't work in the cmd console -- only in a .bat script. But I have a guess.</p> <p>In a cmd console window if you <code>@echo off</code>, that results in command prompts being hidden, just like it does in a .bat script. To reveal the prompts again, you have to <code>echo on</code>....
<p>I've never seen it before. It doesn't work in the cmd console -- only in a .bat script. But I have a guess.</p> <p>In a cmd console window if you <code>@echo off</code>, that results in command prompts being hidden, just like it does in a .bat script. To reveal the prompts again, you have to <code>echo on</code>....
7002
batch-file
<h1>Difference between "@echo off" and "@echo %off"?</h1> <p>At the beginning of a batch script, I saw the command:</p> <pre><code>@echo %off </code></pre> <p>To my surprise it has the same effect of:</p> <pre><code>@echo off </code></pre> <p>What is the effect of the '%' prefix?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,338
cmd
# Difference between "@echo off" and "@echo %off"? At the beginning of a batch script, I saw the command: ``` @echo %off ``` To my surprise it has the same effect of: ``` @echo off ``` What is the effect of the '%' prefix?
I've never seen it before. It doesn't work in the cmd console -- only in a .bat script. But I have a guess. In a cmd console window if you `@echo off`, that results in command prompts being hidden, just like it does in a .bat script. To reveal the prompts again, you have to `echo on`. The difference is that in a .bat ...
6966558
Batch file FOR /f tokens
37
2011-08-06 11:41:15
<p>Can anyone please explain exactly how the following code works, line by line. I'm really lost. I've been trying to learn how to use the FOR command but I don't understand this.</p> <pre><code>@echo off for /f "tokens=* delims= " %%f in (myfile) do ( set line=%%f call :processToken ) goto :eof :processToke...
196,779
null
2016-07-12 06:34:58
6,966,676
46
2011-08-06 12:05:35
73,070
2011-08-06 12:23:19
https://stackoverflow.com/q/6966558
https://stackoverflow.com/a/6966676
<pre><code>for /f "tokens=* delims= " %%f in (myfile) do </code></pre> <p>This reads a file line-by-line, removing leading spaces (thanks, jeb).</p> <pre><code>set line=%%f </code></pre> <p>sets then the <code>line</code> variable to the line just read and</p> <pre><code>call :procesToken </code></pre> <p>calls a ...
<pre><code>for /f "tokens=* delims= " %%f in (myfile) do </code></pre> <p>This reads a file line-by-line, removing leading spaces (thanks, jeb).</p> <pre><code>set line=%%f </code></pre> <p>sets then the <code>line</code> variable to the line just read and</p> <pre><code>call :procesToken </code></pre> <p>calls a ...
64, 2531, 7002, 10946
batch-file, for-loop, token, windows
<h1>Batch file FOR /f tokens</h1> <p>Can anyone please explain exactly how the following code works, line by line. I'm really lost. I've been trying to learn how to use the FOR command but I don't understand this.</p> <pre><code>@echo off for /f "tokens=* delims= " %%f in (myfile) do ( set line=%%f call :processT...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,339
cmd
# Batch file FOR /f tokens Can anyone please explain exactly how the following code works, line by line. I'm really lost. I've been trying to learn how to use the FOR command but I don't understand this. ``` @echo off for /f "tokens=* delims= " %%f in (myfile) do ( set line=%%f call :processToken ) goto :eof...
``` for /f "tokens=* delims= " %%f in (myfile) do ``` This reads a file line-by-line, removing leading spaces (thanks, jeb). ``` set line=%%f ``` sets then the `line` variable to the line just read and ``` call :procesToken ``` calls a subroutine that does something with the line ``` :processToken ``` is the sta...
482678
How to capture stderr on Windows/DOS?
36
2009-01-27 08:46:41
<p>I want to capture the errors from a script into a file instead of to the screen.</p> <p>In *nix, this is done with stderr redirection, usually</p> <pre><code>echo "Error" 2&gt; errorfile.log </code></pre> <p>How do I do it in a CMD script under Windows?</p>
40,633
58,807
2015-10-09 19:42:02
483,280
46
2009-01-27 12:49:11
2,441
2009-01-27 12:49:11
https://stackoverflow.com/q/482678
https://stackoverflow.com/a/483280
<p>For example:</p> <pre><code>PSKILL NOTEPAD &gt;output.txt 2&gt;&amp;1 </code></pre> <p>This will direct stdout and stderr to a file name output.txt.</p> <p>See <a href="https://stackoverflow.com/questions/245395/underused-features-of-windows-batch-files#246691">Underused features of Windows batch files</a> for mo...
<p>For example:</p> <pre><code>PSKILL NOTEPAD &gt;output.txt 2&gt;&amp;1 </code></pre> <p>This will direct stdout and stderr to a file name output.txt.</p> <p>See <a href="https://stackoverflow.com/questions/245395/underused-features-of-windows-batch-files#246691">Underused features of Windows batch files</a> for mo...
64, 531, 2631, 7002, 19156
batch-file, cmd, scripting, stderr, windows
<h1>How to capture stderr on Windows/DOS?</h1> <p>I want to capture the errors from a script into a file instead of to the screen.</p> <p>In *nix, this is done with stderr redirection, usually</p> <pre><code>echo "Error" 2&gt; errorfile.log </code></pre> <p>How do I do it in a CMD script under 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,340
cmd
# How to capture stderr on Windows/DOS? I want to capture the errors from a script into a file instead of to the screen. In *nix, this is done with stderr redirection, usually ``` echo "Error" 2> errorfile.log ``` How do I do it in a CMD script under Windows?
For example: ``` PSKILL NOTEPAD >output.txt 2>&1 ``` This will direct stdout and stderr to a file name output.txt. See [Underused features of Windows batch files](https://stackoverflow.com/questions/245395/underused-features-of-windows-batch-files#246691) for more details.
31445330
Does Windows batch support exception handling?
34
2015-07-16 04:24:00
<p>Does Windows batch programming support exception handling? If not, is there any way to effectively emulate exception handling within batch files?</p> <p>I would like to be able to "throw an exception" anywhere within a batch script, at any CALL level, and have the CALL stack popped repeatedly until it finds an acti...
26,827
1,012,053
2017-09-21 20:04:21
31,445,372
46
2015-07-16 04:28:56
1,012,053
2016-08-16 12:07:18
https://stackoverflow.com/q/31445330
https://stackoverflow.com/a/31445372
<p>Windows batch scripting certainly does not have any formal exception handling - hardly surprising considering how primitive the language is. Never in my wildest dreams did I ever think effective exception handling could be hacked up.</p> <p>But then some amazing discoveries were made on a <a href="http://forum.scri...
<p>Windows batch scripting certainly does not have any formal exception handling - hardly surprising considering how primitive the language is. Never in my wildest dreams did I ever think effective exception handling could be hacked up.</p> <p>But then some amazing discoveries were made on a <a href="http://forum.scri...
2631, 5142, 7002
batch-file, cmd, exception
<h1>Does Windows batch support exception handling?</h1> <p>Does Windows batch programming support exception handling? If not, is there any way to effectively emulate exception handling within batch files?</p> <p>I would like to be able to "throw an exception" anywhere within a batch script, at any CALL level, and have...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,341
cmd
# Does Windows batch support exception handling? Does Windows batch programming support exception handling? If not, is there any way to effectively emulate exception handling within batch files? I would like to be able to "throw an exception" anywhere within a batch script, at any CALL level, and have the CALL stack ...
Windows batch scripting certainly does not have any formal exception handling - hardly surprising considering how primitive the language is. Never in my wildest dreams did I ever think effective exception handling could be hacked up. But then some amazing discoveries were made on a [Russian site](http://forum.script-c...
11004731
Output of tree in command prompt
32
2012-06-12 20:55:00
<p>I was hoping to be able to use the </p> <pre><code>tree /F /A &gt; "desktop"\file.txt </code></pre> <p>command to output only text files. Currently as is, it outputs every file extension. </p> <p>Does anyone know of an easy way to do this?</p>
106,054
1,429,443
2023-05-06 22:40:59
11,004,774
46
2012-06-12 20:58:22
62,576
2012-06-12 20:58:22
https://stackoverflow.com/q/11004731
https://stackoverflow.com/a/11004774
<p><code>Tree</code> accepts only a few command line parameters:</p> <pre><code>c:\&gt;Tree /? Graphically displays the folder structure of a drive or path. TREE [drive:][path] [/F] [/A] /F Display the names of the files in each folder. /A Use ASCII instead of extended characters. </code></pre> <p>None of...
<p><code>Tree</code> accepts only a few command line parameters:</p> <pre><code>c:\&gt;Tree /? Graphically displays the folder structure of a drive or path. TREE [drive:][path] [/F] [/A] /F Display the names of the files in each folder. /A Use ASCII instead of extended characters. </code></pre> <p>None of...
572, 2631
cmd, tree
<h1>Output of tree in command prompt</h1> <p>I was hoping to be able to use the </p> <pre><code>tree /F /A &gt; "desktop"\file.txt </code></pre> <p>command to output only text files. Currently as is, it outputs every file extension. </p> <p>Does anyone know of an easy way to do this?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,342
cmd
# Output of tree in command prompt I was hoping to be able to use the ``` tree /F /A > "desktop"\file.txt ``` command to output only text files. Currently as is, it outputs every file extension. Does anyone know of an easy way to do this?
`Tree` accepts only a few command line parameters: ``` c:\>Tree /? Graphically displays the folder structure of a drive or path. TREE [drive:][path] [/F] [/A] /F Display the names of the files in each folder. /A Use ASCII instead of extended characters. ``` None of the indicated parameters are a file mask...
1951584
Why do I get "the syntax of the command is incorrect" when writing if conditions with no braces?
31
2009-12-23 09:18:02
<pre><code>@echo off SET var1=&quot;Yes&quot; SET var2=&quot;No&quot; SET var3=&quot;Yes&quot; if %var1%==&quot;Yes&quot; echo Var1 set if %var2%==&quot;Yes&quot; echo Var2 set if %var3%==&quot;Yes&quot; echo Var3 set </code></pre> <p>If I run the above script I get the following error. Can anyone pls help?...
139,092
139,909
2025-06-05 13:26:29
1,951,593
46
2009-12-23 09:21:26
14,860
2009-12-23 09:21:26
https://stackoverflow.com/q/1951584
https://stackoverflow.com/a/1951593
<p>The echo needs to either be at the end of the if statement:</p> <pre><code>if %var1%=="Yes" echo Var1 set </code></pre> <p>or of the following form:</p> <pre><code>if %var1%=="Yes" ( echo Var1 set ) </code></pre> <p>I tend to use the former for very simple conditionals and the latter for multi-command ones a...
<p>The echo needs to either be at the end of the if statement:</p> <pre><code>if %var1%=="Yes" echo Var1 set </code></pre> <p>or of the following form:</p> <pre><code>if %var1%=="Yes" ( echo Var1 set ) </code></pre> <p>I tend to use the former for very simple conditionals and the latter for multi-command ones a...
64, 7002
batch-file, windows
<h1>Why do I get "the syntax of the command is incorrect" when writing if conditions with no braces?</h1> <pre><code>@echo off SET var1=&quot;Yes&quot; SET var2=&quot;No&quot; SET var3=&quot;Yes&quot; if %var1%==&quot;Yes&quot; echo Var1 set if %var2%==&quot;Yes&quot; echo Var2 set if %var3%==&quot;Yes&quot; ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,343
cmd
# Why do I get "the syntax of the command is incorrect" when writing if conditions with no braces? ``` @echo off SET var1="Yes" SET var2="No" SET var3="Yes" if %var1%=="Yes" echo Var1 set if %var2%=="Yes" echo Var2 set if %var3%=="Yes" echo Var3 set ``` If I run the above script I get the following error....
The echo needs to either be at the end of the if statement: ``` if %var1%=="Yes" echo Var1 set ``` or of the following form: ``` if %var1%=="Yes" ( echo Var1 set ) ``` I tend to use the former for very simple conditionals and the latter for multi-command ones and primitive `while` statements: ``` :while1 i...
32307870
Add a timeout between two batch command lines in Jenkins
29
2015-08-31 09:22:03
<p>This is the code I want to launch with Jenkins :</p> <pre><code>start cmd.exe /k "node "C:\Program Files\Appium\node_modules\appium\bin\appium.js" -a 127.0.0.1 -p 4723" ping 127.0.0.1 -n 30 &gt; nul C:\path\NUnit-2.6.4\NUnit-2.6.4\bin\nunit-console.exe C:\path\NUnit-2.6.4\NUnit-2.6.4\bin\apk\UnitTestProject1.dll </...
46,570
4,758,940
2022-08-23 15:41:05
33,368,601
46
2015-10-27 12:57:04
5,493,701
2018-04-04 09:07:08
https://stackoverflow.com/q/32307870
https://stackoverflow.com/a/33368601
<p>I think you can use the following command in Execute Windows batch command (will wait for 100 seconds):</p> <pre><code>waitfor SomethingThatIsNeverHappening /t 100 </code></pre> <p>This will return an error which could break your build. To avoid that, redirect the error output:</p> <pre><code>waitfor SomethingTh...
<p>I think you can use the following command in Execute Windows batch command (will wait for 100 seconds):</p> <pre><code>waitfor SomethingThatIsNeverHappening /t 100 </code></pre> <p>This will return an error which could break your build. To avoid that, redirect the error output:</p> <pre><code>waitfor SomethingTh...
7002, 64999
batch-file, jenkins
<h1>Add a timeout between two batch command lines in Jenkins</h1> <p>This is the code I want to launch with Jenkins :</p> <pre><code>start cmd.exe /k "node "C:\Program Files\Appium\node_modules\appium\bin\appium.js" -a 127.0.0.1 -p 4723" ping 127.0.0.1 -n 30 &gt; nul C:\path\NUnit-2.6.4\NUnit-2.6.4\bin\nunit-console.e...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,344
cmd
# Add a timeout between two batch command lines in Jenkins This is the code I want to launch with Jenkins : ``` start cmd.exe /k "node "C:\Program Files\Appium\node_modules\appium\bin\appium.js" -a 127.0.0.1 -p 4723" ping 127.0.0.1 -n 30 > nul C:\path\NUnit-2.6.4\NUnit-2.6.4\bin\nunit-console.exe C:\path\NUnit-2.6.4\...
I think you can use the following command in Execute Windows batch command (will wait for 100 seconds): ``` waitfor SomethingThatIsNeverHappening /t 100 ``` This will return an error which could break your build. To avoid that, redirect the error output: ``` waitfor SomethingThatIsNeverHappening /t 100 2>NUL ```
28143160
How can I download a file with batch file without using any external tools?
26
2015-01-26 00:15:40
<p>First to clarify this question is aimed to HTTP(s) download .For FTP may be I'll ask (and answer) another question. Here are <a href="https://stackoverflow.com/questions/4619088/windows-batch-file-file-download-from-a-url">some similar questions</a> - but I want to be more precise .</p> <p>Besides excluding exter...
69,470
388,389
2020-11-07 10:24:17
28,143,180
46
2015-01-26 00:19:38
388,389
2020-11-07 10:24:17
https://stackoverflow.com/q/28143160
https://stackoverflow.com/a/28143180
<p>The answers.All scripts should be saved with <code>.bat</code>/<code>.cmd</code> extensions and can be used directly as batch scripts.</p> <ol> <li><p><a href="https://isc.sans.edu/forums/diary/A+Suspicious+Use+of+certutilexe/23517/" rel="nofollow noreferrer"><strong>Certutuil</strong></a> (for some reasons in the n...
<p>The answers.All scripts should be saved with <code>.bat</code>/<code>.cmd</code> extensions and can be used directly as batch scripts.</p> <ol> <li><p><a href="https://isc.sans.edu/forums/diary/A+Suspicious+Use+of+certutilexe/23517/" rel="nofollow noreferrer"><strong>Certutuil</strong></a> (for some reasons in the n...
1, 6701, 7002, 75055
.net, batch-file, jscript, wsh
<h1>How can I download a file with batch file without using any external tools?</h1> <p>First to clarify this question is aimed to HTTP(s) download .For FTP may be I'll ask (and answer) another question. Here are <a href="https://stackoverflow.com/questions/4619088/windows-batch-file-file-download-from-a-url">some sim...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,345
cmd
# How can I download a file with batch file without using any external tools? First to clarify this question is aimed to HTTP(s) download .For FTP may be I'll ask (and answer) another question. Here are [some similar questions](https://stackoverflow.com/questions/4619088/windows-batch-file-file-download-from-a-url) - ...
The answers.All scripts should be saved with `.bat`/`.cmd` extensions and can be used directly as batch scripts. 1. [**Certutuil**](https://isc.sans.edu/forums/diary/A+Suspicious+Use+of+certutilexe/23517/) (for some reasons in the newest win10 builds this is recognized as trojan thread ): certutil.exe -urlcache -s...
8177695
How to wait for a process to terminate to execute another process in batch file
66
2011-11-18 04:15:22
<p>How to wait for a process to terminate before executing another process in a batch file? Let's say I have a process <code>notepad.exe</code> that I need to kill before executing <code>wordpad.exe</code>. Then, when <code>wordpad.exe</code> is terminated, I need to launch <code>notepad.exe</code> again. How do I do ...
243,447
261,842
2025-03-26 18:26:17
8,185,270
45
2011-11-18 16:02:54
2,441
2018-10-04 11:33:21
https://stackoverflow.com/q/8177695
https://stackoverflow.com/a/8185270
<p>Try something like this...</p> <pre><code>@ECHO OFF PSKILL NOTEPAD START "" "C:\Program Files\Windows NT\Accessories\wordpad.exe" :LOOP PSLIST wordpad &gt;nul 2&gt;&amp;1 IF ERRORLEVEL 1 ( GOTO CONTINUE ) ELSE ( ECHO Wordpad is still running TIMEOUT /T 5 GOTO LOOP ) :CONTINUE NOTEPAD </code></pre> <p>I...
<p>Try something like this...</p> <pre><code>@ECHO OFF PSKILL NOTEPAD START "" "C:\Program Files\Windows NT\Accessories\wordpad.exe" :LOOP PSLIST wordpad &gt;nul 2&gt;&amp;1 IF ERRORLEVEL 1 ( GOTO CONTINUE ) ELSE ( ECHO Wordpad is still running TIMEOUT /T 5 GOTO LOOP ) :CONTINUE NOTEPAD </code></pre> <p>I...
64, 7002
batch-file, windows
<h1>How to wait for a process to terminate to execute another process in batch file</h1> <p>How to wait for a process to terminate before executing another process in a batch file? Let's say I have a process <code>notepad.exe</code> that I need to kill before executing <code>wordpad.exe</code>. Then, when <code>wordpad...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,346
cmd
# How to wait for a process to terminate to execute another process in batch file How to wait for a process to terminate before executing another process in a batch file? Let's say I have a process `notepad.exe` that I need to kill before executing `wordpad.exe`. Then, when `wordpad.exe` is terminated, I need to launc...
Try something like this... ``` @ECHO OFF PSKILL NOTEPAD START "" "C:\Program Files\Windows NT\Accessories\wordpad.exe" :LOOP PSLIST wordpad >nul 2>&1 IF ERRORLEVEL 1 ( GOTO CONTINUE ) ELSE ( ECHO Wordpad is still running TIMEOUT /T 5 GOTO LOOP ) :CONTINUE NOTEPAD ``` I used `PSLIST` and `PSEXEC`, but you ...
10202540
Rename or remove prefix for multiple files to each ones' number in Windows
43
2012-04-18 03:53:58
<p>I am trying to change all the files names in a current folder and I am trying to achieve this either by removing the files prefix (every file has a common prefix) or changing their names to their count (if there are 5 files, the filenames will be 1.txt 2.txt 3.txt 4.txt 5.txt).</p> <p>Now I have found the ren comma...
119,464
524,695
2024-11-23 14:57:33
10,202,759
45
2012-04-18 04:26:22
1,012,053
2012-04-18 13:15:50
https://stackoverflow.com/q/10202540
https://stackoverflow.com/a/10202759
<p>I don't understand why you can't use a batch file. But here is a solution that should work with most file names.</p> <p>Critical - first you must make sure you have an undefined variable name, I'll use fname</p> <pre><code>set "fname=" </code></pre> <p>Next is the command to actually do the renaming. It won't wor...
<p>I don't understand why you can't use a batch file. But here is a solution that should work with most file names.</p> <p>Critical - first you must make sure you have an undefined variable name, I'll use fname</p> <pre><code>set "fname=" </code></pre> <p>Next is the command to actually do the renaming. It won't wor...
64, 2631, 4510
cmd, rename, windows
<h1>Rename or remove prefix for multiple files to each ones' number in Windows</h1> <p>I am trying to change all the files names in a current folder and I am trying to achieve this either by removing the files prefix (every file has a common prefix) or changing their names to their count (if there are 5 files, the file...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,347
cmd
# Rename or remove prefix for multiple files to each ones' number in Windows I am trying to change all the files names in a current folder and I am trying to achieve this either by removing the files prefix (every file has a common prefix) or changing their names to their count (if there are 5 files, the filenames wil...
I don't understand why you can't use a batch file. But here is a solution that should work with most file names. Critical - first you must make sure you have an undefined variable name, I'll use fname ``` set "fname=" ``` Next is the command to actually do the renaming. It won't work properly if fname is already def...
1642677
Generate unique file name with timestamp in batch script
38
2009-10-29 10:09:16
<p>In my .bat file I want to generate a unique name for files/directories based on date-time.</p> <p>e.g.</p> <pre><code>Build-2009-10-29-10-59-00 </code></pre> <p>The problem is that <code>%TIME%</code> won't do because it contains characters that are illegal in filename (e.g. <em><code>:</code></em>).</p> <p>Is t...
82,063
11,208
2021-11-24 15:10:54
1,642,690
45
2009-10-29 10:12:38
73,070
2012-07-30 18:34:03
https://stackoverflow.com/q/1642677
https://stackoverflow.com/a/1642690
<p>EDIT: A better way of doing this is to take a date/time string that has a defined and unchanging format instead of using the locale-defined ones from <code>%date%</code> and <code>%time%</code>. You can use the following to get it:</p> <pre><code>for /f "skip=1" %%x in ('wmic os get localdatetime') do if not define...
<p>EDIT: A better way of doing this is to take a date/time string that has a defined and unchanging format instead of using the locale-defined ones from <code>%date%</code> and <code>%time%</code>. You can use the following to get it:</p> <pre><code>for /f "skip=1" %%x in ('wmic os get localdatetime') do if not define...
64, 1062, 2177, 7002
batch-file, filenames, timestamp, windows
<h1>Generate unique file name with timestamp in batch script</h1> <p>In my .bat file I want to generate a unique name for files/directories based on date-time.</p> <p>e.g.</p> <pre><code>Build-2009-10-29-10-59-00 </code></pre> <p>The problem is that <code>%TIME%</code> won't do because it contains characters that ar...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,348
cmd
# Generate unique file name with timestamp in batch script In my .bat file I want to generate a unique name for files/directories based on date-time. e.g. ``` Build-2009-10-29-10-59-00 ``` The problem is that `%TIME%` won't do because it contains characters that are illegal in filename (e.g. *`:`*). Is there somet...
EDIT: A better way of doing this is to take a date/time string that has a defined and unchanging format instead of using the locale-defined ones from `%date%` and `%time%`. You can use the following to get it: ``` for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined mydate set mydate=%%x ``` It yiel...
6780553
Prevent overwriting a file using cmd if exist
36
2011-07-21 18:02:40
<p>I am currently writing a .bat batch file that executes an installation file. Before it runs the installation file I check to see if the directory exists to avoid re-installing the application.</p> <p>I do this by using a <code>If Not Exist filename</code> statement. If the installed file doesn't exist, I then execu...
244,294
357,587
2018-10-26 23:42:42
6,780,592
45
2011-07-21 18:06:22
736,170
2011-07-21 18:06:22
https://stackoverflow.com/q/6780553
https://stackoverflow.com/a/6780592
<p>Use the FULL path to the folder in your If Not Exist code. Then you won't even have to CD anymore:</p> <pre><code>If Not Exist "C:\Documents and Settings\John\Start Menu\Programs\SoftWareFolder\" </code></pre>
<p>Use the FULL path to the folder in your If Not Exist code. Then you won't even have to CD anymore:</p> <pre><code>If Not Exist "C:\Documents and Settings\John\Start Menu\Programs\SoftWareFolder\" </code></pre>
2631, 7002, 9938
batch-file, cmd, command-prompt
<h1>Prevent overwriting a file using cmd if exist</h1> <p>I am currently writing a .bat batch file that executes an installation file. Before it runs the installation file I check to see if the directory exists to avoid re-installing the application.</p> <p>I do this by using a <code>If Not Exist filename</code> state...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,349
cmd
# Prevent overwriting a file using cmd if exist I am currently writing a .bat batch file that executes an installation file. Before it runs the installation file I check to see if the directory exists to avoid re-installing the application. I do this by using a `If Not Exist filename` statement. If the installed file...
Use the FULL path to the folder in your If Not Exist code. Then you won't even have to CD anymore: ``` If Not Exist "C:\Documents and Settings\John\Start Menu\Programs\SoftWareFolder\" ```
8485081
How do you stop a Windows Batch file from exiting early?
30
2011-12-13 06:11:36
<p>I have a windows batch file that looks similar to:</p> <pre><code>C:\DoStuff.cmd move output.bak C:\newfolder\output.bak </code></pre> <p>The problem i have is that DoStuff.cmd executes a java program that once complete exits the batch run back to the command prompt. Line 2 never gets hit.</p> <p>i have tried the...
13,525
115,749
2011-12-13 09:38:32
8,486,990
45
2011-12-13 09:38:32
356,838
2011-12-13 09:38:32
https://stackoverflow.com/q/8485081
https://stackoverflow.com/a/8486990
<p>You can use <a href="http://www.computerhope.com/call.htm" rel="noreferrer">DOS call command</a>:</p> <pre><code>@echo off call C:\DoStuff.cmd echo Exit Code = %ERRORLEVEL% </code></pre> <p>After getting error code you can proceed for example with:</p> <pre><code>if "%ERRORLEVEL%" == "1" exit /B 1 </code></pre>
<p>You can use <a href="http://www.computerhope.com/call.htm" rel="noreferrer">DOS call command</a>:</p> <pre><code>@echo off call C:\DoStuff.cmd echo Exit Code = %ERRORLEVEL% </code></pre> <p>After getting error code you can proceed for example with:</p> <pre><code>if "%ERRORLEVEL%" == "1" exit /B 1 </code></pre>
1231, 7002, 40232
batch-file, command-line, windows-console
<h1>How do you stop a Windows Batch file from exiting early?</h1> <p>I have a windows batch file that looks similar to:</p> <pre><code>C:\DoStuff.cmd move output.bak C:\newfolder\output.bak </code></pre> <p>The problem i have is that DoStuff.cmd executes a java program that once complete exits the batch run back to t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,351
cmd
# How do you stop a Windows Batch file from exiting early? I have a windows batch file that looks similar to: ``` C:\DoStuff.cmd move output.bak C:\newfolder\output.bak ``` The problem i have is that DoStuff.cmd executes a java program that once complete exits the batch run back to the command prompt. Line 2 never g...
You can use [DOS call command](http://www.computerhope.com/call.htm): ``` @echo off call C:\DoStuff.cmd echo Exit Code = %ERRORLEVEL% ``` After getting error code you can proceed for example with: ``` if "%ERRORLEVEL%" == "1" exit /B 1 ```
4871620
How to pass multiple params in batch?
26
2011-02-02 07:03:01
<p>In my batch file I want to pass multiple parameters to some other application.</p> <p>Now I do it</p> <pre><code>app.exe %1 %2 </code></pre> <p>and it can only pass two parameters, but I want to pass all the parameters that are passed to the batch(I would rather not write <em>%1 %2 %3 %4 ...</em>)</p> <p>Is ther...
46,690
30,453
2018-10-15 09:19:12
4,871,660
45
2011-02-02 07:10:04
30,453
2011-02-02 07:10:04
https://stackoverflow.com/q/4871620
https://stackoverflow.com/a/4871660
<p>There is a magic way! I knew it, but I could not remember it.</p> <p>its <code>%*</code></p>
<p>There is a magic way! I knew it, but I could not remember it.</p> <p>its <code>%*</code></p>
64, 1231, 7002
batch-file, command-line, windows
<h1>How to pass multiple params in batch?</h1> <p>In my batch file I want to pass multiple parameters to some other application.</p> <p>Now I do it</p> <pre><code>app.exe %1 %2 </code></pre> <p>and it can only pass two parameters, but I want to pass all the parameters that are passed to the batch(I would rather not ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,352
cmd
# How to pass multiple params in batch? In my batch file I want to pass multiple parameters to some other application. Now I do it ``` app.exe %1 %2 ``` and it can only pass two parameters, but I want to pass all the parameters that are passed to the batch(I would rather not write *%1 %2 %3 %4 ...*) Is there any m...
There is a magic way! I knew it, but I could not remember it. its `%*`
945527
Modify cmd.exe properties using the command prompt
26
2009-06-03 15:50:33
<p>Isn't that nicely recursive? </p> <p>I've got a portable command prompt on my external drive, and it has a nice .bat file to configure some initial settings, but I'd like more! </p> <p>Here's what I know how to set from .bat:</p> <ul> <li>Colors = (color XY) where x and y are hex digits for the predefined color...
84,328
93,221
2024-10-03 07:42:23
1,271,592
45
2009-08-13 12:13:58
null
2017-02-17 18:40:57
https://stackoverflow.com/q/945527
https://stackoverflow.com/a/1271592
<p>Regarding setting the buffer size:</p> <p>Using <code>mode con: cols=XX lines=YY</code> sets not only the window (screen) size, but the buffer size too.</p> <p>If you specify a size allowed by your system, based on available screen size, you'll see that both window and buffer dimension are set to the same value; ....
<p>Regarding setting the buffer size:</p> <p>Using <code>mode con: cols=XX lines=YY</code> sets not only the window (screen) size, but the buffer size too.</p> <p>If you specify a size allowed by your system, based on available screen size, you'll see that both window and buffer dimension are set to the same value; ....
1231, 2631, 9938
cmd, command-line, command-prompt
<h1>Modify cmd.exe properties using the command prompt</h1> <p>Isn't that nicely recursive? </p> <p>I've got a portable command prompt on my external drive, and it has a nice .bat file to configure some initial settings, but I'd like more! </p> <p>Here's what I know how to set from .bat:</p> <ul> <li>Colors = (col...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,353
cmd
# Modify cmd.exe properties using the command prompt Isn't that nicely recursive? I've got a portable command prompt on my external drive, and it has a nice .bat file to configure some initial settings, but I'd like more! Here's what I know how to set from .bat: - Colors = (color XY) where x and y are hex digits fo...
Regarding setting the buffer size: Using `mode con: cols=XX lines=YY` sets not only the window (screen) size, but the buffer size too. If you specify a size allowed by your system, based on available screen size, you'll see that both window and buffer dimension are set to the same value; .e.g: ``` mode con: cols=100...
232747
Read environment variables from file in Windows Batch (cmd.exe)
24
2008-10-24 07:29:47
<p>I'm trying to read variables from a batch file for later use in the batch script, which is a Java launcher. I'd ideally like to have the same format for the settings file on all platforms (Unix, Windows), and also be a valid Java Properties file. That is, it should look like this:</p> <pre><code>setting1=Value1 set...
37,714
22,227
2024-06-05 11:08:23
232,813
45
2008-10-24 08:17:30
13,087
2008-10-24 08:17:30
https://stackoverflow.com/q/232747
https://stackoverflow.com/a/232813
<p>You can do this in a batch file as follows:</p> <pre><code>setlocal FOR /F "tokens=*" %%i in ('type Settings.txt') do SET %%i java -Dsetting1=%setting1% ... endlocal </code></pre> <p>This reads a text file containing strings like "SETTING1=VALUE1" and calls SET to set them as environment variables.</p> <p>setloca...
<p>You can do this in a batch file as follows:</p> <pre><code>setlocal FOR /F "tokens=*" %%i in ('type Settings.txt') do SET %%i java -Dsetting1=%setting1% ... endlocal </code></pre> <p>This reads a text file containing strings like "SETTING1=VALUE1" and calls SET to set them as environment variables.</p> <p>setloca...
17, 64, 1231, 2631, 9013
cmd, command-line, environment-variables, java, windows
<h1>Read environment variables from file in Windows Batch (cmd.exe)</h1> <p>I'm trying to read variables from a batch file for later use in the batch script, which is a Java launcher. I'd ideally like to have the same format for the settings file on all platforms (Unix, Windows), and also be a valid Java Properties fil...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,355
cmd
# Read environment variables from file in Windows Batch (cmd.exe) I'm trying to read variables from a batch file for later use in the batch script, which is a Java launcher. I'd ideally like to have the same format for the settings file on all platforms (Unix, Windows), and also be a valid Java Properties file. That i...
You can do this in a batch file as follows: ``` setlocal FOR /F "tokens=*" %%i in ('type Settings.txt') do SET %%i java -Dsetting1=%setting1% ... endlocal ``` This reads a text file containing strings like "SETTING1=VALUE1" and calls SET to set them as environment variables. setlocal/endlocal are used to limit the s...
1096591
How to hide cmd window while running a batch file?
22
2009-07-08 07:22:28
<p>How to hide cmd window while running a batch file?</p> <p>I use the following code to run batch file</p> <pre><code>process = new Process(); process.StartInfo.FileName = batchFilePath; process.Start(); </code></pre>
48,196
14,118
2020-11-08 22:00:49
1,096,626
45
2009-07-08 07:35:16
124,289
2009-07-08 09:40:21
https://stackoverflow.com/q/1096591
https://stackoverflow.com/a/1096626
<p>If proc.StartInfo.UseShellExecute is <strong>false</strong>, then you are launching the process and can use:</p> <pre><code>proc.StartInfo.CreateNoWindow = true; </code></pre> <p>If proc.StartInfo.UseShellExecute is <strong>true</strong>, then the OS is launching the process and you have to provide a "hint" to the...
<p>If proc.StartInfo.UseShellExecute is <strong>false</strong>, then you are launching the process and can use:</p> <pre><code>proc.StartInfo.CreateNoWindow = true; </code></pre> <p>If proc.StartInfo.UseShellExecute is <strong>true</strong>, then the OS is launching the process and you have to provide a "hint" to the...
9, 5910, 7002
batch-file, c#, process
<h1>How to hide cmd window while running a batch file?</h1> <p>How to hide cmd window while running a batch file?</p> <p>I use the following code to run batch file</p> <pre><code>process = new Process(); process.StartInfo.FileName = batchFilePath; process.Start(); </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,356
cmd
# How to hide cmd window while running a batch file? How to hide cmd window while running a batch file? I use the following code to run batch file ``` process = new Process(); process.StartInfo.FileName = batchFilePath; process.Start(); ```
If proc.StartInfo.UseShellExecute is **false**, then you are launching the process and can use: ``` proc.StartInfo.CreateNoWindow = true; ``` If proc.StartInfo.UseShellExecute is **true**, then the OS is launching the process and you have to provide a "hint" to the process via: ``` proc.StartInfo.WindowStyle = Proce...
36733176
How do I add a gzip command to Windows CMD?
12
2016-04-20 03:15:31
<p>On a Mac, if I want to gzip a file, I just type <code>gzip</code> and then the file name. If I do this in windows, it tells me that &quot;gzip is not recognized...&quot;.</p> <p>How do I add this functionality to Windows?</p>
47,404
4,373,927
2024-04-30 12:23:28
36,733,177
45
2016-04-20 03:15:31
4,373,927
2016-04-20 03:15:31
https://stackoverflow.com/q/36733176
https://stackoverflow.com/a/36733177
<h1>How to add <code>gzip</code> to CMD</h1> <p>Step 1: Download and install <a href="https://www.cygwin.com/" rel="noreferrer">Cygwin</a></p> <p>Step 2: Click 'Start' and type <em>System Environment Variables</em></p> <p>Step 3: In the 'Advanced' tab, click 'Environment Variables...'</p> <p>Step 4: In the 'User va...
<h1>How to add <code>gzip</code> to CMD</h1> <p>Step 1: Download and install <a href="https://www.cygwin.com/" rel="noreferrer">Cygwin</a></p> <p>Step 2: Click 'Start' and type <em>System Environment Variables</em></p> <p>Step 3: In the 'Advanced' tab, click 'Environment Variables...'</p> <p>Step 4: In the 'User va...
64, 1231, 1930, 2631
cmd, command-line, gzip, windows
<h1>How do I add a gzip command to Windows CMD?</h1> <p>On a Mac, if I want to gzip a file, I just type <code>gzip</code> and then the file name. If I do this in windows, it tells me that &quot;gzip is not recognized...&quot;.</p> <p>How do I add this functionality to 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,357
cmd
# How do I add a gzip command to Windows CMD? On a Mac, if I want to gzip a file, I just type `gzip` and then the file name. If I do this in windows, it tells me that "gzip is not recognized...". How do I add this functionality to Windows?
# How to add `gzip` to CMD Step 1: Download and install [Cygwin](https://www.cygwin.com/) Step 2: Click 'Start' and type *System Environment Variables* Step 3: In the 'Advanced' tab, click 'Environment Variables...' Step 4: In the 'User variables for (user)' section, select the `Path` variable and click 'Edit...' ...
108439
How do I get the result of a command in a variable in windows?
184
2008-09-20 15:13:28
<p>I'm looking to get the result of a command as a variable in a Windows batch script (see <a href="https://stackoverflow.com/questions/58207/using-the-result-of-a-command-as-an-argument-in-bash#58214">how to get the result of a command in bash</a> for the bash scripting equivalent). A solution that will work in a .ba...
373,694
3,535
2022-05-26 13:52:51
108,615
44
2008-09-20 16:23:21
394
2021-10-25 02:41:15
https://stackoverflow.com/q/108439
https://stackoverflow.com/a/108615
<p>If you have to capture all the command output you can use a batch like this:</p> <pre><code>@ECHO OFF IF NOT &quot;%1&quot;==&quot;&quot; GOTO ADDV SET VAR= FOR /F %%I IN ('DIR *.TXT /B /O:D') DO CALL %0 %%I SET VAR GOTO END :ADDV SET VAR=%VAR%!%1 :END </code></pre> <p>All output lines are stored in VAR separated ...
<p>If you have to capture all the command output you can use a batch like this:</p> <pre><code>@ECHO OFF IF NOT &quot;%1&quot;==&quot;&quot; GOTO ADDV SET VAR= FOR /F %%I IN ('DIR *.TXT /B /O:D') DO CALL %0 %%I SET VAR GOTO END :ADDV SET VAR=%VAR%!%1 :END </code></pre> <p>All output lines are stored in VAR separated ...
64, 531, 7002
batch-file, scripting, windows
<h1>How do I get the result of a command in a variable in windows?</h1> <p>I'm looking to get the result of a command as a variable in a Windows batch script (see <a href="https://stackoverflow.com/questions/58207/using-the-result-of-a-command-as-an-argument-in-bash#58214">how to get the result of a command in bash</a>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,358
cmd
# How do I get the result of a command in a variable in windows? I'm looking to get the result of a command as a variable in a Windows batch script (see [how to get the result of a command in bash](https://stackoverflow.com/questions/58207/using-the-result-of-a-command-as-an-argument-in-bash#58214) for the bash script...
If you have to capture all the command output you can use a batch like this: ``` @ECHO OFF IF NOT "%1"=="" GOTO ADDV SET VAR= FOR /F %%I IN ('DIR *.TXT /B /O:D') DO CALL %0 %%I SET VAR GOTO END :ADDV SET VAR=%VAR%!%1 :END ``` All output lines are stored in VAR separated with "!". But if only a single-line console-...
19131029
How to get date in BAT file
51
2013-10-02 06:20:17
<p>I need to get today date in Window <code>*.bat</code> file. After it I would like to get day, month and year. How can I do this? <br/> I can't use PowerShell</p>
207,180
650,148
2025-06-23 16:19:59
19,131,148
44
2013-10-02 06:30:46
381,877
2024-03-26 09:28:19
https://stackoverflow.com/q/19131029
https://stackoverflow.com/a/19131148
<p>You get and format like this</p> <pre class="lang-dos prettyprint-override"><code>for /f &quot;tokens=1-4 delims=/ &quot; %%i in (&quot;%date%&quot;) do ( set dow=%%i set month=%%j set day=%%k set year=%%l ) set datestr=%month%_%day%_%year% echo datestr is %datestr% </code></pre> <p><strong>Note:...
<p>You get and format like this</p> <pre class="lang-dos prettyprint-override"><code>for /f &quot;tokens=1-4 delims=/ &quot; %%i in (&quot;%date%&quot;) do ( set dow=%%i set month=%%j set day=%%k set year=%%l ) set datestr=%month%_%day%_%year% echo datestr is %datestr% </code></pre> <p><strong>Note:...
64, 7002
batch-file, windows
<h1>How to get date in BAT file</h1> <p>I need to get today date in Window <code>*.bat</code> file. After it I would like to get day, month and year. How can I do this? <br/> I can't use PowerShell</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,359
cmd
# How to get date in BAT file I need to get today date in Window `*.bat` file. After it I would like to get day, month and year. How can I do this? I can't use PowerShell
You get and format like this ``` for /f "tokens=1-4 delims=/ " %%i in ("%date%") do ( set dow=%%i set month=%%j set day=%%k set year=%%l ) set datestr=%month%_%day%_%year% echo datestr is %datestr% ``` **Note: Above only works on US locale.** It assumes the output of `echo %date%` looks like this:...
20602869
Batch file to split .csv file
36
2013-12-16 03:14:46
<p>I have a very large .csv file (>500mb) and I wish to break this up into into smaller .csv files in command prompt. (Basically trying to find a linux "split" function in Windows".</p> <p>This has to be a batch script as my machine only has windows installed and requesting softwares is a pain. I came across a number ...
163,657
2,020,869
2019-04-17 10:39:16
20,603,219
44
2013-12-16 03:56:45
1,528,993
2013-12-16 05:33:57
https://stackoverflow.com/q/20602869
https://stackoverflow.com/a/20603219
<p>Try this out:</p> <pre><code>@echo off setLocal EnableDelayedExpansion set limit=20000 set file=export.csv set lineCounter=1 set filenameCounter=1 set name= set extension= for %%a in (%file%) do ( set "name=%%~na" set "extension=%%~xa" ) for /f "tokens=*" %%a in (%file%) do ( set splitFile=!name!-par...
<p>Try this out:</p> <pre><code>@echo off setLocal EnableDelayedExpansion set limit=20000 set file=export.csv set lineCounter=1 set filenameCounter=1 set name= set extension= for %%a in (%file%) do ( set "name=%%~na" set "extension=%%~xa" ) for /f "tokens=*" %%a in (%file%) do ( set splitFile=!name!-par...
64, 73, 7002, 9938
batch-file, command-prompt, csv, windows
<h1>Batch file to split .csv file</h1> <p>I have a very large .csv file (>500mb) and I wish to break this up into into smaller .csv files in command prompt. (Basically trying to find a linux "split" function in Windows".</p> <p>This has to be a batch script as my machine only has windows installed and requesting softw...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,360
cmd
# Batch file to split .csv file I have a very large .csv file (>500mb) and I wish to break this up into into smaller .csv files in command prompt. (Basically trying to find a linux "split" function in Windows". This has to be a batch script as my machine only has windows installed and requesting softwares is a pain. ...
Try this out: ``` @echo off setLocal EnableDelayedExpansion set limit=20000 set file=export.csv set lineCounter=1 set filenameCounter=1 set name= set extension= for %%a in (%file%) do ( set "name=%%~na" set "extension=%%~xa" ) for /f "tokens=*" %%a in (%file%) do ( set splitFile=!name!-part!filenameCoun...
11472843
Set up Python on Windows to not type "python" in cmd
32
2012-07-13 14:47:08
<p>How do I have to configure so that I don't have to type <code>python script.py</code> but simply <code>script.py</code> in CMD on Windows?</p> <p>I added my python directory to %PATH% that contains python.exe but still scripts are not run correctly.</p> <p>I tried it with django-admin.py Running <code>django-admin...
24,063
1,159,747
2021-12-21 08:17:36
11,473,042
44
2012-07-13 14:59:10
791,500
2019-02-01 19:53:09
https://stackoverflow.com/q/11472843
https://stackoverflow.com/a/11473042
<pre><code>C:\&gt; assoc .py=Python C:\&gt; ftype Python="C:\python27\python.exe %1 %*" </code></pre> <p>Or whatever the relevant path is - you can also set command line args using ftype.</p> <hr> <p>In order to make a command recognized without having to give the suffix (<code>.py</code>), similar to how it works f...
<pre><code>C:\&gt; assoc .py=Python C:\&gt; ftype Python="C:\python27\python.exe %1 %*" </code></pre> <p>Or whatever the relevant path is - you can also set command line args using ftype.</p> <hr> <p>In order to make a command recognized without having to give the suffix (<code>.py</code>), similar to how it works f...
16, 64, 2631, 6268
cmd, path, python, windows
<h1>Set up Python on Windows to not type "python" in cmd</h1> <p>How do I have to configure so that I don't have to type <code>python script.py</code> but simply <code>script.py</code> in CMD on Windows?</p> <p>I added my python directory to %PATH% that contains python.exe but still scripts are not run correctly.</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,361
cmd
# Set up Python on Windows to not type "python" in cmd How do I have to configure so that I don't have to type `python script.py` but simply `script.py` in CMD on Windows? I added my python directory to %PATH% that contains python.exe but still scripts are not run correctly. I tried it with django-admin.py Running `...
``` C:\> assoc .py=Python C:\> ftype Python="C:\python27\python.exe %1 %*" ``` Or whatever the relevant path is - you can also set command line args using ftype. --- In order to make a command recognized without having to give the suffix (`.py`), similar to how it works for `.exe` files, add `.py` to the semi-colon ...
18639663
How to pass command line parameters with space in Batch file
28
2013-09-05 14:57:39
<p>I need to pass parameter line <code>AB CD</code> to a batch file from the command line. This parameter refer to a file name. </p> <p>If I use use <code>AB CD</code> the script just pick the first part and return <code>Unable to find the file AB.txt</code></p> <p>If I put quote around my parameters like <code>"AB C...
96,939
1,329,758
2023-08-30 10:09:06
18,640,027
44
2013-09-05 15:12:28
2,610,019
2013-09-05 15:12:28
https://stackoverflow.com/q/18639663
https://stackoverflow.com/a/18640027
<p>you can use %~1 instead of %1</p> <p>e.g a test.bat with :</p> <pre><code>echo %~1 </code></pre> <p>then a call to <code>test "abc de"</code> will display :</p> <pre><code>abc de </code></pre>
<p>you can use %~1 instead of %1</p> <p>e.g a test.bat with :</p> <pre><code>echo %~1 </code></pre> <p>then a call to <code>test "abc de"</code> will display :</p> <pre><code>abc de </code></pre>
276, 7002
batch-file, variables
<h1>How to pass command line parameters with space in Batch file</h1> <p>I need to pass parameter line <code>AB CD</code> to a batch file from the command line. This parameter refer to a file name. </p> <p>If I use use <code>AB CD</code> the script just pick the first part and return <code>Unable to find the file AB.t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,362
cmd
# How to pass command line parameters with space in Batch file I need to pass parameter line `AB CD` to a batch file from the command line. This parameter refer to a file name. If I use use `AB CD` the script just pick the first part and return `Unable to find the file AB.txt` If I put quote around my parameters lik...
you can use %~1 instead of %1 e.g a test.bat with : ``` echo %~1 ``` then a call to `test "abc de"` will display : ``` abc de ```
2071408
how to run multiple batch files in serial, in windows command line environment
23
2010-01-15 12:32:04
<p>I have a batch file, </p> <pre><code>bat1.bat bat2.bat </code></pre> <p>but it stops at the end of bat1</p> <p>any clues?</p>
60,084
142,795
2018-01-08 14:28:53
2,071,445
44
2010-01-15 12:36:48
73,070
2010-01-15 13:22:48
https://stackoverflow.com/q/2071408
https://stackoverflow.com/a/2071445
<p>Use <code>call</code>:</p> <pre><code>call bat1.cmd call bat2.cmd </code></pre> <p>By default, when you just run a batch file from another one controll will not pass back to the calling one. That's why you need to use <code>call</code>.</p> <p>Basically, if you have a batch like this:</p> <pre><code>@echo off ec...
<p>Use <code>call</code>:</p> <pre><code>call bat1.cmd call bat2.cmd </code></pre> <p>By default, when you just run a batch file from another one controll will not pass back to the calling one. That's why you need to use <code>call</code>.</p> <p>Basically, if you have a batch like this:</p> <pre><code>@echo off ec...
2631, 7002
batch-file, cmd
<h1>how to run multiple batch files in serial, in windows command line environment</h1> <p>I have a batch file, </p> <pre><code>bat1.bat bat2.bat </code></pre> <p>but it stops at the end of bat1</p> <p>any clues?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,363
cmd
# how to run multiple batch files in serial, in windows command line environment I have a batch file, ``` bat1.bat bat2.bat ``` but it stops at the end of bat1 any clues?
Use `call`: ``` call bat1.cmd call bat2.cmd ``` By default, when you just run a batch file from another one controll will not pass back to the calling one. That's why you need to use `call`. Basically, if you have a batch like this: ``` @echo off echo Foo batch2.cmd echo Bar ``` then it will only output ``` Foo `...
41454769
What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?
12
2017-01-04 01:13:41
<p>I have a one-line snippet that works perfectly in the command line, but fails and throws up errors when I run it as part of a batch script.</p> <p>The below commands behaves as expected, deleting all empty subfolders in the folder.</p> <pre><code>for /f &quot;delims=&quot; %d in ('dir /s /b /ad ^| sort /r') do rd &q...
85,661
1,191,147
2025-02-21 07:26:28
41,461,002
44
2017-01-04 10:01:11
3,074,564
2025-02-21 07:26:28
https://stackoverflow.com/q/41454769
https://stackoverflow.com/a/41461002
<h2>A) How does Windows command processor search for commands?</h2> <p>Windows command processor searches for a <em>COMMAND</em> to execute which</p> <ol> <li>is not an internal command of <code>cmd.exe</code> <strong>and</strong></li> <li>is just specified with file name without file extension and without path</li> </...
<h2>A) How does Windows command processor search for commands?</h2> <p>Windows command processor searches for a <em>COMMAND</em> to execute which</p> <ol> <li>is not an internal command of <code>cmd.exe</code> <strong>and</strong></li> <li>is just specified with file name without file extension and without path</li> </...
64, 2631, 7002
batch-file, cmd, windows
<h1>What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?</h1> <p>I have a one-line snippet that works perfectly in the command line, but fails and throws up errors when I run it as part of a batch script.</p> <p>The below commands behaves as expected, deleting...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,365
cmd
# What is the reason for "X is not recognized as an internal or external command, operable program or batch file"? I have a one-line snippet that works perfectly in the command line, but fails and throws up errors when I run it as part of a batch script. The below commands behaves as expected, deleting all empty subf...
## A) How does Windows command processor search for commands? Windows command processor searches for a *COMMAND* to execute which 1. is not an internal command of `cmd.exe` **and** 2. is just specified with file name without file extension and without path for a file matching the pattern `command.*` **and** having a...
8358265
How can I update the PATH variable permanently from the Windows command line?
129
2011-12-02 15:03:39
<p>If I execute <code>set PATH=%PATH%;C:\\Something\\bin</code> from the command line (<code>cmd.exe</code>) and then execute <code>echo %PATH%</code>, I see this string added to the PATH. If I close and open the command line, that new string is not in PATH.</p> <p>How can I update PATH permanently from the command lin...
266,325
365,011
2025-07-17 18:30:51
8,358,361
43
2011-12-02 15:09:56
505,088
2011-12-02 16:13:01
https://stackoverflow.com/q/8358265
https://stackoverflow.com/a/8358361
<p>The documentation on how to do this can be found on <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653%28v=vs.85%29.aspx" rel="noreferrer">MSDN</a>. The key extract is this:</p> <blockquote> <p>To programmatically add or modify system environment variables, add them to the <strong>HKEY_LOCA...
<p>The documentation on how to do this can be found on <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653%28v=vs.85%29.aspx" rel="noreferrer">MSDN</a>. The key extract is this:</p> <blockquote> <p>To programmatically add or modify system environment variables, add them to the <strong>HKEY_LOCA...
64, 2631, 6268
cmd, path, windows
<h1>How can I update the PATH variable permanently from the Windows command line?</h1> <p>If I execute <code>set PATH=%PATH%;C:\\Something\\bin</code> from the command line (<code>cmd.exe</code>) and then execute <code>echo %PATH%</code>, I see this string added to the PATH. If I close and open the command line, that n...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,366
cmd
# How can I update the PATH variable permanently from the Windows command line? If I execute `set PATH=%PATH%;C:\\Something\\bin` from the command line (`cmd.exe`) and then execute `echo %PATH%`, I see this string added to the PATH. If I close and open the command line, that new string is not in PATH. How can I updat...
The documentation on how to do this can be found on [MSDN](http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653%28v=vs.85%29.aspx). The key extract is this: > To programmatically add or modify system environment variables, add them to the **HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manage...
18462169
How to loop through array in batch?
56
2013-08-27 09:49:16
<p>I created an array like this:</p> <pre><code>set sources[0]="\\sources\folder1\" set sources[1]="\\sources\folder2\" set sources[2]="\\sources\folder3\" set sources[3]="\\sources\folder4\" </code></pre> <p>Now I want to iterate through this array:</p> <pre><code>for %%s in (%sources%) do echo %%s </code></pre> <...
143,661
1,001,055
2024-01-06 23:54:35
18,480,952
43
2013-08-28 06:38:34
778,560
2015-09-15 14:18:16
https://stackoverflow.com/q/18462169
https://stackoverflow.com/a/18480952
<p>If you don't know how many elements the array have (that seems is the case), you may use this method:</p> <pre><code>for /F "tokens=2 delims==" %%s in ('set sources[') do echo %%s </code></pre> <p>Note that the elements will be processed in <em>alphabetical order</em>, that is, if you have more than 9 (or 99, etc)...
<p>If you don't know how many elements the array have (that seems is the case), you may use this method:</p> <pre><code>for /F "tokens=2 delims==" %%s in ('set sources[') do echo %%s </code></pre> <p>Note that the elements will be processed in <em>alphabetical order</em>, that is, if you have more than 9 (or 99, etc)...
2531, 7002
batch-file, for-loop
<h1>How to loop through array in batch?</h1> <p>I created an array like this:</p> <pre><code>set sources[0]="\\sources\folder1\" set sources[1]="\\sources\folder2\" set sources[2]="\\sources\folder3\" set sources[3]="\\sources\folder4\" </code></pre> <p>Now I want to iterate through this array:</p> <pre><code>for %%...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,367
cmd
# How to loop through array in batch? I created an array like this: ``` set sources[0]="\\sources\folder1\" set sources[1]="\\sources\folder2\" set sources[2]="\\sources\folder3\" set sources[3]="\\sources\folder4\" ``` Now I want to iterate through this array: ``` for %%s in (%sources%) do echo %%s ``` It doesn't...
If you don't know how many elements the array have (that seems is the case), you may use this method: ``` for /F "tokens=2 delims==" %%s in ('set sources[') do echo %%s ``` Note that the elements will be processed in *alphabetical order*, that is, if you have more than 9 (or 99, etc) elements, the index must have lef...
25648155
Windows: Command line to read version info of an executable file?
44
2014-09-03 15:24:24
<p>Does Windows have an executable that I can run in the command shell which returns the version number of an executable (.exe) file? </p> <p>I see a lot of questions that show how to do it from different languages, and references to third party software to write it, but I can't find a simple shell command to do it. A...
106,312
10,335
2024-07-27 16:54:05
25,648,699
43
2014-09-03 15:53:12
2,861,476
2014-09-03 20:56:13
https://stackoverflow.com/q/25648155
https://stackoverflow.com/a/25648699
<pre><code>wmic datafile where name="C:\\Windows\\System32\\msiexec.exe" get Version /value </code></pre> <p>You can use <code>wmic</code> to do it. And you can wrap it into a batch file</p> <pre><code>@echo off setlocal enableextensions set "file=%~1" if not defined file goto :eof if not exist "%fi...
<pre><code>wmic datafile where name="C:\\Windows\\System32\\msiexec.exe" get Version /value </code></pre> <p>You can use <code>wmic</code> to do it. And you can wrap it into a batch file</p> <pre><code>@echo off setlocal enableextensions set "file=%~1" if not defined file goto :eof if not exist "%fi...
64, 1231, 5792, 7002, 30612
batch-file, command-line, portable-executable, version, windows
<h1>Windows: Command line to read version info of an executable file?</h1> <p>Does Windows have an executable that I can run in the command shell which returns the version number of an executable (.exe) file? </p> <p>I see a lot of questions that show how to do it from different languages, and references to third part...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,368
cmd
# Windows: Command line to read version info of an executable file? Does Windows have an executable that I can run in the command shell which returns the version number of an executable (.exe) file? I see a lot of questions that show how to do it from different languages, and references to third party software to wri...
``` wmic datafile where name="C:\\Windows\\System32\\msiexec.exe" get Version /value ``` You can use `wmic` to do it. And you can wrap it into a batch file ``` @echo off setlocal enableextensions set "file=%~1" if not defined file goto :eof if not exist "%file%" goto :eof set "vers=" FOR /F ...
7041069
Passing around multi-line strings
33
2011-08-12 13:52:31
<p>I'm trying to create a batch file which passes around a string with line feeds in it but its not working out. The continuation of the string is executed as a new command. </p> <p>Is there anyway to encode a line feed or make this work?</p>
59,413
73,407
2018-10-27 02:42:50
7,044,572
43
2011-08-12 18:20:47
463,115
2011-08-12 18:20:47
https://stackoverflow.com/q/7041069
https://stackoverflow.com/a/7044572
<p>You can create directly multiline strings with the caret (one empty line is required). </p> <pre><code>setlocal EnableDelayedExpansion set multiLine=This is a ^ multiline text^ line3 echo !multiLine! </code></pre> <p>Or you can create first a newline character.</p> <pre><code>setlocal EnableDelayedExpansion se...
<p>You can create directly multiline strings with the caret (one empty line is required). </p> <pre><code>setlocal EnableDelayedExpansion set multiLine=This is a ^ multiline text^ line3 echo !multiLine! </code></pre> <p>Or you can create first a newline character.</p> <pre><code>setlocal EnableDelayedExpansion se...
64, 2631, 7002
batch-file, cmd, windows
<h1>Passing around multi-line strings</h1> <p>I'm trying to create a batch file which passes around a string with line feeds in it but its not working out. The continuation of the string is executed as a new command. </p> <p>Is there anyway to encode a line feed or make this work?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,369
cmd
# Passing around multi-line strings I'm trying to create a batch file which passes around a string with line feeds in it but its not working out. The continuation of the string is executed as a new command. Is there anyway to encode a line feed or make this work?
You can create directly multiline strings with the caret (one empty line is required). ``` setlocal EnableDelayedExpansion set multiLine=This is a ^ multiline text^ line3 echo !multiLine! ``` Or you can create first a newline character. ``` setlocal EnableDelayedExpansion set LF=^ rem Two empty lines are require...
7396680
Add new line in text file with Windows batch file
32
2011-09-13 04:04:58
<p>I have a text file which has more than 200 lines in it, and I just want to add a new line before line 4. I'm using Windows&nbsp;XP.</p> <p>Example text file before input:</p> <pre><code>header 1 header 2 header 3 details 1 details 2 </code></pre> <p>After output:</p> <pre><code>header 1 header 2 header 3 &lt;---...
139,738
941,760
2020-10-07 10:02:40
7,396,917
43
2011-09-13 04:45:19
605,191
2011-09-13 04:45:19
https://stackoverflow.com/q/7396680
https://stackoverflow.com/a/7396917
<p>I believe you are using the </p> <pre><code>echo Text &gt;&gt; Example.txt </code></pre> <p>function?</p> <p>If so the answer would be simply adding a "." (Dot) directly after the echo with nothing else there.</p> <p>Example:</p> <pre><code>echo Blah echo Blah 2 echo. #New line is added echo Next Blah </code><...
<p>I believe you are using the </p> <pre><code>echo Text &gt;&gt; Example.txt </code></pre> <p>function?</p> <p>If so the answer would be simply adding a "." (Dot) directly after the echo with nothing else there.</p> <p>Example:</p> <pre><code>echo Blah echo Blah 2 echo. #New line is added echo Next Blah </code><...
64, 3705, 4867, 7002
batch-file, newline, stdout, windows
<h1>Add new line in text file with Windows batch file</h1> <p>I have a text file which has more than 200 lines in it, and I just want to add a new line before line 4. I'm using Windows&nbsp;XP.</p> <p>Example text file before input:</p> <pre><code>header 1 header 2 header 3 details 1 details 2 </code></pre> <p>After...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,370
cmd
# Add new line in text file with Windows batch file I have a text file which has more than 200 lines in it, and I just want to add a new line before line 4. I'm using Windows XP. Example text file before input: ``` header 1 header 2 header 3 details 1 details 2 ``` After output: ``` header 1 header 2 header 3 <---...
I believe you are using the ``` echo Text >> Example.txt ``` function? If so the answer would be simply adding a "." (Dot) directly after the echo with nothing else there. Example: ``` echo Blah echo Blah 2 echo. #New line is added echo Next Blah ```
6306412
Start a process in a new window from a batch file
30
2011-06-10 12:34:19
<p>I have written a batch file (.bat) in windows. I want to execute a particular process in a new window. How do I do this?</p> <p>Example</p> <pre><code>a.py -s 3 -l 5 b.py -k 0 -&gt; I want to start this in a new window and let the original batch file continue C:\program.exe ... .... </code></pre>
51,051
204,623
2017-11-22 13:11:38
6,306,673
43
2011-06-10 12:55:55
3,501
2011-06-10 12:55:55
https://stackoverflow.com/q/6306412
https://stackoverflow.com/a/6306673
<p>Use the start command:</p> <pre><code>start foo.py </code></pre> <p>or</p> <pre><code>start "" "c:\path with spaces\foo.py" </code></pre>
<p>Use the start command:</p> <pre><code>start foo.py </code></pre> <p>or</p> <pre><code>start "" "c:\path with spaces\foo.py" </code></pre>
64, 7002
batch-file, windows
<h1>Start a process in a new window from a batch file</h1> <p>I have written a batch file (.bat) in windows. I want to execute a particular process in a new window. How do I do this?</p> <p>Example</p> <pre><code>a.py -s 3 -l 5 b.py -k 0 -&gt; I want to start this in a new window and let the original batch file cont...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,371
cmd
# Start a process in a new window from a batch file I have written a batch file (.bat) in windows. I want to execute a particular process in a new window. How do I do this? Example ``` a.py -s 3 -l 5 b.py -k 0 -> I want to start this in a new window and let the original batch file continue C:\program.exe ... .... ...
Use the start command: ``` start foo.py ``` or ``` start "" "c:\path with spaces\foo.py" ```
9383032
Rename all files in a directory with a Windows batch script
27
2012-02-21 18:28:23
<p>How would I write a batch or cmd file that will rename all files in a directory? I am using Windows.</p> <p>Change this:</p> <pre><code>750_MOT_Forgiving_120x90.jpg 751_MOT_Persecution_1_120x90.jpg 752_MOT_Persecution_2_120x90.jpg 753_MOT_Hatred_120x90.jpg 754_MOT_Suffering_120x90.jpg 755_MOT_Freedom_of_Religion_1...
134,102
1,159,429
2024-04-30 18:27:17
9,383,305
43
2012-02-21 18:47:11
1,012,053
2012-11-07 05:32:55
https://stackoverflow.com/q/9383032
https://stackoverflow.com/a/9383305
<p>A FOR statement to loop through the names (type <code>FOR /?</code> for help), and string search and replace (type <code>SET /?</code> for help).</p> <pre><code>@echo off setlocal enableDelayedExpansion for %%F in (*120x90.jpg) do ( set "name=%%F" ren "!name!" "!name:120x90=67x100!" ) </code></pre> <p><br/><st...
<p>A FOR statement to loop through the names (type <code>FOR /?</code> for help), and string search and replace (type <code>SET /?</code> for help).</p> <pre><code>@echo off setlocal enableDelayedExpansion for %%F in (*120x90.jpg) do ( set "name=%%F" ren "!name!" "!name:120x90=67x100!" ) </code></pre> <p><br/><st...
64, 2631, 4510, 7002
batch-file, cmd, rename, windows
<h1>Rename all files in a directory with a Windows batch script</h1> <p>How would I write a batch or cmd file that will rename all files in a directory? I am using Windows.</p> <p>Change this:</p> <pre><code>750_MOT_Forgiving_120x90.jpg 751_MOT_Persecution_1_120x90.jpg 752_MOT_Persecution_2_120x90.jpg 753_MOT_Hatred_...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,373
cmd
# Rename all files in a directory with a Windows batch script How would I write a batch or cmd file that will rename all files in a directory? I am using Windows. Change this: ``` 750_MOT_Forgiving_120x90.jpg 751_MOT_Persecution_1_120x90.jpg 752_MOT_Persecution_2_120x90.jpg 753_MOT_Hatred_120x90.jpg 754_MOT_Sufferin...
A FOR statement to loop through the names (type `FOR /?` for help), and string search and replace (type `SET /?` for help). ``` @echo off setlocal enableDelayedExpansion for %%F in (*120x90.jpg) do ( set "name=%%F" ren "!name!" "!name:120x90=67x100!" ) ``` **UPDATE - 2012-11-07** I've investigated how the RENAME...
14347038
Why are my set commands resulting in nothing getting stored?
26
2013-01-15 21:13:50
<p>I am trying to access the value of TOMCAT_VER later on, but it appears as an empty string.</p> <pre><code>if exist "%_REALPATH%\tomcat-%TOMCAT_VER2%" ( set CATALINA_HOME=%_REALPATH%\tomcat-%TOMCAT_VER2% set TOMCAT_VER=%TOMCAT_VER2% echo "%TOMCAT_VER%" ) else if exist "%TOMCAT_VER2%" ( set CATALINA_HOME="%TO...
35,781
28,214
2020-01-16 10:05:29
14,347,131
43
2013-01-15 21:19:35
463,115
2020-01-16 10:05:29
https://stackoverflow.com/q/14347038
https://stackoverflow.com/a/14347131
<p>You found the bbb (batch beginner bug), but not the variable is empty, it's the expansion that doesn't work as expected. </p> <p>Percent expansion is done when a line or a complete parenthesis block is parsed, before the code will be executed.<br> But to solve this you can use the <strong>delayed expansion</strong...
<p>You found the bbb (batch beginner bug), but not the variable is empty, it's the expansion that doesn't work as expected. </p> <p>Percent expansion is done when a line or a complete parenthesis block is parsed, before the code will be executed.<br> But to solve this you can use the <strong>delayed expansion</strong...
64, 2631, 7002, 19675
batch-file, cmd, delayedvariableexpansion, windows
<h1>Why are my set commands resulting in nothing getting stored?</h1> <p>I am trying to access the value of TOMCAT_VER later on, but it appears as an empty string.</p> <pre><code>if exist "%_REALPATH%\tomcat-%TOMCAT_VER2%" ( set CATALINA_HOME=%_REALPATH%\tomcat-%TOMCAT_VER2% set TOMCAT_VER=%TOMCAT_VER2% echo "%T...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,374
cmd
# Why are my set commands resulting in nothing getting stored? I am trying to access the value of TOMCAT_VER later on, but it appears as an empty string. ``` if exist "%_REALPATH%\tomcat-%TOMCAT_VER2%" ( set CATALINA_HOME=%_REALPATH%\tomcat-%TOMCAT_VER2% set TOMCAT_VER=%TOMCAT_VER2% echo "%TOMCAT_VER%" ) else i...
You found the bbb (batch beginner bug), but not the variable is empty, it's the expansion that doesn't work as expected. Percent expansion is done when a line or a complete parenthesis block is parsed, before the code will be executed. But to solve this you can use the **delayed expansion**, this doesn't expand at p...
43234667
tf.layers.batch_normalization large test error
21
2017-04-05 14:50:58
<p>I'm trying to use batch normalization. I tried to use tf.layers.batch_normalization on a simple conv net for mnist.</p> <p>I get high accuracy for train step (>98%) but very low test accuracy (&lt;50%). I tried to change momentum values (I tried 0.8,0.9,0.99,0.999) and to play to with batch sizes but it always beh...
12,914
7,821,304
2018-01-14 14:30:49
43,276,405
43
2017-04-07 10:56:45
7,832,197
2017-04-07 10:56:45
https://stackoverflow.com/q/43234667
https://stackoverflow.com/a/43276405
<p>The operations which <code>tf.layers.batch_normalization</code> adds to update mean and variance don't automatically get added as dependencies of the train operation - so if you don't do anything extra, they never get run. (Unfortunately, the documentation doesn't currently mention this. I'm opening an issue about ...
<p>The operations which <code>tf.layers.batch_normalization</code> adds to update mean and variance don't automatically get added as dependencies of the train operation - so if you don't do anything extra, they never get run. (Unfortunately, the documentation doesn't currently mention this. I'm opening an issue about ...
124994
batch-normalization
<h1>tf.layers.batch_normalization large test error</h1> <p>I'm trying to use batch normalization. I tried to use tf.layers.batch_normalization on a simple conv net for mnist.</p> <p>I get high accuracy for train step (>98%) but very low test accuracy (&lt;50%). I tried to change momentum values (I tried 0.8,0.9,0.99,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,375
cmd
# tf.layers.batch_normalization large test error I'm trying to use batch normalization. I tried to use tf.layers.batch_normalization on a simple conv net for mnist. I get high accuracy for train step (>98%) but very low test accuracy (<50%). I tried to change momentum values (I tried 0.8,0.9,0.99,0.999) and to play t...
The operations which `tf.layers.batch_normalization` adds to update mean and variance don't automatically get added as dependencies of the train operation - so if you don't do anything extra, they never get run. (Unfortunately, the documentation doesn't currently mention this. I'm opening an issue about it.) Luckily, ...
8666225
How to test if a path is a file or directory in Windows batch file?
20
2011-12-29 09:50:43
<p>I searched here, found someone using this</p> <pre><code>set is_dir=0 for %%i in ("%~1") do if exist "%%~si"\nul set is_dir=1 </code></pre> <p>but didn't work, when <code>%1==c:\this is a file with spaces.csproj</code>, the test still success, which means it will still be treated as a folder!!!</p> <p>anyone know...
33,796
1,039,275
2023-10-24 04:39:30
8,669,636
43
2011-12-29 15:21:34
1,012,053
2019-10-31 12:09:10
https://stackoverflow.com/q/8666225
https://stackoverflow.com/a/8669636
<p>I know the <code>if exist path\nul</code> test for a folder used to work on MS-DOS. I don't know if it was broken with the introduction of long file names.</p> <p>I knew that <code>if exist "long path\nul"</code> does not work on Windows batch. I did not realize until today that <code>if exist path\nul</code> works...
<p>I know the <code>if exist path\nul</code> test for a folder used to work on MS-DOS. I don't know if it was broken with the introduction of long file names.</p> <p>I knew that <code>if exist "long path\nul"</code> does not work on Windows batch. I did not realize until today that <code>if exist path\nul</code> works...
64, 2631, 7002
batch-file, cmd, windows
<h1>How to test if a path is a file or directory in Windows batch file?</h1> <p>I searched here, found someone using this</p> <pre><code>set is_dir=0 for %%i in ("%~1") do if exist "%%~si"\nul set is_dir=1 </code></pre> <p>but didn't work, when <code>%1==c:\this is a file with spaces.csproj</code>, the test still suc...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,376
cmd
# How to test if a path is a file or directory in Windows batch file? I searched here, found someone using this ``` set is_dir=0 for %%i in ("%~1") do if exist "%%~si"\nul set is_dir=1 ``` but didn't work, when `%1==c:\this is a file with spaces.csproj`, the test still success, which means it will still be treated a...
I know the `if exist path\nul` test for a folder used to work on MS-DOS. I don't know if it was broken with the introduction of long file names. I knew that `if exist "long path\nul"` does not work on Windows batch. I did not realize until today that `if exist path\nul` works on Vista and beyond as long as path is in ...
1807425
Recursively delete all folders starting with
12
2009-11-27 08:30:52
<p>I need to write a command in a .bat file that recursively deletes all the folders starting with a certain string. How may I achieve this ?</p>
25,484
118,437
2017-12-10 19:03:37
2,829,351
43
2010-05-13 18:39:28
260,080
2011-03-22 09:15:36
https://stackoverflow.com/q/1807425
https://stackoverflow.com/a/2829351
<p>This is the complete answer you are looking for:</p> <pre><code>FOR /D /R %%X IN (certain_string*) DO RD /S /Q "%%X" </code></pre> <p>where obviously you need to replace <code>certain_string</code> with the string your folders start with.</p> <p>This deletes <strong>RECURSIVELY</strong> as you asked (I mean it go...
<p>This is the complete answer you are looking for:</p> <pre><code>FOR /D /R %%X IN (certain_string*) DO RD /S /Q "%%X" </code></pre> <p>where obviously you need to replace <code>certain_string</code> with the string your folders start with.</p> <p>This deletes <strong>RECURSIVELY</strong> as you asked (I mean it go...
64, 218, 578, 1231, 7002
batch-file, command-line, directory, recursion, windows
<h1>Recursively delete all folders starting with</h1> <p>I need to write a command in a .bat file that recursively deletes all the folders starting with a certain string. How may I achieve this ?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,377
cmd
# Recursively delete all folders starting with I need to write a command in a .bat file that recursively deletes all the folders starting with a certain string. How may I achieve this ?
This is the complete answer you are looking for: ``` FOR /D /R %%X IN (certain_string*) DO RD /S /Q "%%X" ``` where obviously you need to replace `certain_string` with the string your folders start with. This deletes **RECURSIVELY** as you asked (I mean it goes throught all folders and subfolders).
4228807
Copy files without overwrite
134
2010-11-19 19:50:42
<p>I just can't seem to find a way on the command line to say "copy all the files from directory A to directory B, but if the file already exists in directory B, don't overwrite it, no matter which file is newer, and don't prompt me."</p> <p>I have been through copy, move, xcopy &amp; robocopy, and the closest I can g...
282,813
513,915
2025-03-20 11:23:18
4,228,911
42
2010-11-19 20:04:21
414
2012-09-01 19:43:49
https://stackoverflow.com/q/4228807
https://stackoverflow.com/a/4228911
<pre><code>For %F In ("C:\From\*.*") Do If Not Exist "C:\To\%~nxF" Copy "%F" "C:\To\%~nxF" </code></pre>
<pre><code>For %F In ("C:\From\*.*") Do If Not Exist "C:\To\%~nxF" Copy "%F" "C:\To\%~nxF" </code></pre>
64, 4710, 7002, 11635
batch-file, robocopy, windows, xcopy
<h1>Copy files without overwrite</h1> <p>I just can't seem to find a way on the command line to say "copy all the files from directory A to directory B, but if the file already exists in directory B, don't overwrite it, no matter which file is newer, and don't prompt me."</p> <p>I have been through copy, move, xcopy &...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,378
cmd
# Copy files without overwrite I just can't seem to find a way on the command line to say "copy all the files from directory A to directory B, but if the file already exists in directory B, don't overwrite it, no matter which file is newer, and don't prompt me." I have been through copy, move, xcopy & robocopy, and t...
``` For %F In ("C:\From\*.*") Do If Not Exist "C:\To\%~nxF" Copy "%F" "C:\To\%~nxF" ```
130193
Is it possible to modify a registry entry via a .bat/.cmd script?
53
2008-09-24 21:52:10
<p>Is it possible to modify a registry value (whether string or DWORD) via a .bat/.cmd script?</p>
198,211
3,153
2024-04-30 15:24:25
130,202
42
2008-09-24 21:54:20
143,732
2013-02-25 18:49:27
https://stackoverflow.com/q/130193
https://stackoverflow.com/a/130202
<p>You can use the REG command. From <a href="http://www.ss64.com/nt/reg.html" rel="noreferrer">http://www.ss64.com/nt/reg.html</a>:</p> <pre><code>Syntax: REG QUERY [ROOT\]RegKey /v ValueName [/s] REG QUERY [ROOT\]RegKey /ve --This returns the (default) value REG ADD [ROOT\]RegKey /v ValueName [/t DataTyp...
<p>You can use the REG command. From <a href="http://www.ss64.com/nt/reg.html" rel="noreferrer">http://www.ss64.com/nt/reg.html</a>:</p> <pre><code>Syntax: REG QUERY [ROOT\]RegKey /v ValueName [/s] REG QUERY [ROOT\]RegKey /ve --This returns the (default) value REG ADD [ROOT\]RegKey /v ValueName [/t DataTyp...
64, 263, 1362, 2631, 7002
automation, batch-file, cmd, registry, windows
<h1>Is it possible to modify a registry entry via a .bat/.cmd script?</h1> <p>Is it possible to modify a registry value (whether string or DWORD) via a .bat/.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,380
cmd
# Is it possible to modify a registry entry via a .bat/.cmd script? Is it possible to modify a registry value (whether string or DWORD) via a .bat/.cmd script?
You can use the REG command. From <http://www.ss64.com/nt/reg.html>: ``` Syntax: REG QUERY [ROOT\]RegKey /v ValueName [/s] REG QUERY [ROOT\]RegKey /ve --This returns the (default) value REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f] REG ADD [ROOT\]RegKey /ve [/d Data] [/f...
1015163
heredoc for Windows batch?
51
2009-06-18 21:01:31
<p>Is there a way of specifying multiline strings in batch in a way similar to heredoc in unix shells. Something similar to:</p> <pre><code>cat &lt;&lt;EOF &gt; out.txt bla bla .. EOF </code></pre> <p>The idea is to create a customized file from a template file..</p>
30,523
97,160
2025-12-03 06:46:12
1,015,471
42
2009-06-18 22:10:27
20,713
2009-06-18 22:10:27
https://stackoverflow.com/q/1015163
https://stackoverflow.com/a/1015471
<p>Not as far as I know.</p> <p>The closest I know of is</p> <pre><code>&gt; out.txt ( @echo.bla @echo.bla ... ) </code></pre> <p>(<code>@</code> prevents the command shell itself from printing the commands it's running, and <code>echo.</code> allows you to start a line with a space.)</p>
<p>Not as far as I know.</p> <p>The closest I know of is</p> <pre><code>&gt; out.txt ( @echo.bla @echo.bla ... ) </code></pre> <p>(<code>@</code> prevents the command shell itself from printing the commands it's running, and <code>echo.</code> allows you to start a line with a space.)</p>
1478, 7002, 7449
batch-file, heredoc, templates
<h1>heredoc for Windows batch?</h1> <p>Is there a way of specifying multiline strings in batch in a way similar to heredoc in unix shells. Something similar to:</p> <pre><code>cat &lt;&lt;EOF &gt; out.txt bla bla .. EOF </code></pre> <p>The idea is to create a customized file from a template file..</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,381
cmd
# heredoc for Windows batch? Is there a way of specifying multiline strings in batch in a way similar to heredoc in unix shells. Something similar to: ``` cat <<EOF > out.txt bla bla .. EOF ``` The idea is to create a customized file from a template file..
Not as far as I know. The closest I know of is ``` > out.txt ( @echo.bla @echo.bla ... ) ``` (`@` prevents the command shell itself from printing the commands it's running, and `echo.` allows you to start a line with a space.)
31201631
Execute CMD commands using C++
38
2015-07-03 08:01:20
<p>In my project I want to execute some CMD commands. What is the syntax for doing that using C++.</p>
166,751
5,074,328
2018-11-15 16:42:19
31,201,720
42
2015-07-03 08:06:41
4,748,205
2018-11-15 16:42:19
https://stackoverflow.com/q/31201631
https://stackoverflow.com/a/31201720
<p>You can execute Windows Command prompt commands using a C++ function called <code>system();</code>. <strong><em>For safer standards</em></strong> you are recommended to use Windows specific API'S like <strong><em>ShellExecute</em></strong> or <strong><em>ShellExecuteEx</em></strong>. Here is how to run CMD command u...
<p>You can execute Windows Command prompt commands using a C++ function called <code>system();</code>. <strong><em>For safer standards</em></strong> you are recommended to use Windows specific API'S like <strong><em>ShellExecute</em></strong> or <strong><em>ShellExecuteEx</em></strong>. Here is how to run CMD command u...
10, 64, 1796, 2631
c++, cmd, command, windows
<h1>Execute CMD commands using C++</h1> <p>In my project I want to execute some CMD commands. What is the syntax for doing that using C++.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,382
cmd
# Execute CMD commands using C++ In my project I want to execute some CMD commands. What is the syntax for doing that using C++.
You can execute Windows Command prompt commands using a C++ function called `system();`. ***For safer standards*** you are recommended to use Windows specific API'S like ***ShellExecute*** or ***ShellExecuteEx***. Here is how to run CMD command using `system()` function. You should place the CMD command like shown bel...
20782734
Open a URL without using a browser from a batch file
36
2013-12-26 09:56:16
<p>I want to open a particular URL without directly opening the browser using only a batch file. I know I can use something like:</p> <pre><code>START www.google.com </code></pre> <p>But I want to open a URL without using a browser. Is this possible?</p> <p>The reason is that I have to open like 30 URLs, and I don't...
182,412
2,274,622
2022-05-29 08:25:25
20,787,029
42
2013-12-26 15:14:33
2,861,476
2019-09-19 15:57:10
https://stackoverflow.com/q/20782734
https://stackoverflow.com/a/20787029
<p>If all you want is to request the URL and if it needs to be done from batch file, without anything outside of the OS, this can help you:</p> <pre><code>@if (@This==@IsBatch) @then @echo off rem **** batch zone ********************************************************* setlocal enableextensions disabledelayedexp...
<p>If all you want is to request the URL and if it needs to be done from batch file, without anything outside of the OS, this can help you:</p> <pre><code>@if (@This==@IsBatch) @then @echo off rem **** batch zone ********************************************************* setlocal enableextensions disabledelayedexp...
2631, 7002
batch-file, cmd
<h1>Open a URL without using a browser from a batch file</h1> <p>I want to open a particular URL without directly opening the browser using only a batch file. I know I can use something like:</p> <pre><code>START www.google.com </code></pre> <p>But I want to open a URL without using a browser. Is this 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,383
cmd
# Open a URL without using a browser from a batch file I want to open a particular URL without directly opening the browser using only a batch file. I know I can use something like: ``` START www.google.com ``` But I want to open a URL without using a browser. Is this possible? The reason is that I have to open lik...
If all you want is to request the URL and if it needs to be done from batch file, without anything outside of the OS, this can help you: ``` @if (@This==@IsBatch) @then @echo off rem **** batch zone ********************************************************* setlocal enableextensions disabledelayedexpansion re...
19121138
Batch file 'for' loops - multiple lines
33
2013-10-01 16:16:38
<p>Why will the following lines work in a batch file?</p> <pre><code> for %%a in ("C:\Test\*.txt") do set FileName=%%~a echo Filename is: %FileName% </code></pre> <p>But these won't?:</p> <pre><code> for %%a in ("C:\Test\*.txt") do ( set FileName=%%~a echo Filename is: %FileName% ) </code></pre> <p>It...
52,514
1,547,084
2021-01-29 21:46:29
19,121,310
42
2013-10-01 16:25:14
2,093,352
2021-01-29 21:46:29
https://stackoverflow.com/q/19121138
https://stackoverflow.com/a/19121310
<p>It is because everything between the parentheses is loaded as one line. So <code>%FileName%</code> is expanded (at load time) before it is set (at run time). If you need to use the second format, you need to enable delayed expansion. Then you will have difficulty if the filename contains a <code>!</code>. This would...
<p>It is because everything between the parentheses is loaded as one line. So <code>%FileName%</code> is expanded (at load time) before it is set (at run time). If you need to use the second format, you need to enable delayed expansion. Then you will have difficulty if the filename contains a <code>!</code>. This would...
2531, 7002
batch-file, for-loop
<h1>Batch file 'for' loops - multiple lines</h1> <p>Why will the following lines work in a batch file?</p> <pre><code> for %%a in ("C:\Test\*.txt") do set FileName=%%~a echo Filename is: %FileName% </code></pre> <p>But these won't?:</p> <pre><code> for %%a in ("C:\Test\*.txt") do ( set FileName=%%~a ech...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,384
cmd
# Batch file 'for' loops - multiple lines Why will the following lines work in a batch file? ``` for %%a in ("C:\Test\*.txt") do set FileName=%%~a echo Filename is: %FileName% ``` But these won't?: ``` for %%a in ("C:\Test\*.txt") do ( set FileName=%%~a echo Filename is: %FileName% ) ``` It's like ...
It is because everything between the parentheses is loaded as one line. So `%FileName%` is expanded (at load time) before it is set (at run time). If you need to use the second format, you need to enable delayed expansion. Then you will have difficulty if the filename contains a `!`. This would work if there are no par...
10229324
Pass parameter to MySQL script command line
33
2012-04-19 13:39:20
<p>Is there any option to pass a parameter from the command line to MySQL script?</p> <p>Something like @start_date in this example:</p> <pre><code>mysql –uuser_id -ppassword –h mysql-host -A -e "set @start_date=${start_date}; source ${sql_script};" &gt;${data_file}; </code></pre>
51,527
1,083,423
2021-04-06 18:39:43
10,265,580
42
2012-04-22 05:49:37
1,083,423
2014-01-17 23:21:27
https://stackoverflow.com/q/10229324
https://stackoverflow.com/a/10265580
<p>Found an answer on the net <a href="http://databobjr.blogspot.com/2011/07/passing-parameters-to-mysql-query.html" rel="noreferrer">here</a>.</p> <p>Basically, suppose that we want to run this query:</p> <pre><code>Select c_id, c_first_name,c_last_name, c_address,last_modified_date from customer where last_modified...
<p>Found an answer on the net <a href="http://databobjr.blogspot.com/2011/07/passing-parameters-to-mysql-query.html" rel="noreferrer">here</a>.</p> <p>Basically, suppose that we want to run this query:</p> <pre><code>Select c_id, c_first_name,c_last_name, c_address,last_modified_date from customer where last_modified...
21, 2631
cmd, mysql
<h1>Pass parameter to MySQL script command line</h1> <p>Is there any option to pass a parameter from the command line to MySQL script?</p> <p>Something like @start_date in this example:</p> <pre><code>mysql –uuser_id -ppassword –h mysql-host -A -e "set @start_date=${start_date}; source ${sql_script};" &gt;${data_fil...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,385
cmd
# Pass parameter to MySQL script command line Is there any option to pass a parameter from the command line to MySQL script? Something like @start_date in this example: ``` mysql –uuser_id -ppassword –h mysql-host -A -e "set @start_date=${start_date}; source ${sql_script};" >${data_file}; ```
Found an answer on the net [here](http://databobjr.blogspot.com/2011/07/passing-parameters-to-mysql-query.html). Basically, suppose that we want to run this query: ``` Select c_id, c_first_name,c_last_name, c_address,last_modified_date from customer where last_modified_date >=@start_date and last_modified_date <= @en...
17900954
Add “python2” path to command line on Windows 7
29
2013-07-27 18:13:46
<p>I've been trying to add the <code>python2</code> path to command line on Windows 7. </p> <p>I have tried to do it this way:</p> <pre><code>C:\&gt;set python2 = C:\Python27\python.exe </code></pre> <p>But <code>cmd</code> told me that:</p> <pre><code>'python2' is not recognized as an internal or external command....
44,212
null
2020-05-27 07:04:25
17,900,974
42
2013-07-27 18:15:49
2,225,682
2018-08-13 15:54:42
https://stackoverflow.com/q/17900954
https://stackoverflow.com/a/17900974
<p>This answer copied from <a href="https://stackoverflow.com/a/17836439/2225682">my own answer</a>, and customized to this question.</p> <p>Try following command.</p> <pre><code>set path=%path%;c:\python27 </code></pre> <p><code>PATH</code> is set only for the cmd.exe in which you run the above command.</p> <p>To ...
<p>This answer copied from <a href="https://stackoverflow.com/a/17836439/2225682">my own answer</a>, and customized to this question.</p> <p>Try following command.</p> <pre><code>set path=%path%;c:\python27 </code></pre> <p><code>PATH</code> is set only for the cmd.exe in which you run the above command.</p> <p>To ...
16, 64, 2631, 6268, 34595
cmd, path, python, windows, windows-7
<h1>Add “python2” path to command line on Windows 7</h1> <p>I've been trying to add the <code>python2</code> path to command line on Windows 7. </p> <p>I have tried to do it this way:</p> <pre><code>C:\&gt;set python2 = C:\Python27\python.exe </code></pre> <p>But <code>cmd</code> told me that:</p> <pre><code>'pytho...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,387
cmd
# Add “python2” path to command line on Windows 7 I've been trying to add the `python2` path to command line on Windows 7. I have tried to do it this way: ``` C:\>set python2 = C:\Python27\python.exe ``` But `cmd` told me that: ``` 'python2' is not recognized as an internal or external command. ``` So how can I a...
This answer copied from [my own answer](https://stackoverflow.com/a/17836439/2225682), and customized to this question. Try following command. ``` set path=%path%;c:\python27 ``` `PATH` is set only for the cmd.exe in which you run the above command. To permanently set PATH: 1. Right click **My computer** in the de...
8898088
single line for statement: %%i 'unexpected at this time'
27
2012-01-17 16:23:19
<pre><code>for /r %%i in (*) do (echo %%i) </code></pre> <p>Results in</p> <blockquote> <p>%%i was unexpected at this time</p> </blockquote> <p>Why?</p>
49,668
178,511
2024-08-13 16:10:19
8,898,432
42
2012-01-17 16:47:21
1,012,053
2020-10-26 11:32:26
https://stackoverflow.com/q/8898088
https://stackoverflow.com/a/8898432
<p>You must be trying to run the command from the command line and not from within a batch file. Use a single % instead of two when running from the command line.</p> <pre><code>for /r %i in (*) do (echo %i) </code></pre> <p>Type <code>HELP FOR</code> from the command line and read the 3rd paragraph.</p>
<p>You must be trying to run the command from the command line and not from within a batch file. Use a single % instead of two when running from the command line.</p> <pre><code>for /r %i in (*) do (echo %i) </code></pre> <p>Type <code>HELP FOR</code> from the command line and read the 3rd paragraph.</p>
2531, 2631
cmd, for-loop
<h1>single line for statement: %%i 'unexpected at this time'</h1> <pre><code>for /r %%i in (*) do (echo %%i) </code></pre> <p>Results in</p> <blockquote> <p>%%i was unexpected at this time</p> </blockquote> <p>Why?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,388
cmd
# single line for statement: %%i 'unexpected at this time' ``` for /r %%i in (*) do (echo %%i) ``` Results in > %%i was unexpected at this time Why?
You must be trying to run the command from the command line and not from within a batch file. Use a single % instead of two when running from the command line. ``` for /r %i in (*) do (echo %i) ``` Type `HELP FOR` from the command line and read the 3rd paragraph.
50243229
run batch file in npm script
25
2018-05-08 22:44:57
<p>Is it possible and how to run a batch script in npm command? </p> <p>I have an angular project, in <code>package.json</code> file, under <code>scripts</code> section, I want to define a npm command to run batch script. I know I can run shell script with keyword <code>bash</code> e.g. </p> <pre class="lang-json pre...
29,624
2,480,414
2022-02-02 09:17:37
50,366,466
42
2018-05-16 08:57:07
1,611,459
2018-05-16 09:04:24
https://stackoverflow.com/q/50243229
https://stackoverflow.com/a/50366466
<p>To help provide context to this answer, let's say we two batch files named <code>say-hello.bat</code> and <code>say-hello-cmd</code>. Both batch files have the same simple contrived content as follows:</p> <pre><code>echo Hello World </code></pre> <p>When invoking either of the two batch files via <code>npm-scri...
<p>To help provide context to this answer, let's say we two batch files named <code>say-hello.bat</code> and <code>say-hello-cmd</code>. Both batch files have the same simple contrived content as follows:</p> <pre><code>echo Hello World </code></pre> <p>When invoking either of the two batch files via <code>npm-scri...
7002, 122330
batch-file, npm-scripts
<h1>run batch file in npm script</h1> <p>Is it possible and how to run a batch script in npm command? </p> <p>I have an angular project, in <code>package.json</code> file, under <code>scripts</code> section, I want to define a npm command to run batch script. I know I can run shell script with keyword <code>bash</code...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,389
cmd
# run batch file in npm script Is it possible and how to run a batch script in npm command? I have an angular project, in `package.json` file, under `scripts` section, I want to define a npm command to run batch script. I know I can run shell script with keyword `bash` e.g. ``` "start": "cd mydir && bash ./myscript"...
To help provide context to this answer, let's say we two batch files named `say-hello.bat` and `say-hello-cmd`. Both batch files have the same simple contrived content as follows: ``` echo Hello World ``` When invoking either of the two batch files via `npm-scripts`, we expect the console to log: > `Hello World` **...
7931997
Setting Android AVD Command Line Hardware Profile
25
2011-10-28 16:21:09
<p>When creating a new Android AVD through command line through the following command:</p> <pre><code>android create avd -n &lt;name&gt; </code></pre> <p>You're met with the following output:</p> <pre><code>Do you wish to create a custom hardware profile [no] </code></pre> <p>I've been tasked with created a fully-a...
9,614
1,018,713
2017-05-12 04:36:39
7,932,089
42
2011-10-28 16:30:40
1,001,360
2011-10-28 16:30:40
https://stackoverflow.com/q/7931997
https://stackoverflow.com/a/7932089
<p>try</p> <pre><code>echo no | android create avd -n &lt;name&gt; </code></pre>
<p>try</p> <pre><code>echo no | android create avd -n &lt;name&gt; </code></pre>
531, 1231, 1386, 7002, 40048
android, android-virtual-device, batch-file, command-line, scripting
<h1>Setting Android AVD Command Line Hardware Profile</h1> <p>When creating a new Android AVD through command line through the following command:</p> <pre><code>android create avd -n &lt;name&gt; </code></pre> <p>You're met with the following output:</p> <pre><code>Do you wish to create a custom hardware profile [no...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,390
cmd
# Setting Android AVD Command Line Hardware Profile When creating a new Android AVD through command line through the following command: ``` android create avd -n <name> ``` You're met with the following output: ``` Do you wish to create a custom hardware profile [no] ``` I've been tasked with created a fully-autom...
try ``` echo no | android create avd -n <name> ```
19765536
Compile all .c files in a directory using GCC compiler in CMD
22
2013-11-04 10:14:29
<p>Is there a way to compile all <code>.c</code> files in a given folder by using the command line with GCC compiler ?<br> I've seen this page for Linux : <a href="http://www.commandlinefu.com/commands/view/3230/compile-all-c-files-in-a-directory" rel="noreferrer">http://www.commandlinefu.com/commands/view/3230/compile...
53,023
1,405,268
2020-06-04 19:41:15
19,765,645
42
2013-11-04 10:20:53
2,003,898
2015-01-13 19:14:20
https://stackoverflow.com/q/19765536
https://stackoverflow.com/a/19765645
<p>I guess gcc itself doesn't have such a parameter.</p> <p>But you can try the regular wildcard argument of <code>gcc *.c -o Output</code> where the <code>*</code> (wildcard) is to read as "any".</p>
<p>I guess gcc itself doesn't have such a parameter.</p> <p>But you can try the regular wildcard argument of <code>gcc *.c -o Output</code> where the <code>*</code> (wildcard) is to read as "any".</p>
1477, 2631, 4545
cmd, compilation, gcc
<h1>Compile all .c files in a directory using GCC compiler in CMD</h1> <p>Is there a way to compile all <code>.c</code> files in a given folder by using the command line with GCC compiler ?<br> I've seen this page for Linux : <a href="http://www.commandlinefu.com/commands/view/3230/compile-all-c-files-in-a-directory" r...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,391
cmd
# Compile all .c files in a directory using GCC compiler in CMD Is there a way to compile all `.c` files in a given folder by using the command line with GCC compiler ? I've seen this page for Linux : <http://www.commandlinefu.com/commands/view/3230/compile-all-c-files-in-a-directory> but couldn't find any equivalen...
I guess gcc itself doesn't have such a parameter. But you can try the regular wildcard argument of `gcc *.c -o Output` where the `*` (wildcard) is to read as "any".
1869155
Math on batch (win)
22
2009-12-08 19:06:27
<p>I am developing a CMD batch. I want to do some math in it. This formula: <code>(x+1)100:y</code></p> <p>So in batch, <code>x = %x%, and y = %y%</code>. I know how to set the variables. Now, how can batch calculate this? (WINDOWS CMD) </p> <p>Do I need something extra?</p> <p>(I need this to be available to users...
60,939
111,731
2023-05-21 13:35:48
1,869,198
42
2009-12-08 19:14:26
91,756
2019-01-14 15:08:27
https://stackoverflow.com/q/1869155
https://stackoverflow.com/a/1869198
<p>The set command supports some limited calculation. In your case, you want: <code>set /a result=(100*x)/y</code></p> <p>Run <code>set /?</code> to see full documentation on what is supported. The <code>/a</code> switch does automatic variable substitution, so you can use <code>x</code> instead of <code>%x%</code>....
<p>The set command supports some limited calculation. In your case, you want: <code>set /a result=(100*x)/y</code></p> <p>Run <code>set /?</code> to see full documentation on what is supported. The <code>/a</code> switch does automatic variable substitution, so you can use <code>x</code> instead of <code>%x%</code>....
259, 2631, 7002, 8908, 34595
batch-file, cmd, formula, math, windows-7
<h1>Math on batch (win)</h1> <p>I am developing a CMD batch. I want to do some math in it. This formula: <code>(x+1)100:y</code></p> <p>So in batch, <code>x = %x%, and y = %y%</code>. I know how to set the variables. Now, how can batch calculate this? (WINDOWS CMD) </p> <p>Do I need something extra?</p> <p>(I need ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,392
cmd
# Math on batch (win) I am developing a CMD batch. I want to do some math in it. This formula: `(x+1)100:y` So in batch, `x = %x%, and y = %y%`. I know how to set the variables. Now, how can batch calculate this? (WINDOWS CMD) Do I need something extra? (I need this to be available to users of Windows XP to 7.)
The set command supports some limited calculation. In your case, you want: `set /a result=(100*x)/y` Run `set /?` to see full documentation on what is supported. The `/a` switch does automatic variable substitution, so you can use `x` instead of `%x%`.
12870880
Run .php file in Windows Command Prompt (cmd)
20
2012-10-13 07:11:39
<p>I want to run a <code>.php</code> file in windows cmd. I followed this (suggestion) <a href="https://stackoverflow.com/questions/2920903/php-is-not-recognized-as-an-intern-command-using-windows">php is not recognized as an internal command (in Windows)</a></p> <p>But it did not work. </p> <p>I tried this command p...
163,076
1,687,804
2024-06-25 09:35:33
12,870,987
42
2012-10-13 07:29:34
1,142,004
2017-10-29 12:25:21
https://stackoverflow.com/q/12870880
https://stackoverflow.com/a/12870987
<p><strong>If running Windows 10:</strong></p> <ol> <li>Open the start menu</li> <li>Type <code>path</code></li> <li>Click <strong><em>Edit the system environment variables</em></strong> (usually, it's the top search result) and continue on step <strong>6</strong> below.</li> </ol> <p><strong>If on older Windows:</st...
<p><strong>If running Windows 10:</strong></p> <ol> <li>Open the start menu</li> <li>Type <code>path</code></li> <li>Click <strong><em>Edit the system environment variables</em></strong> (usually, it's the top search result) and continue on step <strong>6</strong> below.</li> </ol> <p><strong>If on older Windows:</st...
5, 2631
cmd, php
<h1>Run .php file in Windows Command Prompt (cmd)</h1> <p>I want to run a <code>.php</code> file in windows cmd. I followed this (suggestion) <a href="https://stackoverflow.com/questions/2920903/php-is-not-recognized-as-an-intern-command-using-windows">php is not recognized as an internal command (in Windows)</a></p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,393
cmd
# Run .php file in Windows Command Prompt (cmd) I want to run a `.php` file in windows cmd. I followed this (suggestion) [php is not recognized as an internal command (in Windows)](https://stackoverflow.com/questions/2920903/php-is-not-recognized-as-an-intern-command-using-windows) But it did not work. I tried this ...
**If running Windows 10:** 1. Open the start menu 2. Type `path` 3. Click ***Edit the system environment variables*** (usually, it's the top search result) and continue on step **6** below. **If on older Windows:** 1. Show Desktop. 2. Right Click ***My Computer*** shortcut in the desktop. 3. Click ***Properties***. ...
9203362
C color text in terminal applications in windows
18
2012-02-08 23:45:09
<p>I know "textcolor();" is for C++ and i've seen methods for unix... but is there way for windows also?</p> <pre><code>#include &lt;stdio.h&gt; int main() { printf("\ntest - C programming text color!"); printf("\n--------------------------------"); printf("\n\n\t\t-BREAK-\n\n"); textcolor(15); pri...
41,626
883,015
2023-11-20 19:34:18
9,203,489
42
2012-02-08 23:57:21
195,701
2012-02-09 02:34:46
https://stackoverflow.com/q/9203362
https://stackoverflow.com/a/9203489
<p>Since you want a C and Windows specific solution, I'd recommend using the <code>SetConsoleTextAttribute()</code> function in the Win32 API. You'll need to grab a handle to the console, and then pass it with the appropriate attributes.</p> <p>As a simple example:</p> <pre><code>/* Change console text color, then re...
<p>Since you want a C and Windows specific solution, I'd recommend using the <code>SetConsoleTextAttribute()</code> function in the Win32 API. You'll need to grab a handle to the console, and then pass it with the appropriate attributes.</p> <p>As a simple example:</p> <pre><code>/* Change console text color, then re...
8, 64, 2631, 9938, 15256
c, cmd, command-prompt, textcolor, windows
<h1>C color text in terminal applications in windows</h1> <p>I know "textcolor();" is for C++ and i've seen methods for unix... but is there way for windows also?</p> <pre><code>#include &lt;stdio.h&gt; int main() { printf("\ntest - C programming text color!"); printf("\n--------------------------------"); ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,394
cmd
# C color text in terminal applications in windows I know "textcolor();" is for C++ and i've seen methods for unix... but is there way for windows also? ``` #include <stdio.h> int main() { printf("\ntest - C programming text color!"); printf("\n--------------------------------"); printf("\n\n\t\t-BREAK-\n...
Since you want a C and Windows specific solution, I'd recommend using the `SetConsoleTextAttribute()` function in the Win32 API. You'll need to grab a handle to the console, and then pass it with the appropriate attributes. As a simple example: ``` /* Change console text color, then restore it back to normal. */ #inc...
21765687
remove quotes "" from string in batch file
17
2014-02-13 21:18:13
<p>I use:</p> <pre><code>FOR /F "delims=" %%G IN ("%command%") DO SET command=%%~G </code></pre> <p>to remove "" quotes from variable %command%. If command = <strong>"Shutdown /s /t 00"</strong>, after this line it will be: <strong>Shutdown /s /t 00</strong>. and it works. But when command contains a string where are...
37,505
2,426,559
2023-12-05 17:19:23
21,765,973
42
2014-02-13 21:34:50
2,844,742
2014-02-13 21:34:50
https://stackoverflow.com/q/21765687
https://stackoverflow.com/a/21765973
<p>Instead of your for loop through the command, you could just use string manipulation.</p> <pre><code>set command=%command:"=% </code></pre> <p>the values after <code>command</code> are <code>"=&lt;nul&gt;</code> so you're getting rid of quotation marks in the variable command. Just as an extra example, you could a...
<p>Instead of your for loop through the command, you could just use string manipulation.</p> <pre><code>set command=%command:"=% </code></pre> <p>the values after <code>command</code> are <code>"=&lt;nul&gt;</code> so you're getting rid of quotation marks in the variable command. Just as an extra example, you could a...
64, 7002
batch-file, windows
<h1>remove quotes "" from string in batch file</h1> <p>I use:</p> <pre><code>FOR /F "delims=" %%G IN ("%command%") DO SET command=%%~G </code></pre> <p>to remove "" quotes from variable %command%. If command = <strong>"Shutdown /s /t 00"</strong>, after this line it will be: <strong>Shutdown /s /t 00</strong>. and it...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,395
cmd
# remove quotes "" from string in batch file I use: ``` FOR /F "delims=" %%G IN ("%command%") DO SET command=%%~G ``` to remove "" quotes from variable %command%. If command = **"Shutdown /s /t 00"**, after this line it will be: **Shutdown /s /t 00**. and it works. But when command contains a string where are a equa...
Instead of your for loop through the command, you could just use string manipulation. ``` set command=%command:"=% ``` the values after `command` are `"=<nul>` so you're getting rid of quotation marks in the variable command. Just as an extra example, you could also do `%command: =_%` to replace all spaces in command...
5664761
How to count no of lines in text file and store the value into a variable using batch script?
62
2011-04-14 14:27:53
<p>I want to count the no of lines in a text file and then the value has to be stored into a environment variable. The command to count the no of lines is</p> <pre> findstr /R /N "^" file.txt | find /C ":" </pre> <p>I refered the question <a href="https://stackoverflow.com/questions/1427218">How to store the result o...
269,348
596,370
2021-08-05 00:48:34
5,665,718
41
2011-04-14 15:34:27
463,115
2011-04-14 21:06:32
https://stackoverflow.com/q/5664761
https://stackoverflow.com/a/5665718
<p>You could use the FOR /F loop, to assign the output to a variable. </p> <p>I use the <code>cmd-variable</code>, so it's not neccessary to escape the pipe or other characters in the cmd-string, as the delayed expansion passes the string "unchanged" to the FOR-Loop.</p> <pre><code>@echo off cls setlocal EnableDelay...
<p>You could use the FOR /F loop, to assign the output to a variable. </p> <p>I use the <code>cmd-variable</code>, so it's not neccessary to escape the pipe or other characters in the cmd-string, as the delayed expansion passes the string "unchanged" to the FOR-Loop.</p> <pre><code>@echo off cls setlocal EnableDelay...
64, 2631, 7002
batch-file, cmd, windows
<h1>How to count no of lines in text file and store the value into a variable using batch script?</h1> <p>I want to count the no of lines in a text file and then the value has to be stored into a environment variable. The command to count the no of lines is</p> <pre> findstr /R /N "^" file.txt | find /C ":" </pre> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,396
cmd
# How to count no of lines in text file and store the value into a variable using batch script? I want to count the no of lines in a text file and then the value has to be stored into a environment variable. The command to count the no of lines is ``` findstr /R /N "^" file.txt | find /C ":" ``` I refered the questi...
You could use the FOR /F loop, to assign the output to a variable. I use the `cmd-variable`, so it's not neccessary to escape the pipe or other characters in the cmd-string, as the delayed expansion passes the string "unchanged" to the FOR-Loop. ``` @echo off cls setlocal EnableDelayedExpansion set "cmd=findstr /R /N...
3677773
How can I run a windows batch file but hide the command window?
36
2010-09-09 14:56:21
<p>How can I run a windows batch file but hiding the command window? I dont want cmd.exe to be visible on screen when the file is being executed. Is this possible?</p>
117,720
1,390,354
2021-07-09 05:59:07
3,696,515
41
2010-09-12 20:37:26
315,935
2021-07-09 05:59:07
https://stackoverflow.com/q/3677773
https://stackoverflow.com/a/3696515
<p>If you write an <strong>unmanaged program</strong> and use <a href="https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa" rel="nofollow noreferrer">CreateProcess</a> API then you should initialize <code>lpStartupInfo</code> parameter of the type <a href="https://l...
<p>If you write an <strong>unmanaged program</strong> and use <a href="https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa" rel="nofollow noreferrer">CreateProcess</a> API then you should initialize <code>lpStartupInfo</code> parameter of the type <a href="https://l...
64, 531, 7002
batch-file, scripting, windows
<h1>How can I run a windows batch file but hide the command window?</h1> <p>How can I run a windows batch file but hiding the command window? I dont want cmd.exe to be visible on screen when the file is being executed. Is this 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,397
cmd
# How can I run a windows batch file but hide the command window? How can I run a windows batch file but hiding the command window? I dont want cmd.exe to be visible on screen when the file is being executed. Is this possible?
If you write an **unmanaged program** and use [CreateProcess](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa) API then you should initialize `lpStartupInfo` parameter of the type [STARTUPINFO](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsap...
13972636
Jenkins always considers a build successful using batch/bat
32
2012-12-20 12:51:41
<p>I just joined a company that uses batch files to build a C++ project. The batch does all sorts of things (updates svn, which is now done by jenkins), creates build folders, deletes unnecessary files after building, copies library files to the build folder, etc.</p> <p>My problem is Jenkins always considers the buil...
43,793
1,918,810
2018-06-27 20:19:53
13,994,277
41
2012-12-21 17:04:08
1,390,251
2014-04-18 12:07:22
https://stackoverflow.com/q/13972636
https://stackoverflow.com/a/13994277
<p>To answer each of your questions -</p> <ul> <li><p><strong>Jenkins always return "SUCCESS", even when the Job actually failed</strong>:</p> <p>Jenkins sets the status of the Job, based on the return-code of the <em>last command</em><br> that ran in each "<em>Execute windows batch command</em>" block.<br> If your l...
<p>To answer each of your questions -</p> <ul> <li><p><strong>Jenkins always return "SUCCESS", even when the Job actually failed</strong>:</p> <p>Jenkins sets the status of the Job, based on the return-code of the <em>last command</em><br> that ran in each "<em>Execute windows batch command</em>" block.<br> If your l...
7002, 64999
batch-file, jenkins
<h1>Jenkins always considers a build successful using batch/bat</h1> <p>I just joined a company that uses batch files to build a C++ project. The batch does all sorts of things (updates svn, which is now done by jenkins), creates build folders, deletes unnecessary files after building, copies library files to the build...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,398
cmd
# Jenkins always considers a build successful using batch/bat I just joined a company that uses batch files to build a C++ project. The batch does all sorts of things (updates svn, which is now done by jenkins), creates build folders, deletes unnecessary files after building, copies library files to the build folder, ...
To answer each of your questions - - **Jenkins always return "SUCCESS", even when the Job actually failed**: Jenkins sets the status of the Job, based on the return-code of the *last command* that ran in each "*Execute windows batch command*" block. If your last command is `copy some.log D:`, Jenkins th...
2044882
How to hide batch output
31
2010-01-11 20:58:22
<p>I am putting the finishing touches to a batch script that transfers the contents of a locally edited web site to the internet.</p> <p>The script opens in a console window, and outputs quite a lot of stuff the administrator needs to see in case something goes wrong. In that case, though, the output is being sent as ...
87,913
187,606
2022-07-18 10:45:58
2,044,955
41
2010-01-11 21:08:25
14,569
2010-01-11 21:08:25
https://stackoverflow.com/q/2044882
https://stackoverflow.com/a/2044955
<p>Windows actually does have the notion of stdout and stderr. Here's an example:</p> <p>test.bat:</p> <pre><code>@echo off echo verbose stuff 1 echo verbose stuff 2 echo verbose stuff 3 echo important stuff! &gt;&amp;2 echo verbose stuff 4 </code></pre> <p>If you run it as '<code>test.bat</code>' you'll get the ful...
<p>Windows actually does have the notion of stdout and stderr. Here's an example:</p> <p>test.bat:</p> <pre><code>@echo off echo verbose stuff 1 echo verbose stuff 2 echo verbose stuff 3 echo important stuff! &gt;&amp;2 echo verbose stuff 4 </code></pre> <p>If you run it as '<code>test.bat</code>' you'll get the ful...
64, 7002
batch-file, windows
<h1>How to hide batch output</h1> <p>I am putting the finishing touches to a batch script that transfers the contents of a locally edited web site to the internet.</p> <p>The script opens in a console window, and outputs quite a lot of stuff the administrator needs to see in case something goes wrong. In that case, th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,399
cmd
# How to hide batch output I am putting the finishing touches to a batch script that transfers the contents of a locally edited web site to the internet. The script opens in a console window, and outputs quite a lot of stuff the administrator needs to see in case something goes wrong. In that case, though, the output...
Windows actually does have the notion of stdout and stderr. Here's an example: test.bat: ``` @echo off echo verbose stuff 1 echo verbose stuff 2 echo verbose stuff 3 echo important stuff! >&2 echo verbose stuff 4 ``` If you run it as '`test.bat`' you'll get the full output. If you run it as '`test.bat >nul`' then yo...
36760127
How to use the new support for ANSI escape sequences in the Windows 10 console?
28
2016-04-21 05:07:17
<p>The latest Windows 10 updates include <a href="http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-%28v1511%29-Console-Host-Enhancements" rel="noreferrer">support for ANSI escape sequences</a> in conhost.exe.</p> <p><a href="https://i.sstatic.net/5j61D.png" rel="noreferrer"><img src="https://i.sstatic.net/5j61...
16,651
3,486,684
2022-05-18 15:37:29
36,760,881
41
2016-04-21 06:02:19
3,826,372
2016-04-21 06:37:33
https://stackoverflow.com/q/36760127
https://stackoverflow.com/a/36760881
<p>The problem is that the Python interpreter doesn't enable the processing of ANSI escape sequences. The ANSI sequences work from the Windows command prompt because <code>cmd</code> does enable them. If you start Python from the command prompt you'll find the ANSI sequences do work, including the ones for enabling an...
<p>The problem is that the Python interpreter doesn't enable the processing of ANSI escape sequences. The ANSI sequences work from the Windows command prompt because <code>cmd</code> does enable them. If you start Python from the command prompt you'll find the ANSI sequences do work, including the ones for enabling an...
16, 2631, 40232, 107329
cmd, python, windows-10, windows-console
<h1>How to use the new support for ANSI escape sequences in the Windows 10 console?</h1> <p>The latest Windows 10 updates include <a href="http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-%28v1511%29-Console-Host-Enhancements" rel="noreferrer">support for ANSI escape sequences</a> in conhost.exe.</p> <p><a hre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,400
cmd
# How to use the new support for ANSI escape sequences in the Windows 10 console? The latest Windows 10 updates include [support for ANSI escape sequences](http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-%28v1511%29-Console-Host-Enhancements) in conhost.exe. [![enter image description here](https://i.sstatic...
The problem is that the Python interpreter doesn't enable the processing of ANSI escape sequences. The ANSI sequences work from the Windows command prompt because `cmd` does enable them. If you start Python from the command prompt you'll find the ANSI sequences do work, including the ones for enabling and disabling the...
11746079
filter in tasklist.exe does not take wildcards?
27
2012-07-31 17:49:58
<p>OS: Windows XP, Windows 7 64bit.</p> <p>We have some fairly hefty cmd scripts that are used for some daily build processes. These scripts spawn numerous other (windowed) processes. There is one controlling cmd script, a small simple script, which starts the main cmd script. The purpose of the small controlling s...
79,888
1,082,063
2022-10-11 10:01:28
11,747,041
41
2012-07-31 18:55:09
1,012,053
2019-02-28 01:46:49
https://stackoverflow.com/q/11746079
https://stackoverflow.com/a/11747041
<p>You can use the /V option to include the window title in the output and then pipe the result to FIND (or FINDSTR) to filter the result.</p> <pre><code>tasklist /v | find "UniqueIdentifier" tasklist /v | findstr /c:"UniqueIdentifier" </code></pre> <p>If using FINDSTR then I recommend using the /C option so that you...
<p>You can use the /V option to include the window title in the output and then pipe the result to FIND (or FINDSTR) to filter the result.</p> <pre><code>tasklist /v | find "UniqueIdentifier" tasklist /v | findstr /c:"UniqueIdentifier" </code></pre> <p>If using FINDSTR then I recommend using the /C option so that you...
2631, 9647, 10052, 34595, 69665
cmd, filter, tasklist, windows-7, windows-8
<h1>filter in tasklist.exe does not take wildcards?</h1> <p>OS: Windows XP, Windows 7 64bit.</p> <p>We have some fairly hefty cmd scripts that are used for some daily build processes. These scripts spawn numerous other (windowed) processes. There is one controlling cmd script, a small simple script, which starts the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,401
cmd
# filter in tasklist.exe does not take wildcards? OS: Windows XP, Windows 7 64bit. We have some fairly hefty cmd scripts that are used for some daily build processes. These scripts spawn numerous other (windowed) processes. There is one controlling cmd script, a small simple script, which starts the main cmd script. ...
You can use the /V option to include the window title in the output and then pipe the result to FIND (or FINDSTR) to filter the result. ``` tasklist /v | find "UniqueIdentifier" tasklist /v | findstr /c:"UniqueIdentifier" ``` If using FINDSTR then I recommend using the /C option so that you can include spaces in the ...
605101
Order in which command prompt executes files with the same name (a.bat vs a.cmd vs a.exe)
26
2009-03-03 04:20:34
<p>What is the order in which the Windows command prompt executes files with the same name, but different extensions?</p> <p>For example, I have a bunch of executable files: <code>something.cmd</code>, <code>something.bat</code> and <code>something.exe</code>. Which of these would be executed when I typed <code>someth...
11,691
3,719
2020-06-18 05:57:29
605,139
41
2009-03-03 04:41:50
3,719
2020-06-18 05:57:29
https://stackoverflow.com/q/605101
https://stackoverflow.com/a/605139
<p>Okay, I did some quick experimentation based on some other searches I had going.</p> <p>The gist is that the order of the commands is dependent on the order the extensions are stored in the <code>PATHEXT</code> environment variable. So initially I had:</p> <pre><code>PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;...
<p>Okay, I did some quick experimentation based on some other searches I had going.</p> <p>The gist is that the order of the commands is dependent on the order the extensions are stored in the <code>PATHEXT</code> environment variable. So initially I had:</p> <pre><code>PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;...
64, 1231, 2631, 7002
batch-file, cmd, command-line, windows
<h1>Order in which command prompt executes files with the same name (a.bat vs a.cmd vs a.exe)</h1> <p>What is the order in which the Windows command prompt executes files with the same name, but different extensions?</p> <p>For example, I have a bunch of executable files: <code>something.cmd</code>, <code>something.ba...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,402
cmd
# Order in which command prompt executes files with the same name (a.bat vs a.cmd vs a.exe) What is the order in which the Windows command prompt executes files with the same name, but different extensions? For example, I have a bunch of executable files: `something.cmd`, `something.bat` and `something.exe`. Which of...
Okay, I did some quick experimentation based on some other searches I had going. The gist is that the order of the commands is dependent on the order the extensions are stored in the `PATHEXT` environment variable. So initially I had: ``` PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.RB;.RBW ``` and for ...
16526627
Windows 7 remote shutdown: Access denied(5)
25
2013-05-13 16:14:17
<p>I am trying to force a remote shutdown from my laptop to my PC:</p> <pre><code>machine&gt; shutdown -m \\192.168.2.10 -s -f -t 0 192.168.2.10: Access denied(5) </code></pre> <p>I am in a WLAN/LAN environment:</p> <ul> <li>Laptop is in WLAN with IP <code>192.168.2.100</code> (DHCP), Win 7 (64 bit)</li> <li>PC is c...
92,089
1,828,051
2016-04-13 16:55:27
16,526,680
41
2013-05-13 16:17:38
185,117
2016-04-13 16:55:27
https://stackoverflow.com/q/16526627
https://stackoverflow.com/a/16526680
<p>You can use the <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true" rel="noreferrer">NET USE</a> command to authenticate on the remote server and then use shutdown.exe</p> <pre><code>NET USE \\MyServer\IPC$ mypassword /USER:myuser </code></pre> <p><a href=...
<p>You can use the <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true" rel="noreferrer">NET USE</a> command to authenticate on the remote server and then use shutdown.exe</p> <pre><code>NET USE \\MyServer\IPC$ mypassword /USER:myuser </code></pre> <p><a href=...
794, 2631, 4921, 8192, 34595
cmd, network-programming, remote-access, shutdown, windows-7
<h1>Windows 7 remote shutdown: Access denied(5)</h1> <p>I am trying to force a remote shutdown from my laptop to my PC:</p> <pre><code>machine&gt; shutdown -m \\192.168.2.10 -s -f -t 0 192.168.2.10: Access denied(5) </code></pre> <p>I am in a WLAN/LAN environment:</p> <ul> <li>Laptop is in WLAN with IP <code>192.168...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,403
cmd
# Windows 7 remote shutdown: Access denied(5) I am trying to force a remote shutdown from my laptop to my PC: ``` machine> shutdown -m \\192.168.2.10 -s -f -t 0 192.168.2.10: Access denied(5) ``` I am in a WLAN/LAN environment: - Laptop is in WLAN with IP `192.168.2.100` (DHCP), Win 7 (64 bit) - PC is connected via...
You can use the [NET USE](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true) command to authenticate on the remote server and then use shutdown.exe ``` NET USE \\MyServer\IPC$ mypassword /USER:myuser ``` <http://www.squidworks.net/2011/07/how-to-pass-a-username-and-p...
2532740
Windows batch file to delete .svn files and folders
25
2010-03-28 11:42:38
<p>In order to delete all ".svn" files/folders/subfolders in "myfolder" I use this simple line in a batch file:</p> <pre><code>FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X") </code></pre> <p>This works, but if there are no ".svn" files/folders the batch file shows a warning saying: "The system cannot find the file...
21,482
260,080
2016-04-15 12:24:12
2,532,752
41
2010-03-28 11:47:41
131,527
2010-03-28 11:47:41
https://stackoverflow.com/q/2532740
https://stackoverflow.com/a/2532752
<p>you can try</p> <pre><code>FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2&gt;nul) </code></pre>
<p>you can try</p> <pre><code>FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2&gt;nul) </code></pre>
63, 7002, 37510
batch-file, delete-file, svn
<h1>Windows batch file to delete .svn files and folders</h1> <p>In order to delete all ".svn" files/folders/subfolders in "myfolder" I use this simple line in a batch file:</p> <pre><code>FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X") </code></pre> <p>This works, but if there are no ".svn" files/folders the batch ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,404
cmd
# Windows batch file to delete .svn files and folders In order to delete all ".svn" files/folders/subfolders in "myfolder" I use this simple line in a batch file: ``` FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X") ``` This works, but if there are no ".svn" files/folders the batch file shows a warning saying: "The...
you can try ``` FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul) ```
11539726
How to get the most recent file using a batch file?
23
2012-07-18 10:54:32
<p>I have a list of zip files with date and time appended like <code>yyyymmdd_hhmmss_Demos.zip</code>. Now how to get the most recently added zip file in the source dir. I need to copy this file in the target using <code>copy</code> command.</p> <p>I found some info about <code>forfiles</code>, but do not have an idea...
82,073
1,168,819
2023-03-24 19:58:00
11,539,774
41
2012-07-18 10:57:56
799,586
2012-07-18 12:01:14
https://stackoverflow.com/q/11539726
https://stackoverflow.com/a/11539774
<p>You can use</p> <pre><code>pushd D:\a for /f "tokens=*" %%a in ('dir /b /od') do set newest=%%a copy "%newest%" D:\b popd </code></pre>
<p>You can use</p> <pre><code>pushd D:\a for /f "tokens=*" %%a in ('dir /b /od') do set newest=%%a copy "%newest%" D:\b popd </code></pre>
7002, 136758
batch-file, forfiles
<h1>How to get the most recent file using a batch file?</h1> <p>I have a list of zip files with date and time appended like <code>yyyymmdd_hhmmss_Demos.zip</code>. Now how to get the most recently added zip file in the source dir. I need to copy this file in the target using <code>copy</code> command.</p> <p>I found s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,405
cmd
# How to get the most recent file using a batch file? I have a list of zip files with date and time appended like `yyyymmdd_hhmmss_Demos.zip`. Now how to get the most recently added zip file in the source dir. I need to copy this file in the target using `copy` command. I found some info about `forfiles`, but do not ...
You can use ``` pushd D:\a for /f "tokens=*" %%a in ('dir /b /od') do set newest=%%a copy "%newest%" D:\b popd ```
31990775
batch file to connect and disconnect from vpn connection
19
2015-08-13 14:16:29
<p><strong>connect.bat</strong></p> <pre><code>rasdial myvpn </code></pre> <p><strong>disconnect.bat</strong></p> <pre><code>rasdial myvpn /DISCONNECT </code></pre> <p>....I assigned those two files a keyboard shortcut to run them and they work perfectly.</p> <hr> <p><strong>QUESTION</strong>: is it possible to m...
46,032
4,470,692
2018-01-13 05:13:14
32,000,249
41
2015-08-13 23:50:02
3,959,875
2015-08-14 17:26:31
https://stackoverflow.com/q/31990775
https://stackoverflow.com/a/32000249
<ul> <li><p>Based on <code>ping</code> in case the VPN server IP is always the same:</p> <pre><code>ping -n 1 1.2.3.4 &amp;&amp; rasdial myvpn /disconnect || rasdial myvpn </code></pre> <p>Replace 1.2.3.4 with your VPN server ip (use <code>ipconfig /all</code> when connected) and put this in your batch file or direct...
<ul> <li><p>Based on <code>ping</code> in case the VPN server IP is always the same:</p> <pre><code>ping -n 1 1.2.3.4 &amp;&amp; rasdial myvpn /disconnect || rasdial myvpn </code></pre> <p>Replace 1.2.3.4 with your VPN server ip (use <code>ipconfig /all</code> when connected) and put this in your batch file or direct...
64, 2631, 7002
batch-file, cmd, windows
<h1>batch file to connect and disconnect from vpn connection</h1> <p><strong>connect.bat</strong></p> <pre><code>rasdial myvpn </code></pre> <p><strong>disconnect.bat</strong></p> <pre><code>rasdial myvpn /DISCONNECT </code></pre> <p>....I assigned those two files a keyboard shortcut to run them and they work perfe...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,407
cmd
# batch file to connect and disconnect from vpn connection **connect.bat** ``` rasdial myvpn ``` **disconnect.bat** ``` rasdial myvpn /DISCONNECT ``` ....I assigned those two files a keyboard shortcut to run them and they work perfectly. --- **QUESTION**: is it possible to make a single .bat that does the follow...
- Based on `ping` in case the VPN server IP is always the same: ``` ping -n 1 1.2.3.4 && rasdial myvpn /disconnect || rasdial myvpn ``` Replace 1.2.3.4 with your VPN server ip (use `ipconfig /all` when connected) and put this in your batch file or directly in the shortcut properties prepending with `cmd /c` i...
53051630
Git - list remote branches with their author names
18
2018-10-29 18:24:26
<p>Based on my search , the below 2 commands are supposed to give me remote branches with their author name. However, I get nothing in return - do you know why ?</p> <p>I am using windows command prompt.</p> <p>The below command returns : "Input file specified two times."</p> <pre><code>git for-each-ref --format='%(...
14,375
1,630,853
2024-03-01 21:50:09
53,053,513
41
2018-10-29 20:43:36
947,357
2018-10-31 19:26:36
https://stackoverflow.com/q/53051630
https://stackoverflow.com/a/53053513
<p>You are trying to run a Unix-Command in a Windows <code>cmd</code> shell. The Windows <code>sort</code> does not understand the <code>-k5n</code> syntax. Try running it in the <code>bash</code> shell provided by Git For Windows and it will not print errors. </p> <p>There is room for improvement though: <code>git fo...
<p>You are trying to run a Unix-Command in a Windows <code>cmd</code> shell. The Windows <code>sort</code> does not understand the <code>-k5n</code> syntax. Try running it in the <code>bash</code> shell provided by Git For Windows and it will not print errors. </p> <p>There is room for improvement though: <code>git fo...
119, 2631
cmd, git
<h1>Git - list remote branches with their author names</h1> <p>Based on my search , the below 2 commands are supposed to give me remote branches with their author name. However, I get nothing in return - do you know why ?</p> <p>I am using windows command prompt.</p> <p>The below command returns : "Input file specifi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,408
cmd
# Git - list remote branches with their author names Based on my search , the below 2 commands are supposed to give me remote branches with their author name. However, I get nothing in return - do you know why ? I am using windows command prompt. The below command returns : "Input file specified two times." ``` git...
You are trying to run a Unix-Command in a Windows `cmd` shell. The Windows `sort` does not understand the `-k5n` syntax. Try running it in the `bash` shell provided by Git For Windows and it will not print errors. There is room for improvement though: `git for-each-ref` can sort itself: ``` git for-each-ref --sort=co...
43986732
Spring Batch configuration error in processor
17
2017-05-15 18:47:13
<p>I want to configure Spring Batch job, but I receive the following error, how can I solve it? </p> <p>Error: <a href="https://i.sstatic.net/1ldjf.png" rel="noreferrer"><img src="https://i.sstatic.net/1ldjf.png" alt="enter image description here"></a></p> <p>Reader:</p> <pre><code>import org.springframework.batch.i...
10,421
5,651,359
2019-04-06 19:40:26
43,986,930
41
2017-05-15 19:00:02
1,392,894
2017-05-15 19:25:24
https://stackoverflow.com/q/43986732
https://stackoverflow.com/a/43986930
<p>You need to specify a type for the <code>chunk</code> operation. In your case that would be <code>&lt;SearchResponseRO, Movie&gt;</code>.</p> <pre><code>return stepBuilderFactory.get("downloadStep").&lt;SearchResponseRO, Movie&gt;chunk(10) .reader(reader) .processor(processor) ..... </code></pre> <p>Without ...
<p>You need to specify a type for the <code>chunk</code> operation. In your case that would be <code>&lt;SearchResponseRO, Movie&gt;</code>.</p> <pre><code>return stepBuilderFactory.get("downloadStep").&lt;SearchResponseRO, Movie&gt;chunk(10) .reader(reader) .processor(processor) ..... </code></pre> <p>Without ...
17, 1211, 41895
java, spring, spring-batch
<h1>Spring Batch configuration error in processor</h1> <p>I want to configure Spring Batch job, but I receive the following error, how can I solve it? </p> <p>Error: <a href="https://i.sstatic.net/1ldjf.png" rel="noreferrer"><img src="https://i.sstatic.net/1ldjf.png" alt="enter image description here"></a></p> <p>Rea...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,409
cmd
# Spring Batch configuration error in processor I want to configure Spring Batch job, but I receive the following error, how can I solve it? Error: [![enter image description here](https://i.sstatic.net/1ldjf.png)](https://i.sstatic.net/1ldjf.png) Reader: ``` import org.springframework.batch.item.ItemReader; publi...
You need to specify a type for the `chunk` operation. In your case that would be `<SearchResponseRO, Movie>`. ``` return stepBuilderFactory.get("downloadStep").<SearchResponseRO, Movie>chunk(10) .reader(reader) .processor(processor) ..... ``` Without the type, it defaults to `<Object, Object>`: ``` stepBuilder...
206114
Batch files: How to read a file?
122
2008-10-15 19:37:39
<p>How you can read a file (text or binary) from a batch file? There is a way to read it in a binary mode or text mode?</p>
501,219
20,601
2024-10-13 19:39:08
206,145
40
2008-10-15 19:47:00
27,929
2008-10-15 19:47:00
https://stackoverflow.com/q/206114
https://stackoverflow.com/a/206145
<p>You can use the for command:</p> <pre><code>FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k </code></pre> <p>Type</p> <pre><code>for /? </code></pre> <p>at the command prompt. Also, you can <a href="http://www.ericphelps.com/batch/samples/getini.txt" rel="noreferrer">parse ini files</a>...
<p>You can use the for command:</p> <pre><code>FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k </code></pre> <p>Type</p> <pre><code>for /? </code></pre> <p>at the command prompt. Also, you can <a href="http://www.ericphelps.com/batch/samples/getini.txt" rel="noreferrer">parse ini files</a>...
5310, 7002
batch-file, file
<h1>Batch files: How to read a file?</h1> <p>How you can read a file (text or binary) from a batch file? There is a way to read it in a binary mode or text mode?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,410
cmd
# Batch files: How to read a file? How you can read a file (text or binary) from a batch file? There is a way to read it in a binary mode or text mode?
You can use the for command: ``` FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k ``` Type ``` for /? ``` at the command prompt. Also, you can [parse ini files](http://www.ericphelps.com/batch/samples/getini.txt)!