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
8607594
Batch file to restart a service. Windows
41
2011-12-22 17:22:48
<p>How can I restart a windows service using a .bat file? I am on windows server.</p>
138,422
977,121
2019-01-31 11:54:34
8,607,620
84
2011-12-22 17:25:12
707,111
2011-12-22 17:25:12
https://stackoverflow.com/q/8607594
https://stackoverflow.com/a/8607620
<pre><code>net stop &lt;your service&gt; &amp;&amp; net start &lt;your service&gt; </code></pre> <p>No <code>net restart</code>, unfortunately.</p>
<pre><code>net stop &lt;your service&gt; &amp;&amp; net start &lt;your service&gt; </code></pre> <p>No <code>net restart</code>, unfortunately.</p>
7002, 23964
batch-file, windows-server-2003
<h1>Batch file to restart a service. Windows</h1> <p>How can I restart a windows service using a .bat file? I am on windows server.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,093
cmd
# Batch file to restart a service. Windows How can I restart a windows service using a .bat file? I am on windows server.
``` net stop <your service> && net start <your service> ``` No `net restart`, unfortunately.
25840861
"Invalid path 0 files copied" Error while using xcopy command
25
2014-09-15 04:31:49
<p>I have this little command to copy files in a batch, which will help because I do this specific copy multiple times a day. The problem occurs while using the <code>xcopy</code> command. Everything is in order, but I am receiving this error: &quot;Invalid path 0 files copied&quot;. Here is the code:</p> <pre><code>C:...
39,818
2,593,854
2024-10-28 08:42:48
25,841,519
84
2014-09-15 05:47:41
2,861,476
2021-02-26 10:55:19
https://stackoverflow.com/q/25840861
https://stackoverflow.com/a/25841519
<p><strong>Original answer</strong></p> <p>Remove the ending backslash from the source folder path</p> <pre><code>C:\Windows\System32\xcopy.exe /Y &quot;C:\Users\Ryan\Desktop\mmars_pub&quot; &quot;C:\Users\Ryan\Desktop\Dropbox\MMARS\mmars_pub\&quot; </code></pre> <hr /> <p><strong>edited</strong> 2015/10/01</p> <p>Whi...
<p><strong>Original answer</strong></p> <p>Remove the ending backslash from the source folder path</p> <pre><code>C:\Windows\System32\xcopy.exe /Y &quot;C:\Users\Ryan\Desktop\mmars_pub&quot; &quot;C:\Users\Ryan\Desktop\Dropbox\MMARS\mmars_pub\&quot; </code></pre> <hr /> <p><strong>edited</strong> 2015/10/01</p> <p>Whi...
64, 4710, 6268, 7002
batch-file, path, windows, xcopy
<h1>"Invalid path 0 files copied" Error while using xcopy command</h1> <p>I have this little command to copy files in a batch, which will help because I do this specific copy multiple times a day. The problem occurs while using the <code>xcopy</code> command. Everything is in order, but I am receiving this error: &quot...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,094
cmd
# "Invalid path 0 files copied" Error while using xcopy command I have this little command to copy files in a batch, which will help because I do this specific copy multiple times a day. The problem occurs while using the `xcopy` command. Everything is in order, but I am receiving this error: "Invalid path 0 files cop...
**Original answer** Remove the ending backslash from the source folder path ``` C:\Windows\System32\xcopy.exe /Y "C:\Users\Ryan\Desktop\mmars_pub" "C:\Users\Ryan\Desktop\Dropbox\MMARS\mmars_pub\" ``` --- **edited** 2015/10/01 While the original question used a literal path, and the indicated solution will solve t...
18058389
How to switch between python 2.7 to python 3 from command line?
68
2013-08-05 12:39:06
<p>I'm trying to find the best way to switch between the two python compilers, 2.7 to 3.3. I ran the python script from the cmd like this:</p> <blockquote> <p><code>python ex1.py</code></p> </blockquote> <p>Where do I set the "python" environment in the window's environment variable to point to either python 3.3 or...
216,800
918,460
2021-12-20 09:58:27
18,058,500
83
2013-08-05 12:45:06
2,055,853
2013-08-05 12:50:33
https://stackoverflow.com/q/18058389
https://stackoverflow.com/a/18058500
<p>For Windows 7, I just rename the <code>python.exe</code> from the Python 3 folder to <code>python3.exe</code> and add the path into the environment variables. Using that, I can execute <code>python test_script.py</code> and the script runs with Python 2.7 and when I do <code>python3 test_script.py</code>, it runs th...
<p>For Windows 7, I just rename the <code>python.exe</code> from the Python 3 folder to <code>python3.exe</code> and add the path into the environment variables. Using that, I can execute <code>python test_script.py</code> and the script runs with Python 2.7 and when I do <code>python3 test_script.py</code>, it runs th...
16, 64, 1231, 2631
cmd, command-line, python, windows
<h1>How to switch between python 2.7 to python 3 from command line?</h1> <p>I'm trying to find the best way to switch between the two python compilers, 2.7 to 3.3. I ran the python script from the cmd like this:</p> <blockquote> <p><code>python ex1.py</code></p> </blockquote> <p>Where do I set the "python" environm...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,095
cmd
# How to switch between python 2.7 to python 3 from command line? I'm trying to find the best way to switch between the two python compilers, 2.7 to 3.3. I ran the python script from the cmd like this: > `python ex1.py` Where do I set the "python" environment in the window's environment variable to point to either p...
For Windows 7, I just rename the `python.exe` from the Python 3 folder to `python3.exe` and add the path into the environment variables. Using that, I can execute `python test_script.py` and the script runs with Python 2.7 and when I do `python3 test_script.py`, it runs the script in Python 3. To add `Python 3` to the...
856573
concatenate variables
65
2009-05-13 07:37:28
<p>I need to do a .bat for DOS that do the following:</p> <pre><code>set ROOT = c:\programas\ set SRC_ROOT = (I want to put the ROOT Here)System\Source </code></pre> <p>so after defining ROOT I want to have SRC_ROOT = c:\programas\System\Source</p> <p>How can I do that?</p>
189,117
41,795
2023-10-04 05:58:41
856,592
83
2009-05-13 07:42:02
103,585
2019-05-02 11:19:00
https://stackoverflow.com/q/856573
https://stackoverflow.com/a/856592
<pre><code>set ROOT=c:\programs set SRC_ROOT=%ROOT%\System\Source </code></pre>
<pre><code>set ROOT=c:\programs set SRC_ROOT=%ROOT%\System\Source </code></pre>
7002
batch-file
<h1>concatenate variables</h1> <p>I need to do a .bat for DOS that do the following:</p> <pre><code>set ROOT = c:\programas\ set SRC_ROOT = (I want to put the ROOT Here)System\Source </code></pre> <p>so after defining ROOT I want to have SRC_ROOT = c:\programas\System\Source</p> <p>How can I do that?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,096
cmd
# concatenate variables I need to do a .bat for DOS that do the following: ``` set ROOT = c:\programas\ set SRC_ROOT = (I want to put the ROOT Here)System\Source ``` so after defining ROOT I want to have SRC_ROOT = c:\programas\System\Source How can I do that?
``` set ROOT=c:\programs set SRC_ROOT=%ROOT%\System\Source ```
1040655
ms speech from command line
46
2009-06-24 20:04:38
<p>Is there a way to use the MS Speech utility from command line? I can do it on a mac, but can't find any reference to it on Windows XP.</p>
89,853
126,582
2024-03-19 15:04:53
39,647,762
83
2016-09-22 19:51:26
1,644,202
2024-03-19 15:04:53
https://stackoverflow.com/q/1040655
https://stackoverflow.com/a/39647762
<p>My 2 cents on the topic, command line one-liners:</p> <ul> <li><p>on Win8+ (<a href="https://devblogs.microsoft.com/scripting/installing-powershell-on-windows-xp-and-copying-files/" rel="noreferrer">WinXP</a>) using <code>PowerShell.exe</code></p> <pre><code> PowerShell -Command &quot;Add-Type –AssemblyName System....
<p>My 2 cents on the topic, command line one-liners:</p> <ul> <li><p>on Win8+ (<a href="https://devblogs.microsoft.com/scripting/installing-powershell-on-windows-xp-and-copying-files/" rel="noreferrer">WinXP</a>) using <code>PowerShell.exe</code></p> <pre><code> PowerShell -Command &quot;Add-Type –AssemblyName System....
2631, 9393
cmd, text-to-speech
<h1>ms speech from command line</h1> <p>Is there a way to use the MS Speech utility from command line? I can do it on a mac, but can't find any reference to it on Windows XP.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,098
cmd
# ms speech from command line Is there a way to use the MS Speech utility from command line? I can do it on a mac, but can't find any reference to it on Windows XP.
My 2 cents on the topic, command line one-liners: - on Win8+ ([WinXP](https://devblogs.microsoft.com/scripting/installing-powershell-on-windows-xp-and-copying-files/)) using `PowerShell.exe` ``` PowerShell -Command "Add-Type –AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Spe...
4717352
open command prompt window and change current working directory
43
2011-01-17 20:07:01
<p>I'm terribly new to scripting on windows. Using windows 7 64.</p> <p>I'm trying to make a .bat file that I can double click, and have it open a command prompt and automatically <code>cd</code> me to a certain directory.</p> <p>I tried making a .bat file with</p> <pre><code>@ECHO OFF cmd "cd C:\my\destination" </c...
100,750
249,538
2018-02-16 11:09:35
4,717,504
83
2011-01-17 20:24:19
416,521
2011-01-17 20:24:19
https://stackoverflow.com/q/4717352
https://stackoverflow.com/a/4717504
<p>This works for me:</p> <pre><code>@ECHO OFF cmd.exe /K "cd C:\my\destination &amp;&amp; C:" </code></pre> <p>The quoted string is actually two commands (separated by a double ampersand): The first command is to change to the specified directory, the second command is to change to the specified drive letter.</p> <...
<p>This works for me:</p> <pre><code>@ECHO OFF cmd.exe /K "cd C:\my\destination &amp;&amp; C:" </code></pre> <p>The quoted string is actually two commands (separated by a double ampersand): The first command is to change to the specified directory, the second command is to change to the specified drive letter.</p> <...
64, 1231, 7002
batch-file, command-line, windows
<h1>open command prompt window and change current working directory</h1> <p>I'm terribly new to scripting on windows. Using windows 7 64.</p> <p>I'm trying to make a .bat file that I can double click, and have it open a command prompt and automatically <code>cd</code> me to a certain directory.</p> <p>I tried making ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,099
cmd
# open command prompt window and change current working directory I'm terribly new to scripting on windows. Using windows 7 64. I'm trying to make a .bat file that I can double click, and have it open a command prompt and automatically `cd` me to a certain directory. I tried making a .bat file with ``` @ECHO OFF cm...
This works for me: ``` @ECHO OFF cmd.exe /K "cd C:\my\destination && C:" ``` The quoted string is actually two commands (separated by a double ampersand): The first command is to change to the specified directory, the second command is to change to the specified drive letter. Put this in a batch (.BAT) file and when...
3583565
How to skip pause in batch file
54
2010-08-27 11:10:42
<p>In a Windows batch file, myScript.bat runs otherScript.bat, and in otherScript.bat, there's a pause in first line.</p> <p>How can I send a keystroke thast skips the pause in myScript.bat? So my script won't need to take any extract keystroke and won't be blocked by the pause.</p>
29,237
248,430
2023-04-28 08:42:04
3,585,380
82
2010-08-27 14:51:52
7,903
2023-04-28 07:41:32
https://stackoverflow.com/q/3583565
https://stackoverflow.com/a/3585380
<p>One way would be to use the <code>echo</code> command to do the keystroke for you.</p> <p>For example:</p> <h2>myScript.bat</h2> <pre><code>@echo OFF @echo Calling otherScript.bat... @echo | call otherScript.bat @echo Done. </code></pre> <h2>otherScript.bat</h2> <pre><code>pause @echo Hello World </code></pre> <p><...
<p>One way would be to use the <code>echo</code> command to do the keystroke for you.</p> <p>For example:</p> <h2>myScript.bat</h2> <pre><code>@echo OFF @echo Calling otherScript.bat... @echo | call otherScript.bat @echo Done. </code></pre> <h2>otherScript.bat</h2> <pre><code>pause @echo Hello World </code></pre> <p><...
7002
batch-file
<h1>How to skip pause in batch file</h1> <p>In a Windows batch file, myScript.bat runs otherScript.bat, and in otherScript.bat, there's a pause in first line.</p> <p>How can I send a keystroke thast skips the pause in myScript.bat? So my script won't need to take any extract keystroke and won't be blocked by the pause....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,100
cmd
# How to skip pause in batch file In a Windows batch file, myScript.bat runs otherScript.bat, and in otherScript.bat, there's a pause in first line. How can I send a keystroke thast skips the pause in myScript.bat? So my script won't need to take any extract keystroke and won't be blocked by the pause.
One way would be to use the `echo` command to do the keystroke for you. For example: ## myScript.bat ``` @echo OFF @echo Calling otherScript.bat... @echo | call otherScript.bat @echo Done. ``` ## otherScript.bat ``` pause @echo Hello World ``` [Stefan's solution](https://stackoverflow.com/a/3583648/1536976) is m...
11134569
How to show records vertically in mysql command line?
52
2012-06-21 08:48:52
<p>First explaining what is on my mind {I'm not good at English}</p> <p>On <a href="http://alanstorm.com/magento_advanced_orm_entity_attribute_value_part_1" rel="noreferrer">Alan Storm's</a> blog, I found a tricky thing about mysql. I am not sure if he's using the command line or not. The comment section has closed ov...
60,789
817,493
2023-03-09 04:21:50
11,134,765
82
2012-06-21 08:59:36
767,881
2023-03-09 04:21:50
https://stackoverflow.com/q/11134569
https://stackoverflow.com/a/11134765
<p>I think you are using <code>\g</code> instead of <code>\G</code>. Unless you use <code>\G</code> you get default output pattern. Default is <code>\g</code>.</p> <pre><code>mysql&gt; show databases\g +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | t...
<p>I think you are using <code>\g</code> instead of <code>\G</code>. Unless you use <code>\G</code> you get default output pattern. Default is <code>\g</code>.</p> <pre><code>mysql&gt; show databases\g +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | t...
21, 2631, 9938
cmd, command-prompt, mysql
<h1>How to show records vertically in mysql command line?</h1> <p>First explaining what is on my mind {I'm not good at English}</p> <p>On <a href="http://alanstorm.com/magento_advanced_orm_entity_attribute_value_part_1" rel="noreferrer">Alan Storm's</a> blog, I found a tricky thing about mysql. I am not sure if he's u...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,101
cmd
# How to show records vertically in mysql command line? First explaining what is on my mind {I'm not good at English} On [Alan Storm's](http://alanstorm.com/magento_advanced_orm_entity_attribute_value_part_1) blog, I found a tricky thing about mysql. I am not sure if he's using the command line or not. The comment se...
I think you are using `\g` instead of `\G`. Unless you use `\G` you get default output pattern. Default is `\g`. ``` mysql> show databases\g +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0....
7522740
Counting in a FOR loop using Windows Batch script
50
2011-09-22 23:38:15
<p>Can anyone explain this? I am able to count in a loop using the Windows command prompt, using this method:</p> <pre><code>SET /A XCOUNT=0 :loop SET /A XCOUNT+=1 echo %XCOUNT% IF "%XCOUNT%" == "4" ( GOTO end ) ELSE ( GOTO loop ) :end </code></pre> <p>But this method does not work (it prints out "1" for each li...
201,296
118,228
2020-10-16 10:59:41
7,522,822
82
2011-09-22 23:51:48
14,860
2016-12-01 05:16:19
https://stackoverflow.com/q/7522740
https://stackoverflow.com/a/7522822
<p>It's not working because the <em>entire</em> <code>for</code> loop (from the <code>for</code> to the final closing parenthesis, <em>including</em> the commands between those) is being evaluated when it's encountered, <em>before</em> it begins executing.</p> <p>In other words, <code>%count%</code> is replaced with i...
<p>It's not working because the <em>entire</em> <code>for</code> loop (from the <code>for</code> to the final closing parenthesis, <em>including</em> the commands between those) is being evaluated when it's encountered, <em>before</em> it begins executing.</p> <p>In other words, <code>%count%</code> is replaced with i...
64, 2631, 7002
batch-file, cmd, windows
<h1>Counting in a FOR loop using Windows Batch script</h1> <p>Can anyone explain this? I am able to count in a loop using the Windows command prompt, using this method:</p> <pre><code>SET /A XCOUNT=0 :loop SET /A XCOUNT+=1 echo %XCOUNT% IF "%XCOUNT%" == "4" ( GOTO end ) ELSE ( GOTO loop ) :end </code></pre> <p>B...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,102
cmd
# Counting in a FOR loop using Windows Batch script Can anyone explain this? I am able to count in a loop using the Windows command prompt, using this method: ``` SET /A XCOUNT=0 :loop SET /A XCOUNT+=1 echo %XCOUNT% IF "%XCOUNT%" == "4" ( GOTO end ) ELSE ( GOTO loop ) :end ``` But this method does not work (it p...
It's not working because the *entire* `for` loop (from the `for` to the final closing parenthesis, *including* the commands between those) is being evaluated when it's encountered, *before* it begins executing. In other words, `%count%` is replaced with its value `1` before running the loop. What you need is somethin...
42907331
How to install pandas from pip on windows cmd?
47
2017-03-20 15:16:45
<p>I am trying to install pandas using pip to run some pandas-based Python programs. I already installed pip. I tried googling and SO'ing but didn't find a solution to this error. Can somebody share your inputs on this?</p> <pre><code>C:\&gt; pip install pandas </code></pre> <p>Error:</p> <pre><code>pip is not recog...
416,090
1,049,893
2023-08-22 05:26:01
42,907,421
82
2017-03-20 15:20:34
6,622,817
2018-04-24 01:12:54
https://stackoverflow.com/q/42907331
https://stackoverflow.com/a/42907421
<p>Since both <code>pip</code> nor <code>python</code> commands are not installed along Python in Windows, you will need to use the Windows alternative <code>py</code>, which is included by default when you installed Python. Then you have the option to specify a general or specific version number after the <code>py</co...
<p>Since both <code>pip</code> nor <code>python</code> commands are not installed along Python in Windows, you will need to use the Windows alternative <code>py</code>, which is included by default when you installed Python. Then you have the option to specify a general or specific version number after the <code>py</co...
16, 64, 2631, 5119, 67719
cmd, pandas, pip, python, windows
<h1>How to install pandas from pip on windows cmd?</h1> <p>I am trying to install pandas using pip to run some pandas-based Python programs. I already installed pip. I tried googling and SO'ing but didn't find a solution to this error. Can somebody share your inputs on this?</p> <pre><code>C:\&gt; pip install pandas <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,103
cmd
# How to install pandas from pip on windows cmd? I am trying to install pandas using pip to run some pandas-based Python programs. I already installed pip. I tried googling and SO'ing but didn't find a solution to this error. Can somebody share your inputs on this? ``` C:\> pip install pandas ``` Error: ``` pip is ...
Since both `pip` nor `python` commands are not installed along Python in Windows, you will need to use the Windows alternative `py`, which is included by default when you installed Python. Then you have the option to specify a general or specific version number after the `py` command. ``` C:\> py -m pip install p...
10757851
Run a JAR file using a specific JRE
45
2012-05-25 16:08:11
<p>Is there a way on Windows to run a JAR file using a JRE located in a specific folder? Similar to the way Eclipse looks for its JRE in some path you give to it. Either some windows executable code (C or C++) or a Batch file will do the job. Thanks!</p>
158,876
1,091,016
2018-07-31 14:36:52
10,757,888
82
2012-05-25 16:10:57
1,213,327
2012-05-25 16:10:57
https://stackoverflow.com/q/10757851
https://stackoverflow.com/a/10757888
<p>A JRE directory has a bin/java.exe.</p> <p>You can run a jar from that JRE simply with</p> <pre><code>&lt;path_to_jre&gt;/bin/java.exe -jar Executable.jar </code></pre> <p>If you don't want to have to open a console each time, simply put the above line in a .bat file and double click on that.</p>
<p>A JRE directory has a bin/java.exe.</p> <p>You can run a jar from that JRE simply with</p> <pre><code>&lt;path_to_jre&gt;/bin/java.exe -jar Executable.jar </code></pre> <p>If you don't want to have to open a console each time, simply put the above line in a .bat file and double click on that.</p>
17, 64, 4841, 7002
batch-file, jar, java, windows
<h1>Run a JAR file using a specific JRE</h1> <p>Is there a way on Windows to run a JAR file using a JRE located in a specific folder? Similar to the way Eclipse looks for its JRE in some path you give to it. Either some windows executable code (C or C++) or a Batch file will do the job. 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,104
cmd
# Run a JAR file using a specific JRE Is there a way on Windows to run a JAR file using a JRE located in a specific folder? Similar to the way Eclipse looks for its JRE in some path you give to it. Either some windows executable code (C or C++) or a Batch file will do the job. Thanks!
A JRE directory has a bin/java.exe. You can run a jar from that JRE simply with ``` <path_to_jre>/bin/java.exe -jar Executable.jar ``` If you don't want to have to open a console each time, simply put the above line in a .bat file and double click on that.
14946766
CodeIgniter: INSERT multiple records without cycle
34
2013-02-18 22:52:26
<p>It's possible to use multiple INSERT records in CodeIgniter Active Record without for, foreach and etc. ?</p> <p>My current code:</p> <pre><code>foreach($tags as $tag) { $tag = trim($tag); $data = array( 'topic_id' =&gt; $topic_id, 'user_id' =&gt; $user_id, 'text' =&gt; $...
66,987
1,713,229
2025-10-25 05:29:58
14,946,970
82
2013-02-18 23:08:11
1,192,707
2016-08-19 09:28:51
https://stackoverflow.com/q/14946766
https://stackoverflow.com/a/14946970
<p>Codeigniter active record has a function <code>insert_batch</code> i think that is what you need</p> <pre><code>$data = array( array( 'title' =&gt; 'My title' , 'name' =&gt; 'My Name' , 'date' =&gt; 'My date' ), array( 'title' =&gt; 'Another title' , 'name' =&gt; 'Another Name...
<p>Codeigniter active record has a function <code>insert_batch</code> i think that is what you need</p> <pre><code>$data = array( array( 'title' =&gt; 'My title' , 'name' =&gt; 'My Name' , 'date' =&gt; 'My date' ), array( 'title' =&gt; 'Another title' , 'name' =&gt; 'Another Name...
5, 3988, 28708, 58566, 68873
batch-insert, codeigniter, php, query-builder, sql-insert
<h1>CodeIgniter: INSERT multiple records without cycle</h1> <p>It's possible to use multiple INSERT records in CodeIgniter Active Record without for, foreach and etc. ?</p> <p>My current code:</p> <pre><code>foreach($tags as $tag) { $tag = trim($tag); $data = array( 'topic_id' =&gt; $topic_id, ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,105
cmd
# CodeIgniter: INSERT multiple records without cycle It's possible to use multiple INSERT records in CodeIgniter Active Record without for, foreach and etc. ? My current code: ``` foreach($tags as $tag) { $tag = trim($tag); $data = array( 'topic_id' => $topic_id, 'user_id' => $user_id, ...
Codeigniter active record has a function `insert_batch` i think that is what you need ``` $data = array( array( 'title' => 'My title' , 'name' => 'My Name' , 'date' => 'My date' ), array( 'title' => 'Another title' , 'name' => 'Another Name' , 'date' => 'Another date' ) ...
535975
Dealing with quotes in Windows batch scripts
85
2009-02-11 08:57:54
<p>In a Windows batch file, when you do the following: </p> <blockquote> <p><code>set myvar="c:\my music &amp; videos"</code></p> </blockquote> <p>the variable <code>myvar</code> is stored with the quotes included. Honestly I find that very stupid. The quotes are just to tell where the string begins and ends, not ...
129,513
25,700
2025-10-20 16:41:15
8,582,277
81
2011-12-20 21:34:28
1,108,715
2011-12-20 21:34:28
https://stackoverflow.com/q/535975
https://stackoverflow.com/a/8582277
<pre><code>set "myvar=c:\my music &amp; videos" </code></pre> <p>Notice the quotes start before myvar. It's actually that simple. Side note: myvar can't be echoed afterwards unless it's wrapped in quotes because &amp; will be read as a command separator, but it'll still work as a path.</p> <p><a href="http://ss64.co...
<pre><code>set "myvar=c:\my music &amp; videos" </code></pre> <p>Notice the quotes start before myvar. It's actually that simple. Side note: myvar can't be echoed afterwards unless it's wrapped in quotes because &amp; will be read as a command separator, but it'll still work as a path.</p> <p><a href="http://ss64.co...
64, 430, 531, 7002
batch-file, quotes, scripting, windows
<h1>Dealing with quotes in Windows batch scripts</h1> <p>In a Windows batch file, when you do the following: </p> <blockquote> <p><code>set myvar="c:\my music &amp; videos"</code></p> </blockquote> <p>the variable <code>myvar</code> is stored with the quotes included. Honestly I find that very stupid. The quotes a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,106
cmd
# Dealing with quotes in Windows batch scripts In a Windows batch file, when you do the following: > `set myvar="c:\my music & videos"` the variable `myvar` is stored with the quotes included. Honestly I find that very stupid. The quotes are just to tell where the string begins and ends, not to be stored as part of ...
``` set "myvar=c:\my music & videos" ``` Notice the quotes start before myvar. It's actually that simple. Side note: myvar can't be echoed afterwards unless it's wrapped in quotes because & will be read as a command separator, but it'll still work as a path. <http://ss64.com/nt/set.html> under "Variable names can inc...
5062503
batch/bat to copy folder and content at once
69
2011-02-21 05:04:15
<p>I'm writing a batch script that does a copy. I want to script it to copy an entire folder. When I want to copy a single file, I do this </p> <pre><code>copy %~dp0file.txt file.txt </code></pre> <p>If I have a folder with this structure, is there a command to copy this entire folder with its contents all at once w...
250,302
605,098
2018-11-30 14:53:14
5,062,591
81
2011-02-21 05:17:01
103,043
2011-02-21 05:17:01
https://stackoverflow.com/q/5062503
https://stackoverflow.com/a/5062591
<p>if you have <code>xcopy</code>, you can use the <code>/E</code> param, which will copy directories and subdirectories and the files within them, including maintaining the directory structure for empty directories</p> <pre><code>xcopy [source] [destination] /E </code></pre>
<p>if you have <code>xcopy</code>, you can use the <code>/E</code> param, which will copy directories and subdirectories and the files within them, including maintaining the directory structure for empty directories</p> <pre><code>xcopy [source] [destination] /E </code></pre>
64, 218, 4330, 7002
batch-file, copy, directory, windows
<h1>batch/bat to copy folder and content at once</h1> <p>I'm writing a batch script that does a copy. I want to script it to copy an entire folder. When I want to copy a single file, I do this </p> <pre><code>copy %~dp0file.txt file.txt </code></pre> <p>If I have a folder with this structure, is there a command to c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,107
cmd
# batch/bat to copy folder and content at once I'm writing a batch script that does a copy. I want to script it to copy an entire folder. When I want to copy a single file, I do this ``` copy %~dp0file.txt file.txt ``` If I have a folder with this structure, is there a command to copy this entire folder with its con...
if you have `xcopy`, you can use the `/E` param, which will copy directories and subdirectories and the files within them, including maintaining the directory structure for empty directories ``` xcopy [source] [destination] /E ```
20765337
How to fix '.' is not an internal or external command error
65
2013-12-24 18:32:51
<p>I have followed few links to try and solve this issue, such as <a href="http://community.spiceworks.com/how_to/show/36697-how-to-fix-not-recognized-as-an-internal-or-external-command-in-windows" rel="noreferrer">link1</a> , where they have asked to me include the path of the exe in the environment variables. This is...
197,475
1,620,040
2024-02-20 05:09:24
20,765,382
81
2013-12-24 18:36:09
329,928
2015-09-19 20:27:00
https://stackoverflow.com/q/20765337
https://stackoverflow.com/a/20765382
<p>Just leave out the "dot-slash" <code>./</code>:</p> <pre><code>D:\Gesture Recognition\Gesture Recognition\Debug&gt;"Gesture Recognition.exe" </code></pre> <p>Though, if you wanted to, you could use <code>.\</code> and it would work.</p> <pre><code>D:\Gesture Recognition\Gesture Recognition\Debug&gt;.\"Gesture Rec...
<p>Just leave out the "dot-slash" <code>./</code>:</p> <pre><code>D:\Gesture Recognition\Gesture Recognition\Debug&gt;"Gesture Recognition.exe" </code></pre> <p>Though, if you wanted to, you could use <code>.\</code> and it would work.</p> <pre><code>D:\Gesture Recognition\Gesture Recognition\Debug&gt;.\"Gesture Rec...
2631, 9013
cmd, environment-variables
<h1>How to fix '.' is not an internal or external command error</h1> <p>I have followed few links to try and solve this issue, such as <a href="http://community.spiceworks.com/how_to/show/36697-how-to-fix-not-recognized-as-an-internal-or-external-command-in-windows" rel="noreferrer">link1</a> , where they have asked to...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,108
cmd
# How to fix '.' is not an internal or external command error I have followed few links to try and solve this issue, such as [link1](http://community.spiceworks.com/how_to/show/36697-how-to-fix-not-recognized-as-an-internal-or-external-command-in-windows) , where they have asked to me include the path of the exe in th...
Just leave out the "dot-slash" `./`: ``` D:\Gesture Recognition\Gesture Recognition\Debug>"Gesture Recognition.exe" ``` Though, if you wanted to, you could use `.\` and it would work. ``` D:\Gesture Recognition\Gesture Recognition\Debug>.\"Gesture Recognition.exe" ```
11637501
Forwarding all batch file parameters to inner command
50
2012-07-24 18:57:37
<p>For my comfort in Windows, I want to prepare some PHP tools launched like in Unix.</p> <p>f.e.: <code>composer create-project symfony/framework-standard-edition path/</code></p> <p>Not: <code>php composer.phar create-project symfony/framework-standard-edition path/</code></p> <p>I made <strong>composer.bat</stron...
23,947
334,264
2018-09-20 22:37:17
11,637,707
81
2012-07-24 19:09:55
63,733
2012-07-24 19:09:55
https://stackoverflow.com/q/11637501
https://stackoverflow.com/a/11637707
<p>in your batch file <em>composer.bat</em>, simply put:</p> <pre><code>php C:\path\to\composer\composer.phar %* </code></pre>
<p>in your batch file <em>composer.bat</em>, simply put:</p> <pre><code>php C:\path\to\composer\composer.phar %* </code></pre>
64, 1362, 7002
automation, batch-file, windows
<h1>Forwarding all batch file parameters to inner command</h1> <p>For my comfort in Windows, I want to prepare some PHP tools launched like in Unix.</p> <p>f.e.: <code>composer create-project symfony/framework-standard-edition path/</code></p> <p>Not: <code>php composer.phar create-project symfony/framework-standard-...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,109
cmd
# Forwarding all batch file parameters to inner command For my comfort in Windows, I want to prepare some PHP tools launched like in Unix. f.e.: `composer create-project symfony/framework-standard-edition path/` Not: `php composer.phar create-project symfony/framework-standard-edition path/` I made **composer.bat**...
in your batch file *composer.bat*, simply put: ``` php C:\path\to\composer\composer.phar %* ```
9597001
How to set the working directory of a command in a Windows batch file?
54
2012-03-07 06:51:12
<p>Let's say I have these commands:</p> <pre><code>Prog1.exe D:\SomeDir\Prog2.exe Prog3.exe </code></pre> <p>Now, say for the second line, I would like the working directory to be D:\SomeDir, but in Prog1.exe and Prog3.exe I want the default working directory (normally, where my .bat file is). If I try this</p> <pre...
136,173
385,387
2019-07-21 19:02:32
9,598,440
80
2012-03-07 09:03:01
463,115
2012-03-07 09:03:01
https://stackoverflow.com/q/9597001
https://stackoverflow.com/a/9598440
<p>You could use the pushd/popd commands (help with <code>pushd /?</code>)</p> <pre><code>Prog1.exe Pushd D:\SomeDir Prog2.exe popd Prog3.exe </code></pre>
<p>You could use the pushd/popd commands (help with <code>pushd /?</code>)</p> <pre><code>Prog1.exe Pushd D:\SomeDir Prog2.exe popd Prog3.exe </code></pre>
64, 7002, 10201
batch-file, windows, working-directory
<h1>How to set the working directory of a command in a Windows batch file?</h1> <p>Let's say I have these commands:</p> <pre><code>Prog1.exe D:\SomeDir\Prog2.exe Prog3.exe </code></pre> <p>Now, say for the second line, I would like the working directory to be D:\SomeDir, but in Prog1.exe and Prog3.exe I want the defa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,110
cmd
# How to set the working directory of a command in a Windows batch file? Let's say I have these commands: ``` Prog1.exe D:\SomeDir\Prog2.exe Prog3.exe ``` Now, say for the second line, I would like the working directory to be D:\SomeDir, but in Prog1.exe and Prog3.exe I want the default working directory (normally, ...
You could use the pushd/popd commands (help with `pushd /?`) ``` Prog1.exe Pushd D:\SomeDir Prog2.exe popd Prog3.exe ```
10393248
Get filename from string-path?
47
2012-05-01 03:37:30
<p>How do I get the filename from this string?</p> <pre><code>"C:\Documents and Settings\Usuario\Escritorio\hello\test.txt" </code></pre> <p>output:</p> <pre><code>"test.txt" </code></pre> <p>I really tried to find this one before posting, but all the results were contaminated, they talk about getting filenames fro...
90,682
908,879
2025-01-06 16:34:07
10,393,352
80
2012-05-01 03:55:54
1,012,053
2012-05-01 03:55:54
https://stackoverflow.com/q/10393248
https://stackoverflow.com/a/10393352
<p><strong>Method 1</strong></p> <pre><code>for %%F in ("C:\Documents and Settings\Usuario\Escritorio\hello\test.txt") do echo %%~nxF </code></pre> <p>Type <code>HELP FOR</code> for more info.</p> <p><strong>Method 2</strong></p> <pre><code>call :sub "C:\Documents and Settings\Usuario\Escritorio\hello\test.txt" exi...
<p><strong>Method 1</strong></p> <pre><code>for %%F in ("C:\Documents and Settings\Usuario\Escritorio\hello\test.txt") do echo %%~nxF </code></pre> <p>Type <code>HELP FOR</code> for more info.</p> <p><strong>Method 2</strong></p> <pre><code>call :sub "C:\Documents and Settings\Usuario\Escritorio\hello\test.txt" exi...
139, 1062, 7002
batch-file, filenames, string
<h1>Get filename from string-path?</h1> <p>How do I get the filename from this string?</p> <pre><code>"C:\Documents and Settings\Usuario\Escritorio\hello\test.txt" </code></pre> <p>output:</p> <pre><code>"test.txt" </code></pre> <p>I really tried to find this one before posting, but all the results were contaminate...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,111
cmd
# Get filename from string-path? How do I get the filename from this string? ``` "C:\Documents and Settings\Usuario\Escritorio\hello\test.txt" ``` output: ``` "test.txt" ``` I really tried to find this one before posting, but all the results were contaminated, they talk about getting filenames from current dir (I ...
**Method 1** ``` for %%F in ("C:\Documents and Settings\Usuario\Escritorio\hello\test.txt") do echo %%~nxF ``` Type `HELP FOR` for more info. **Method 2** ``` call :sub "C:\Documents and Settings\Usuario\Escritorio\hello\test.txt" exit /b :sub echo %~nx1 exit /b ``` Type `HELP CALL` for more info.
19750653
How to append text files using batch files
39
2013-11-03 07:07:33
<p>How can I append file1 to file2, from a batch file? Text files and only using what is "standard" on windows.</p>
133,139
428,845
2015-02-12 21:07:07
19,750,693
80
2013-11-03 07:14:45
831,878
2013-11-03 07:14:45
https://stackoverflow.com/q/19750653
https://stackoverflow.com/a/19750693
<p>It is as simple as</p> <pre><code>type file1 &gt;&gt; file2 </code></pre>
<p>It is as simple as</p> <pre><code>type file1 &gt;&gt; file2 </code></pre>
64, 7002
batch-file, windows
<h1>How to append text files using batch files</h1> <p>How can I append file1 to file2, from a batch file? Text files and only using what is "standard" on 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,112
cmd
# How to append text files using batch files How can I append file1 to file2, from a batch file? Text files and only using what is "standard" on windows.
It is as simple as ``` type file1 >> file2 ```
28624686
Get 'spawn cmd ENOENT' when try to build Cordova application (event.js:85)
35
2015-02-20 08:38:35
<p>Get this error in windows cmd when I try to build (emulate) Cordova app.</p> <pre><code>D:\dev\Cordova\toDoList&gt;cordova build android Running command: D:\dev\Cordova\toDoList\platforms\android\cordova\build.bat events.js:85 throw er; // Unhandled 'error' event ^ Error: spawn cmd ENOENT at exports._err...
68,231
3,877,938
2020-09-13 15:40:27
28,626,189
80
2015-02-20 10:01:04
3,877,938
2015-02-20 10:01:04
https://stackoverflow.com/q/28624686
https://stackoverflow.com/a/28626189
<p>I checked system variables one more time and found the cause of the problem: missing <code>C:\Windows\System32\</code> variable. I added it and that solved my problem</p> <p>Hope, it help you too.</p>
<p>I checked system variables one more time and found the cause of the problem: missing <code>C:\Windows\System32\</code> variable. I added it and that solved my problem</p> <p>Hope, it help you too.</p>
2631, 24562, 46426, 78331
cmd, cordova, node.js, spawn
<h1>Get 'spawn cmd ENOENT' when try to build Cordova application (event.js:85)</h1> <p>Get this error in windows cmd when I try to build (emulate) Cordova app.</p> <pre><code>D:\dev\Cordova\toDoList&gt;cordova build android Running command: D:\dev\Cordova\toDoList\platforms\android\cordova\build.bat events.js:85 th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,113
cmd
# Get 'spawn cmd ENOENT' when try to build Cordova application (event.js:85) Get this error in windows cmd when I try to build (emulate) Cordova app. ``` D:\dev\Cordova\toDoList>cordova build android Running command: D:\dev\Cordova\toDoList\platforms\android\cordova\build.bat events.js:85 throw er; // Unhandled 'e...
I checked system variables one more time and found the cause of the problem: missing `C:\Windows\System32\` variable. I added it and that solved my problem Hope, it help you too.
1884071
Windows echo command can't echo a user-set variable
34
2009-12-10 21:15:39
<p>What did I do to screw up my CMD shell? Windows XP Pro, open a cmd window and do:</p> <pre><code>C:\&gt;set tt = name C:\&gt;set tt tt = name C:\&gt;echo %tt% %tt% C:\&gt;echo %time% 14:13:28.67 </code></pre> <p>The echo command doesn't work for some reason. I can echo the built-in variables just fine. Tried...
161,482
6,320
2024-10-22 16:05:20
1,884,092
80
2009-12-10 21:18:10
103,043
2022-04-01 06:49:24
https://stackoverflow.com/q/1884071
https://stackoverflow.com/a/1884092
<p>The <code>set</code> command does not take spaces. The proper syntax would be:</p> <pre><code>set tt=name </code></pre> <p>What you have done in your example is set an environment variable <code>tt&lt;space&gt;</code>. With that in mind, you can try this:</p> <pre><code>echo %tt % </code></pre> <p>and see your out...
<p>The <code>set</code> command does not take spaces. The proper syntax would be:</p> <pre><code>set tt=name </code></pre> <p>What you have done in your example is set an environment variable <code>tt&lt;space&gt;</code>. With that in mind, you can try this:</p> <pre><code>echo %tt % </code></pre> <p>and see your out...
64, 2631, 7002, 9013, 40232
batch-file, cmd, environment-variables, windows, windows-console
<h1>Windows echo command can't echo a user-set variable</h1> <p>What did I do to screw up my CMD shell? Windows XP Pro, open a cmd window and do:</p> <pre><code>C:\&gt;set tt = name C:\&gt;set tt tt = name C:\&gt;echo %tt% %tt% C:\&gt;echo %time% 14:13:28.67 </code></pre> <p>The echo command doesn't work for some...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,114
cmd
# Windows echo command can't echo a user-set variable What did I do to screw up my CMD shell? Windows XP Pro, open a cmd window and do: ``` C:\>set tt = name C:\>set tt tt = name C:\>echo %tt% %tt% C:\>echo %time% 14:13:28.67 ``` The echo command doesn't work for some reason. I can echo the built-in variables jus...
The `set` command does not take spaces. The proper syntax would be: ``` set tt=name ``` What you have done in your example is set an environment variable `tt<space>`. With that in mind, you can try this: ``` echo %tt % ``` and see your output.
18423443
Switch statement equivalent in Windows batch file
58
2013-08-24 21:48:47
<p>I wonder if there is a simple way to branch execution in a Windows batch file depending on the value of one single expression. Something akin to switch/case blocks in C, C++, C#, Java, JavaScript, PHP, and other real programming languages.</p> <p>My only workaround is a plain if/else block where the same expression...
199,769
1,083,663
2019-10-21 09:03:01
19,795,694
79
2013-11-05 18:03:10
1,083,663
2018-11-05 21:09:16
https://stackoverflow.com/q/18423443
https://stackoverflow.com/a/19795694
<p>I ended up using label names containing the values for the case expressions as suggested by AjV Jsy. Anyway, I use <code>CALL</code> instead of <code>GOTO</code> to jump into the correct case block and <code>GOTO :EOF</code> to jump back. The following sample code is a complete batch script illustrating the idea.</p...
<p>I ended up using label names containing the values for the case expressions as suggested by AjV Jsy. Anyway, I use <code>CALL</code> instead of <code>GOTO</code> to jump into the correct case block and <code>GOTO :EOF</code> to jump back. The following sample code is a complete batch script illustrating the idea.</p...
7002, 20711
batch-file, switch-statement
<h1>Switch statement equivalent in Windows batch file</h1> <p>I wonder if there is a simple way to branch execution in a Windows batch file depending on the value of one single expression. Something akin to switch/case blocks in C, C++, C#, Java, JavaScript, PHP, and other real programming languages.</p> <p>My only wo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,115
cmd
# Switch statement equivalent in Windows batch file I wonder if there is a simple way to branch execution in a Windows batch file depending on the value of one single expression. Something akin to switch/case blocks in C, C++, C#, Java, JavaScript, PHP, and other real programming languages. My only workaround is a pl...
I ended up using label names containing the values for the case expressions as suggested by AjV Jsy. Anyway, I use `CALL` instead of `GOTO` to jump into the correct case block and `GOTO :EOF` to jump back. The following sample code is a complete batch script illustrating the idea. ``` @ECHO OFF SET /P COLOR="Choose a...
25074877
Can't check signature: public key not found
123
2014-08-01 07:16:58
<p>I try to decrypt file using following command:</p> <pre><code>gpg --output file.txt --decrypt file.pgp </code></pre> <p>File is decrypted successfully but i get an error:</p> <blockquote> <p>"gpg: Can't check signature: public key not found"</p> </blockquote> <p>Any idea, why I get this error?</p>
260,794
3,122,116
2023-03-02 23:10:55
25,074,920
78
2014-08-01 07:19:23
null
2018-03-04 18:05:25
https://stackoverflow.com/q/25074877
https://stackoverflow.com/a/25074920
<p>You get that error because you don't have the public key of the person who signed the message. </p> <p><code>gpg</code> should have given you a message containing the ID of the key that was used to sign it. Obtain the public key from the person who encrypted the file and import it into your keyring (<code>gpg2 --...
<p>You get that error because you don't have the public key of the person who signed the message. </p> <p><code>gpg</code> should have given you a message containing the ID of the key that was used to sign it. Obtain the public key from the person who encrypted the file and import it into your keyring (<code>gpg2 --...
219, 2631, 6735, 7408
cmd, encryption, gnupg, pgp
<h1>Can't check signature: public key not found</h1> <p>I try to decrypt file using following command:</p> <pre><code>gpg --output file.txt --decrypt file.pgp </code></pre> <p>File is decrypted successfully but i get an error:</p> <blockquote> <p>"gpg: Can't check signature: public key not found"</p> </blockquote>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,117
cmd
# Can't check signature: public key not found I try to decrypt file using following command: ``` gpg --output file.txt --decrypt file.pgp ``` File is decrypted successfully but i get an error: > "gpg: Can't check signature: public key not found" Any idea, why I get this error?
You get that error because you don't have the public key of the person who signed the message. `gpg` should have given you a message containing the ID of the key that was used to sign it. Obtain the public key from the person who encrypted the file and import it into your keyring (`gpg2 --import key.asc`); you should ...
7486717
Finding parent process ID on Windows
64
2011-09-20 14:20:25
<h1>Problem</h1> <p>Given a process ID &amp; command-line access on a remote Windows host, how can you find its parent's PID?</p> <h1>Solution</h1> <p>Given Marc B's answer, we can use WMIC (Command samples <a href="https://learn.microsoft.com/en-us/archive/blogs/jhoward/wmic-samples" rel="noreferrer">here</a>) and do ...
115,796
250,993
2021-07-09 00:48:09
7,486,816
77
2011-09-20 14:25:49
118,068
2011-09-20 14:25:49
https://stackoverflow.com/q/7486717
https://stackoverflow.com/a/7486816
<pre><code>C:\&gt; wmic process get processid,parentprocessid,executablepath|find "process id goes here" </code></pre>
<pre><code>C:\&gt; wmic process get processid,parentprocessid,executablepath|find "process id goes here" </code></pre>
64, 2631
cmd, windows
<h1>Finding parent process ID on Windows</h1> <h1>Problem</h1> <p>Given a process ID &amp; command-line access on a remote Windows host, how can you find its parent's PID?</p> <h1>Solution</h1> <p>Given Marc B's answer, we can use WMIC (Command samples <a href="https://learn.microsoft.com/en-us/archive/blogs/jhoward/wm...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,118
cmd
# Finding parent process ID on Windows # Problem Given a process ID & command-line access on a remote Windows host, how can you find its parent's PID? # Solution Given Marc B's answer, we can use WMIC (Command samples [here](https://learn.microsoft.com/en-us/archive/blogs/jhoward/wmic-samples)) and do something lik...
``` C:\> wmic process get processid,parentprocessid,executablepath|find "process id goes here" ```
5683583
Windows Batch Files: if else
63
2011-04-16 00:22:00
<p>I'm doing a simple batch file that requires one argument (you can provide more, but I ignore them).</p> <p>For testing, this is what I have so far.</p> <pre><code>if not %1 == "" ( dir /s/b %1 ) else ( echo no ) </code></pre> <p>Basically, I want to say if an argument is provided, recursively display all ...
201,843
536,607
2016-05-04 17:31:25
5,683,599
77
2011-04-16 00:25:31
34,065
2011-04-16 00:25:31
https://stackoverflow.com/q/5683583
https://stackoverflow.com/a/5683599
<pre><code>if not %1 == "" ( </code></pre> <p>must be</p> <pre><code>if not "%1" == "" ( </code></pre> <p>If an argument isn't given, it's completely empty, not even <code>""</code> (which represents an empty string in most programming languages). So we use the surrounding quotes to detect an empty argument.</p>
<pre><code>if not %1 == "" ( </code></pre> <p>must be</p> <pre><code>if not "%1" == "" ( </code></pre> <p>If an argument isn't given, it's completely empty, not even <code>""</code> (which represents an empty string in most programming languages). So we use the surrounding quotes to detect an empty argument.</p>
64, 7002
batch-file, windows
<h1>Windows Batch Files: if else</h1> <p>I'm doing a simple batch file that requires one argument (you can provide more, but I ignore them).</p> <p>For testing, this is what I have so far.</p> <pre><code>if not %1 == "" ( dir /s/b %1 ) else ( echo no ) </code></pre> <p>Basically, I want to say if an argument...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,119
cmd
# Windows Batch Files: if else I'm doing a simple batch file that requires one argument (you can provide more, but I ignore them). For testing, this is what I have so far. ``` if not %1 == "" ( dir /s/b %1 ) else ( echo no ) ``` Basically, I want to say if an argument is provided, recursively display all th...
``` if not %1 == "" ( ``` must be ``` if not "%1" == "" ( ``` If an argument isn't given, it's completely empty, not even `""` (which represents an empty string in most programming languages). So we use the surrounding quotes to detect an empty argument.
28043589
How can I compress (/ zip ) and uncompress (/ unzip ) files and folders with batch file without using any external tools?
48
2015-01-20 10:57:28
<p>I know the similar questions were asked here a lot, but I'm not completely satisfied with the answers (and even with the questions).</p> <p>The main goal is compatibility - it should be applicable to widest possible range of Windows machines (including <a href="https://en.wikipedia.org/wiki/Windows_XP" rel="norefer...
99,281
388,389
2022-06-18 19:20:32
28,043,695
77
2015-01-20 11:02:11
388,389
2021-04-18 13:13:07
https://stackoverflow.com/q/28043589
https://stackoverflow.com/a/28043695
<p>And here are the answer(s):</p> <h3>1. Using &quot;pure&quot; batch script to zip/unzip file.</h3> <p>It's possible thanks to Frank Westlake's <a href="https://github.com/FrankWestlake/CMD-scripts/blob/master/zip.cmd" rel="noreferrer">ZIP.CMD</a> and <a href="https://github.com/FrankWestlake/CMD-scripts/blob/master...
<p>And here are the answer(s):</p> <h3>1. Using &quot;pure&quot; batch script to zip/unzip file.</h3> <p>It's possible thanks to Frank Westlake's <a href="https://github.com/FrankWestlake/CMD-scripts/blob/master/zip.cmd" rel="noreferrer">ZIP.CMD</a> and <a href="https://github.com/FrankWestlake/CMD-scripts/blob/master...
1, 881, 7002, 75055
.net, batch-file, jscript, zip
<h1>How can I compress (/ zip ) and uncompress (/ unzip ) files and folders with batch file without using any external tools?</h1> <p>I know the similar questions were asked here a lot, but I'm not completely satisfied with the answers (and even with the questions).</p> <p>The main goal is compatibility - it should be...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,120
cmd
# How can I compress (/ zip ) and uncompress (/ unzip ) files and folders with batch file without using any external tools? I know the similar questions were asked here a lot, but I'm not completely satisfied with the answers (and even with the questions). The main goal is compatibility - it should be applicable to w...
And here are the answer(s): ### 1. Using "pure" batch script to zip/unzip file. It's possible thanks to Frank Westlake's [ZIP.CMD](https://github.com/FrankWestlake/CMD-scripts/blob/master/zip.cmd) and [UNZIP.CMD](https://github.com/FrankWestlake/CMD-scripts/blob/master/unzip.cmd)(needs admin permissions and requires ...
26929308
Advantages of spring batch
39
2014-11-14 11:46:47
<p>I understood that spring batch framework processes data in chunks. However, I was thinking that when the same chunking functionality can be acheived through java why do we need to go for batch framework.</p> <p>Could any one please let me know if there are more reasons for going to spring batch framework?</p>
25,334
5,808,787
2018-05-07 05:26:57
26,938,300
77
2014-11-14 20:28:28
618,059
2014-11-14 20:28:28
https://stackoverflow.com/q/26929308
https://stackoverflow.com/a/26938300
<p>Let me rephrase your question a bit and see if this addresses it.</p> <p><strong>What does Spring Batch provide that I'd have to handle myself when building a batch application?</strong></p> <p>Spring Batch served as the basis for JSR-352 (the java batch specification) and since that specification has come out, th...
<p>Let me rephrase your question a bit and see if this addresses it.</p> <p><strong>What does Spring Batch provide that I'd have to handle myself when building a batch application?</strong></p> <p>Spring Batch served as the basis for JSR-352 (the java batch specification) and since that specification has come out, th...
1211, 41895
spring, spring-batch
<h1>Advantages of spring batch</h1> <p>I understood that spring batch framework processes data in chunks. However, I was thinking that when the same chunking functionality can be acheived through java why do we need to go for batch framework.</p> <p>Could any one please let me know if there are more reasons for going ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,121
cmd
# Advantages of spring batch I understood that spring batch framework processes data in chunks. However, I was thinking that when the same chunking functionality can be acheived through java why do we need to go for batch framework. Could any one please let me know if there are more reasons for going to spring batch ...
Let me rephrase your question a bit and see if this addresses it. **What does Spring Batch provide that I'd have to handle myself when building a batch application?** Spring Batch served as the basis for JSR-352 (the java batch specification) and since that specification has come out, there is a lot of Spring Batch n...
9647920
Recursively batch process files with pngquant
38
2012-03-10 16:11:00
<p>I have a lot of images that I would like to process with pngquant. They are organized in a pretty deep directory structure, so it is very time-consuming to manually <code>cd</code> into every directory and run <code>pngquant -ext .png -force 256 *.png</code></p> <p>Is there a way to get this command to run on every...
31,584
179,827
2025-04-26 15:04:47
9,649,214
77
2012-03-10 18:55:31
27,009
2014-07-11 11:52:35
https://stackoverflow.com/q/9647920
https://stackoverflow.com/a/9649214
<p>If you have limited depth of directories and not too many files, then lazy solution:</p> <pre><code>pngquant *.png */*.png */*/*.png </code></pre> <p>A standard solution:</p> <pre><code>find . -name '*.png' -exec pngquant --ext .png --force 256 {} \; </code></pre> <p>and multi-core version:</p> <pre><code>find ...
<p>If you have limited depth of directories and not too many files, then lazy solution:</p> <pre><code>pngquant *.png */*.png */*/*.png </code></pre> <p>A standard solution:</p> <pre><code>find . -name '*.png' -exec pngquant --ext .png --force 256 {} \; </code></pre> <p>and multi-core version:</p> <pre><code>find ...
391, 1383, 4985, 30645
batch-processing, image, png, terminal
<h1>Recursively batch process files with pngquant</h1> <p>I have a lot of images that I would like to process with pngquant. They are organized in a pretty deep directory structure, so it is very time-consuming to manually <code>cd</code> into every directory and run <code>pngquant -ext .png -force 256 *.png</code></p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,122
cmd
# Recursively batch process files with pngquant I have a lot of images that I would like to process with pngquant. They are organized in a pretty deep directory structure, so it is very time-consuming to manually `cd` into every directory and run `pngquant -ext .png -force 256 *.png` Is there a way to get this comman...
If you have limited depth of directories and not too many files, then lazy solution: ``` pngquant *.png */*.png */*/*.png ``` A standard solution: ``` find . -name '*.png' -exec pngquant --ext .png --force 256 {} \; ``` and multi-core version: ``` find . -name '*.png' -print0 | xargs -0 -P8 -L1 pngquant --ext .png...
15884892
Print Windows %PATH% with every entry on new line
22
2013-04-08 17:04:24
<p>I have a task: print all entries of %PATH% variable on new line. For example:</p> <pre><code>C:\Program Files\ C:\Windows C:\Windows\System32 </code></pre> <p>and so on...</p>
20,688
2,032,848
2024-03-08 06:30:37
15,885,269
77
2013-04-08 17:27:14
2,032,848
2023-02-26 01:16:37
https://stackoverflow.com/q/15884892
https://stackoverflow.com/a/15885269
<p>Solved: I used <code>echo %path:;=&amp;echo(%</code></p> <p>Source: <a href="https://web.archive.org/web/20160313231839/http://geekswithblogs.net/AskPaula/archive/2008/12/18/128035.aspx" rel="noreferrer"><em>How do I view/see the PATH in a windows environment?</em></a> (the original link is dead, now linking to Web...
<p>Solved: I used <code>echo %path:;=&amp;echo(%</code></p> <p>Source: <a href="https://web.archive.org/web/20160313231839/http://geekswithblogs.net/AskPaula/archive/2008/12/18/128035.aspx" rel="noreferrer"><em>How do I view/see the PATH in a windows environment?</em></a> (the original link is dead, now linking to Web...
64, 2631
cmd, windows
<h1>Print Windows %PATH% with every entry on new line</h1> <p>I have a task: print all entries of %PATH% variable on new line. For example:</p> <pre><code>C:\Program Files\ C:\Windows C:\Windows\System32 </code></pre> <p>and so on...</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,123
cmd
# Print Windows %PATH% with every entry on new line I have a task: print all entries of %PATH% variable on new line. For example: ``` C:\Program Files\ C:\Windows C:\Windows\System32 ``` and so on...
Solved: I used `echo %path:;=&echo(%` Source: [*How do I view/see the PATH in a windows environment?*](https://web.archive.org/web/20160313231839/http://geekswithblogs.net/AskPaula/archive/2008/12/18/128035.aspx) (the original link is dead, now linking to WebArchive)
4781772
How to test if an executable exists in the %PATH% from a windows batch file?
117
2011-01-24 12:08:03
<p>I'm looking for a simple way to test if an executable exists in the PATH environment variable from a Windows batch file. </p> <p>Usage of external tools not provided by the OS is not allowed. The minimal Windows version required is Windows XP.</p>
76,491
99,834
2019-03-25 07:06:57
4,781,795
76
2011-01-24 12:10:22
73,070
2018-07-17 20:40:59
https://stackoverflow.com/q/4781772
https://stackoverflow.com/a/4781795
<pre><code>for %%X in (myExecutable.exe) do (set FOUND=%%~$PATH:X) if defined FOUND ... </code></pre> <p>If you need this for different extensions, just iterate over <code>PATHEXT</code>:</p> <pre><code>set FOUND= for %%e in (%PATHEXT%) do ( for %%X in (myExecutable%%e) do ( if not defined FOUND ( set FOU...
<pre><code>for %%X in (myExecutable.exe) do (set FOUND=%%~$PATH:X) if defined FOUND ... </code></pre> <p>If you need this for different extensions, just iterate over <code>PATHEXT</code>:</p> <pre><code>set FOUND= for %%e in (%PATHEXT%) do ( for %%X in (myExecutable%%e) do ( if not defined FOUND ( set FOU...
64, 7002, 30645
batch-file, batch-processing, windows
<h1>How to test if an executable exists in the %PATH% from a windows batch file?</h1> <p>I'm looking for a simple way to test if an executable exists in the PATH environment variable from a Windows batch file. </p> <p>Usage of external tools not provided by the OS is not allowed. The minimal Windows version required i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,124
cmd
# How to test if an executable exists in the %PATH% from a windows batch file? I'm looking for a simple way to test if an executable exists in the PATH environment variable from a Windows batch file. Usage of external tools not provided by the OS is not allowed. The minimal Windows version required is Windows XP.
``` for %%X in (myExecutable.exe) do (set FOUND=%%~$PATH:X) if defined FOUND ... ``` If you need this for different extensions, just iterate over `PATHEXT`: ``` set FOUND= for %%e in (%PATHEXT%) do ( for %%X in (myExecutable%%e) do ( if not defined FOUND ( set FOUND=%%~$PATH:X ) ) ) ``` Could be th...
16144716
What does %* mean in a batch file?
68
2013-04-22 10:21:36
<p>I have seen the usage of <code>%*</code> in batch files and command lines.</p> <p>Can someone explain the typical usage of <code>%*</code> with an example?</p>
76,352
1,466,866
2022-06-20 05:11:52
16,144,756
76
2013-04-22 10:23:56
50,079
2013-04-22 10:23:56
https://stackoverflow.com/q/16144716
https://stackoverflow.com/a/16144756
<p>It means "all the parameters in the command line".</p> <p>For example, it's useful when you want to forward the command line from your batch file to another program:</p> <pre><code>REM mybatchfile.cmd echo You called this with arguments: %* echo I will now forward these to the DIR command. dir %* </code></pre>
<p>It means "all the parameters in the command line".</p> <p>For example, it's useful when you want to forward the command line from your batch file to another program:</p> <pre><code>REM mybatchfile.cmd echo You called this with arguments: %* echo I will now forward these to the DIR command. dir %* </code></pre>
64, 2631, 7002
batch-file, cmd, windows
<h1>What does %* mean in a batch file?</h1> <p>I have seen the usage of <code>%*</code> in batch files and command lines.</p> <p>Can someone explain the typical usage of <code>%*</code> with an example?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,125
cmd
# What does %* mean in a batch file? I have seen the usage of `%*` in batch files and command lines. Can someone explain the typical usage of `%*` with an example?
It means "all the parameters in the command line". For example, it's useful when you want to forward the command line from your batch file to another program: ``` REM mybatchfile.cmd echo You called this with arguments: %* echo I will now forward these to the DIR command. dir %* ```
30028709
How do I create a shortcut via command-line in Windows?
62
2015-05-04 11:13:12
<p>I want my .bat script (test.bat) to create a shortcut to itself so that I can copy it to my windows 8 Startup folder. </p> <p>I have written this line of code to copy the file but I haven't yet found a way to create the said shortcut, as you can see it only copies the script.</p> <pre><code>xcopy "C:\Users\Gabriel...
302,763
4,270,033
2021-11-02 16:53:15
30,029,955
76
2015-05-04 12:16:18
1,683,264
2015-05-04 15:04:55
https://stackoverflow.com/q/30028709
https://stackoverflow.com/a/30029955
<p>You could use a PowerShell command. Stick this in your batch script and it'll create a shortcut to <code>%~f0</code> in <code>%userprofile%\Start Menu\Programs\Startup</code>:</p> <pre class="lang-js prettyprint-override"><code>powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('%userprofile%\Start Me...
<p>You could use a PowerShell command. Stick this in your batch script and it'll create a shortcut to <code>%~f0</code> in <code>%userprofile%\Start Menu\Programs\Startup</code>:</p> <pre class="lang-js prettyprint-override"><code>powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('%userprofile%\Start Me...
64, 2631, 7002, 7201, 69665
batch-file, cmd, shortcut, windows, windows-8
<h1>How do I create a shortcut via command-line in Windows?</h1> <p>I want my .bat script (test.bat) to create a shortcut to itself so that I can copy it to my windows 8 Startup folder. </p> <p>I have written this line of code to copy the file but I haven't yet found a way to create the said shortcut, as you can see i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,126
cmd
# How do I create a shortcut via command-line in Windows? I want my .bat script (test.bat) to create a shortcut to itself so that I can copy it to my windows 8 Startup folder. I have written this line of code to copy the file but I haven't yet found a way to create the said shortcut, as you can see it only copies the...
You could use a PowerShell command. Stick this in your batch script and it'll create a shortcut to `%~f0` in `%userprofile%\Start Menu\Programs\Startup`: ``` powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('%userprofile%\Start Menu\Programs\Startup\%~n0.lnk');$s.TargetPath='%~f0';$s.Save()" ``` --- If ...
1515965
How to input a string from user into environment variable from batch file
47
2009-10-04 08:55:06
<p>I want to prompt the user for some input detail, and then use it later as a command line argument.</p>
216,042
72,896
2024-05-15 18:29:05
1,515,980
76
2009-10-04 09:05:02
73,070
2009-10-04 09:05:02
https://stackoverflow.com/q/1515965
https://stackoverflow.com/a/1515980
<p>You can use <code>set</code> with the <code>/p</code> argument:</p> <blockquote> <p><code>SET /P variable=[promptString]</code></p> <p>The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. Th...
<p>You can use <code>set</code> with the <code>/p</code> argument:</p> <blockquote> <p><code>SET /P variable=[promptString]</code></p> <p>The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. Th...
2631, 5486, 7002
batch-file, cmd, input
<h1>How to input a string from user into environment variable from batch file</h1> <p>I want to prompt the user for some input detail, and then use it later as a command line argument.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,127
cmd
# How to input a string from user into environment variable from batch file I want to prompt the user for some input detail, and then use it later as a command line argument.
You can use `set` with the `/p` argument: > `SET /P variable=[promptString]` > > The /P switch allows you to set the value of a variable to a line of input > entered by the user. Displays the specified promptString before reading > the line of input. The promptString can be empty. So, simply use something like ``` s...
21204350
Sonar Setup Undefined Mandatory Properties
43
2014-01-18 12:51:17
<p>Learning how to use SonarQube and was doing a quick install from <a href="http://docs.codehaus.org/display/SONAR/Setup+and+Upgrade">here</a></p> <p>Got all the way down to step 5. My build fails when I execute: C:\sonar-runner\bin\sonar-runner.bat</p> <p>I get the following error: </p> <pre><code>INFO: ------...
55,116
2,020,869
2017-10-29 14:53:40
23,263,320
76
2014-04-24 08:09:16
1,218,618
2014-04-24 08:09:16
https://stackoverflow.com/q/21204350
https://stackoverflow.com/a/23263320
<p>If you have a java project, you must create a sonar-project.properties file in the folder where you execute sonar runner. You must define the following properties inside this file:</p> <pre><code># Required metadata sonar.projectKey=java-sonar-runner-simple sonar.projectName=Simple Java project analyzed with the So...
<p>If you have a java project, you must create a sonar-project.properties file in the folder where you execute sonar runner. You must define the following properties inside this file:</p> <pre><code># Required metadata sonar.projectKey=java-sonar-runner-simple sonar.projectName=Simple Java project analyzed with the So...
7002, 98290
batch-file, sonarqube
<h1>Sonar Setup Undefined Mandatory Properties</h1> <p>Learning how to use SonarQube and was doing a quick install from <a href="http://docs.codehaus.org/display/SONAR/Setup+and+Upgrade">here</a></p> <p>Got all the way down to step 5. My build fails when I execute: C:\sonar-runner\bin\sonar-runner.bat</p> <p>I ge...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,128
cmd
# Sonar Setup Undefined Mandatory Properties Learning how to use SonarQube and was doing a quick install from [here](http://docs.codehaus.org/display/SONAR/Setup+and+Upgrade) Got all the way down to step 5. My build fails when I execute: C:\sonar-runner\bin\sonar-runner.bat I get the following error: ``` INFO: ----...
If you have a java project, you must create a sonar-project.properties file in the folder where you execute sonar runner. You must define the following properties inside this file: ``` # Required metadata sonar.projectKey=java-sonar-runner-simple sonar.projectName=Simple Java project analyzed with the SonarQube Runner...
7225630
How to echo "2" (no quotes) to a file, from a batch script?
74
2011-08-29 02:53:39
<p>How do I echo the number <em>2</em> into a file, from a batch script?</p> <p>This doesn't work:</p> <pre><code>Echo 2&gt;&gt; file.txt </code></pre> <p>because <code>2&gt;&gt;</code> is a special command. :(</p>
36,452
541,686
2020-03-24 23:51:52
7,225,659
75
2011-08-29 03:00:23
225,650
2011-08-29 03:00:23
https://stackoverflow.com/q/7225630
https://stackoverflow.com/a/7225659
<p>Use <code>(ECHO 2)&gt;&gt;file.txt</code>. This will output <code>2</code> without any spaces.</p>
<p>Use <code>(ECHO 2)&gt;&gt;file.txt</code>. This will output <code>2</code> without any spaces.</p>
64, 2631, 7002, 13824, 26698
batch-file, cmd, echo, io-redirection, windows
<h1>How to echo "2" (no quotes) to a file, from a batch script?</h1> <p>How do I echo the number <em>2</em> into a file, from a batch script?</p> <p>This doesn't work:</p> <pre><code>Echo 2&gt;&gt; file.txt </code></pre> <p>because <code>2&gt;&gt;</code> is a special command. :(</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,129
cmd
# How to echo "2" (no quotes) to a file, from a batch script? How do I echo the number *2* into a file, from a batch script? This doesn't work: ``` Echo 2>> file.txt ``` because `2>>` is a special command. :(
Use `(ECHO 2)>>file.txt`. This will output `2` without any spaces.
48321639
Error: "is not recognized as an internal or external command, operable program or batch file"
60
2018-01-18 12:41:26
<p>Whenever I try and run <code>mycommand.exe</code> from my Windows <code>cmd.exe</code> terminal, I get this error:</p> <blockquote> <p>''mycommand.exe' is not recognized as an internal or external command, operable program or batch file'</p> </blockquote> <p><strong>Secondly</strong></p> <p>I've also experienced a s...
800,907
null
2025-07-08 13:27:14
48,321,640
75
2018-01-18 12:41:26
null
2019-04-24 06:36:21
https://stackoverflow.com/q/48321639
https://stackoverflow.com/a/48321640
<p>This is a very common question seen on Stackoverflow.</p> <p>The important part here is not the command displayed in the error, but what the actual error tells you instead.</p> <p>a Quick breakdown on why this error is received.</p> <p><code>cmd.exe</code> Being a terminal window relies on input and system Enviro...
<p>This is a very common question seen on Stackoverflow.</p> <p>The important part here is not the command displayed in the error, but what the actual error tells you instead.</p> <p>a Quick breakdown on why this error is received.</p> <p><code>cmd.exe</code> Being a terminal window relies on input and system Enviro...
2631, 7002
batch-file, cmd
<h1>Error: "is not recognized as an internal or external command, operable program or batch file"</h1> <p>Whenever I try and run <code>mycommand.exe</code> from my Windows <code>cmd.exe</code> terminal, I get this error:</p> <blockquote> <p>''mycommand.exe' is not recognized as an internal or external command, operable...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,130
cmd
# Error: "is not recognized as an internal or external command, operable program or batch file" Whenever I try and run `mycommand.exe` from my Windows `cmd.exe` terminal, I get this error: > ''mycommand.exe' is not recognized as an internal or external command, operable program or batch file' **Secondly** I've also...
This is a very common question seen on Stackoverflow. The important part here is not the command displayed in the error, but what the actual error tells you instead. a Quick breakdown on why this error is received. `cmd.exe` Being a terminal window relies on input and system Environment variables, in order to perfor...
22680954
7zip Ultra LZMA2 compression
51
2014-03-27 07:32:22
<p>How can I convert this settings into command?</p> <p><img src="https://i.sstatic.net/PZkJ2.png" alt="enter image description here" /></p> <p>Here are the results:</p> <pre><code>// Manual Compression (see the image above) Compressed Size: 12,647,451 bytes // Ultra 7z a -t7z Files.7z -mx9 -aoa Compressed Size: 12,67...
75,899
1,015,790
2025-03-27 20:33:48
28,474,846
75
2015-02-12 10:19:10
1,424,087
2025-03-27 20:33:48
https://stackoverflow.com/q/22680954
https://stackoverflow.com/a/28474846
<p>Your command line should be at least:</p> <pre><code>7z a -t7z Files.7z -m0=lzma2 -mx=9 -aoa </code></pre> <p>Note that you'll get better compression when using 1 or 2 threads, not 8. So, even closer to your GUI settings (<code>ms</code> : solid, <code>md</code> : dictionary size, <code>mhe</code> : encrypt header (...
<p>Your command line should be at least:</p> <pre><code>7z a -t7z Files.7z -m0=lzma2 -mx=9 -aoa </code></pre> <p>Note that you'll get better compression when using 1 or 2 threads, not 8. So, even closer to your GUI settings (<code>ms</code> : solid, <code>md</code> : dictionary size, <code>mhe</code> : encrypt header (...
76, 1231, 5680, 7002
7zip, batch-file, command-line, compression
<h1>7zip Ultra LZMA2 compression</h1> <p>How can I convert this settings into command?</p> <p><img src="https://i.sstatic.net/PZkJ2.png" alt="enter image description here" /></p> <p>Here are the results:</p> <pre><code>// Manual Compression (see the image above) Compressed Size: 12,647,451 bytes // Ultra 7z a -t7z Fil...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,131
cmd
# 7zip Ultra LZMA2 compression How can I convert this settings into command? ![enter image description here](https://i.sstatic.net/PZkJ2.png) Here are the results: ``` // Manual Compression (see the image above) Compressed Size: 12,647,451 bytes // Ultra 7z a -t7z Files.7z -mx9 -aoa Compressed Size: 12,676,886 byt...
Your command line should be at least: ``` 7z a -t7z Files.7z -m0=lzma2 -mx=9 -aoa ``` Note that you'll get better compression when using 1 or 2 threads, not 8. So, even closer to your GUI settings (`ms` : solid, `md` : dictionary size, `mhe` : encrypt header (file names), `p` : password) ``` 7z a -t7z -m0=lzma2 -mx=...
4726580
Force Windows Batch Script Return Code 0
45
2011-01-18 16:41:33
<p>A vendor has provided us with a Windows Batch script that needs to have a return code of 0.</p> <p>Per that vendor, there are safe to ignore messages being printed by the script. </p> <p>The scripts are used for quiescing the application for a proper backup. Our backup software requires a return code of 0. </p> <...
50,678
2,764
2011-01-18 19:28:25
4,728,151
74
2011-01-18 19:28:25
49,849
2011-01-18 19:28:25
https://stackoverflow.com/q/4726580
https://stackoverflow.com/a/4728151
<p>End the script with:</p> <pre><code>exit /b 0 </code></pre>
<p>End the script with:</p> <pre><code>exit /b 0 </code></pre>
64, 7002
batch-file, windows
<h1>Force Windows Batch Script Return Code 0</h1> <p>A vendor has provided us with a Windows Batch script that needs to have a return code of 0.</p> <p>Per that vendor, there are safe to ignore messages being printed by the script. </p> <p>The scripts are used for quiescing the application for a proper backup. Our ba...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,132
cmd
# Force Windows Batch Script Return Code 0 A vendor has provided us with a Windows Batch script that needs to have a return code of 0. Per that vendor, there are safe to ignore messages being printed by the script. The scripts are used for quiescing the application for a proper backup. Our backup software requires a...
End the script with: ``` exit /b 0 ```
66362274
How to cold boot emulator using command line(CMD)
35
2021-02-25 04:06:46
<p>I am trying to open emulator without opening android studio every time while developing react-native. Emulator can be opened using this lines of code.</p> <pre><code>cd C:\Users\&lt;your_user_name&gt;\AppData\Local\Android\Sdk\emulator emulator -list-avds emulator @&lt;your_adb_name&gt; </code></pre> <p>But now I wa...
24,898
6,714,214
2024-01-31 06:55:20
66,362,332
74
2021-02-25 04:16:03
6,714,214
2021-02-25 04:16:03
https://stackoverflow.com/q/66362274
https://stackoverflow.com/a/66362332
<p>I am able to solve my this problem using <code>-no-snapshot-load</code> with emulator @&lt;your_adb_name&gt;</p> <pre><code>cd C:\Users\&lt;your_user_name&gt;\AppData\Local\Android\Sdk\emulator emulator -list-avds emulator @&lt;your_adb_name&gt; -no-snapshot-load </code></pre>
<p>I am able to solve my this problem using <code>-no-snapshot-load</code> with emulator @&lt;your_adb_name&gt;</p> <pre><code>cd C:\Users\&lt;your_user_name&gt;\AppData\Local\Android\Sdk\emulator emulator -list-avds emulator @&lt;your_adb_name&gt; -no-snapshot-load </code></pre>
1386, 2631, 22975, 43745, 110853
adb, android, android-emulator, cmd, react-native
<h1>How to cold boot emulator using command line(CMD)</h1> <p>I am trying to open emulator without opening android studio every time while developing react-native. Emulator can be opened using this lines of code.</p> <pre><code>cd C:\Users\&lt;your_user_name&gt;\AppData\Local\Android\Sdk\emulator emulator -list-avds em...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,133
cmd
# How to cold boot emulator using command line(CMD) I am trying to open emulator without opening android studio every time while developing react-native. Emulator can be opened using this lines of code. ``` cd C:\Users\<your_user_name>\AppData\Local\Android\Sdk\emulator emulator -list-avds emulator @<your_adb_name> `...
I am able to solve my this problem using `-no-snapshot-load` with emulator @<your_adb_name> ``` cd C:\Users\<your_user_name>\AppData\Local\Android\Sdk\emulator emulator -list-avds emulator @<your_adb_name> -no-snapshot-load ```
23692470
Why can't I use Docker CMD multiple times to run multiple services?
129
2014-05-16 04:06:20
<p>I have built a base image from Dockerfile named centos+ssh. In centos+ssh's Dockerfile, I use CMD to run ssh service.</p> <p>Then I want to build a image run other service named rabbitmq,the Dockerfile:</p> <pre><code>FROM centos+ssh EXPOSE 22 EXPOSE 4149 CMD /opt/mq/sbin/rabbitmq-server start </code></pre> <p>To...
228,021
2,923,142
2024-10-07 21:02:51
23,721,303
73
2014-05-18 11:17:39
1,449,361
2014-05-18 11:17:39
https://stackoverflow.com/q/23692470
https://stackoverflow.com/a/23721303
<p>Even though CMD is written down in the Dockerfile, it really is runtime information. Just like EXPOSE, but contrary to e.g. RUN and ADD. By this, I mean that you can override it later, in an extending Dockerfile, or simple in your run command, which is what you are experiencing. At all times, there can be only one C...
<p>Even though CMD is written down in the Dockerfile, it really is runtime information. Just like EXPOSE, but contrary to e.g. RUN and ADD. By this, I mean that you can override it later, in an extending Dockerfile, or simple in your run command, which is what you are experiencing. At all times, there can be only one C...
90304, 164539
docker, docker-cmd
<h1>Why can't I use Docker CMD multiple times to run multiple services?</h1> <p>I have built a base image from Dockerfile named centos+ssh. In centos+ssh's Dockerfile, I use CMD to run ssh service.</p> <p>Then I want to build a image run other service named rabbitmq,the Dockerfile:</p> <pre><code>FROM centos+ssh EXPO...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,134
cmd
# Why can't I use Docker CMD multiple times to run multiple services? I have built a base image from Dockerfile named centos+ssh. In centos+ssh's Dockerfile, I use CMD to run ssh service. Then I want to build a image run other service named rabbitmq,the Dockerfile: ``` FROM centos+ssh EXPOSE 22 EXPOSE 4149 CMD /opt/...
Even though CMD is written down in the Dockerfile, it really is runtime information. Just like EXPOSE, but contrary to e.g. RUN and ADD. By this, I mean that you can override it later, in an extending Dockerfile, or simple in your run command, which is what you are experiencing. At all times, there can be only one CMD....
28991391
Getting Error:JRE_HOME variable is not defined correctly when trying to run startup.bat of Apache-Tomcat
51
2015-03-11 15:54:27
<p>When trying to start Tomcat Server through cmd prompt using 'startup.bat' getting error as-"JRE_HOME variable is not defined correctly. The environment variable is needed to Run this program" Defined Environment path as-</p> <p>CATALINA_HOME-C:\Program Files\Java\apache-tomcat-7.0.59\apache-tomcat-7.0.59<br> JAVA_H...
188,898
4,637,378
2019-01-08 17:27:51
28,992,413
73
2015-03-11 16:41:28
4,637,378
2019-01-08 17:27:51
https://stackoverflow.com/q/28991391
https://stackoverflow.com/a/28992413
<p>Got the solution and it's working fine. Set the environment variables as:</p> <ul> <li><code>CATALINA_HOME=C:\Program Files\Java\apache-tomcat-7.0.59\apache-tomcat-7.0.59</code> <em>(path where your Apache Tomcat is)</em></li> <li><code>JAVA_HOME=C:\Program Files\Java\jdk1.8.0_25;</code> <em>(path where your JDK is...
<p>Got the solution and it's working fine. Set the environment variables as:</p> <ul> <li><code>CATALINA_HOME=C:\Program Files\Java\apache-tomcat-7.0.59\apache-tomcat-7.0.59</code> <em>(path where your Apache Tomcat is)</em></li> <li><code>JAVA_HOME=C:\Program Files\Java\jdk1.8.0_25;</code> <em>(path where your JDK is...
17, 80, 1603, 7002
apache, batch-file, java, tomcat
<h1>Getting Error:JRE_HOME variable is not defined correctly when trying to run startup.bat of Apache-Tomcat</h1> <p>When trying to start Tomcat Server through cmd prompt using 'startup.bat' getting error as-"JRE_HOME variable is not defined correctly. The environment variable is needed to Run this program" Defined Env...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,135
cmd
# Getting Error:JRE_HOME variable is not defined correctly when trying to run startup.bat of Apache-Tomcat When trying to start Tomcat Server through cmd prompt using 'startup.bat' getting error as-"JRE_HOME variable is not defined correctly. The environment variable is needed to Run this program" Defined Environment ...
Got the solution and it's working fine. Set the environment variables as: - `CATALINA_HOME=C:\Program Files\Java\apache-tomcat-7.0.59\apache-tomcat-7.0.59` *(path where your Apache Tomcat is)* - `JAVA_HOME=C:\Program Files\Java\jdk1.8.0_25;` *(path where your JDK is)* - `JRE_Home=C:\Program Files\Java\jre1.8.0_25;` *(...
2414956
How to run a ".bat" file during installation?
42
2010-03-10 06:30:22
<p>In a Setup project the executable files such as ".exe , .dll , .js , .vbs" are acceptable but there is no way to run a <code>.bat</code> file in a Custom Action.</p> <p>The question is how to run the <code>*.bat</code> files during installation?</p>
52,686
91,055
2022-12-25 01:14:46
6,286,046
73
2011-06-08 22:27:35
446,820
2022-12-25 01:14:46
https://stackoverflow.com/q/2414956
https://stackoverflow.com/a/6286046
<p>Well, after much searching and trial and error I have solved this. I'm not sure if this is the best way, but it works.</p> <p>Here's the scenario: I have an application I would like to deploy via a Visual Studio Setup project. In addition to my application files, I would like to create a subdirectory in the targe...
<p>Well, after much searching and trial and error I have solved this. I'm not sure if this is the best way, but it works.</p> <p>Here's the scenario: I have an application I would like to deploy via a Visual Studio Setup project. In addition to my application files, I would like to create a subdirectory in the targe...
529, 3597, 7002, 12156, 32472
batch-file, custom-action, installation, setup-project, visual-studio-2008
<h1>How to run a ".bat" file during installation?</h1> <p>In a Setup project the executable files such as ".exe , .dll , .js , .vbs" are acceptable but there is no way to run a <code>.bat</code> file in a Custom Action.</p> <p>The question is how to run the <code>*.bat</code> files during installation?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,136
cmd
# How to run a ".bat" file during installation? In a Setup project the executable files such as ".exe , .dll , .js , .vbs" are acceptable but there is no way to run a `.bat` file in a Custom Action. The question is how to run the `*.bat` files during installation?
Well, after much searching and trial and error I have solved this. I'm not sure if this is the best way, but it works. Here's the scenario: I have an application I would like to deploy via a Visual Studio Setup project. In addition to my application files, I would like to create a subdirectory in the target directory ...
2521818
Best way to view a command return code in DOS
40
2010-03-26 08:07:54
<p>Sometimes I run a command in <code>cmd</code> such as:</p> <pre><code>fc /b file1 file2 </code></pre> <p>and would like to see the return code from fc. Is there a simple way to do this?</p>
61,741
204,479
2025-07-24 06:25:21
2,521,848
73
2010-03-26 08:16:11
276,068
2025-07-24 06:25:21
https://stackoverflow.com/q/2521818
https://stackoverflow.com/a/2521848
<pre><code>echo %ERRORLEVEL% </code></pre> <p>From TechNet, <a href="http://technet.microsoft.com/en-us/library/bb490954.aspx" rel="nofollow noreferrer">Command shell overview</a>: <em>&quot;%ERRORLEVEL% ... Returns the error code of the most recently used command. A non zero value usually indicates an error.&quot;</em...
<pre><code>echo %ERRORLEVEL% </code></pre> <p>From TechNet, <a href="http://technet.microsoft.com/en-us/library/bb490954.aspx" rel="nofollow noreferrer">Command shell overview</a>: <em>&quot;%ERRORLEVEL% ... Returns the error code of the most recently used command. A non zero value usually indicates an error.&quot;</em...
64, 2631, 17564, 22091
cmd, errorlevel, return-code, windows
<h1>Best way to view a command return code in DOS</h1> <p>Sometimes I run a command in <code>cmd</code> such as:</p> <pre><code>fc /b file1 file2 </code></pre> <p>and would like to see the return code from fc. Is there a simple 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,137
cmd
# Best way to view a command return code in DOS Sometimes I run a command in `cmd` such as: ``` fc /b file1 file2 ``` and would like to see the return code from fc. Is there a simple way to do this?
``` echo %ERRORLEVEL% ``` From TechNet, [Command shell overview](http://technet.microsoft.com/en-us/library/bb490954.aspx): *"%ERRORLEVEL% ... Returns the error code of the most recently used command. A non zero value usually indicates an error."* To test for specific error levels in batch files, you may find [this k...
17201507
How to use the start command in a batch file?
30
2013-06-19 21:16:12
<p>I have a batch file that starts an app with a lot of command-line parameters:</p> <pre><code>"C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe" /port:1672 /path:"C:\Code.Net\My App\Iteration 6\REL_6.8.806_PerfEnhanceV\Fusion\Code\CC.Fusion\CC.Fusion.Services" /vpath:"/Fusio...
173,417
9,382
2019-07-11 12:01:27
17,204,218
73
2013-06-20 02:08:14
2,128,947
2013-06-20 02:08:14
https://stackoverflow.com/q/17201507
https://stackoverflow.com/a/17204218
<p>An extra pair of rabbits' ears should do the trick.</p> <pre><code>start "" "C:\Program... </code></pre> <p><code>START</code> regards the first quoted parameter as the window-title, unless it's the only parameter - and any switches up until the executable name are regarded as <code>START</code> switches.</p>
<p>An extra pair of rabbits' ears should do the trick.</p> <pre><code>start "" "C:\Program... </code></pre> <p><code>START</code> regards the first quoted parameter as the window-title, unless it's the only parameter - and any switches up until the executable name are regarded as <code>START</code> switches.</p>
7002, 30645, 34595
batch-file, batch-processing, windows-7
<h1>How to use the start command in a batch file?</h1> <p>I have a batch file that starts an app with a lot of command-line parameters:</p> <pre><code>"C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe" /port:1672 /path:"C:\Code.Net\My App\Iteration 6\REL_6.8.806_PerfEnhanceV\F...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,138
cmd
# How to use the start command in a batch file? I have a batch file that starts an app with a lot of command-line parameters: ``` "C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe" /port:1672 /path:"C:\Code.Net\My App\Iteration 6\REL_6.8.806_PerfEnhanceV\Fusion\Code\CC.Fusion...
An extra pair of rabbits' ears should do the trick. ``` start "" "C:\Program... ``` `START` regards the first quoted parameter as the window-title, unless it's the only parameter - and any switches up until the executable name are regarded as `START` switches.
10518151
How to check in command-line if a given file or directory is locked (used by any process)?
18
2012-05-09 14:27:50
<p>I need to know that before any attempt to do anything with such file.</p>
73,573
393,087
2022-11-03 12:45:20
10,520,609
73
2012-05-09 16:54:07
1,012,053
2016-10-28 13:32:06
https://stackoverflow.com/q/10518151
https://stackoverflow.com/a/10520609
<p>Not sure about locked directories (does Windows have that?)</p> <p>But detecting if a file is being written to by another process is not difficult.</p> <pre><code>@echo off 2&gt;nul ( &gt;&gt;test.txt echo off ) &amp;&amp; (echo file is not locked) || (echo file is locked) </code></pre> <p>I use the following t...
<p>Not sure about locked directories (does Windows have that?)</p> <p>But detecting if a file is being written to by another process is not difficult.</p> <pre><code>@echo off 2&gt;nul ( &gt;&gt;test.txt echo off ) &amp;&amp; (echo file is not locked) || (echo file is locked) </code></pre> <p>I use the following t...
1231, 2216, 7002, 21546
batch-file, command-line, filelock, windows-xp
<h1>How to check in command-line if a given file or directory is locked (used by any process)?</h1> <p>I need to know that before any attempt to do anything with such 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,139
cmd
# How to check in command-line if a given file or directory is locked (used by any process)? I need to know that before any attempt to do anything with such file.
Not sure about locked directories (does Windows have that?) But detecting if a file is being written to by another process is not difficult. ``` @echo off 2>nul ( >>test.txt echo off ) && (echo file is not locked) || (echo file is locked) ``` I use the following test script from another window to place a lock on t...
7985755
How to detect if CMD is running as Administrator/has elevated privileges?
173
2011-11-02 18:50:12
<p>From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.</p> <p>The username doesn't change when "Run as Administrator" is selected, so that doesn't work.</p> <p>If there were a universally available command, which has no effect, but requires administrative privile...
215,776
604,049
2025-01-18 17:07:33
7,986,021
72
2011-11-02 19:10:31
164,188
2024-01-11 19:02:39
https://stackoverflow.com/q/7985755
https://stackoverflow.com/a/7986021
<p><strong>ADDENDUM</strong>: For Windows 8 this will not work; see <a href="https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights#11995662">this excellent answer</a> instead.</p> <hr /> <p>Found this solution here: <a href="https://www.robvanderwoude.com/clevertricks.php" rel="nofollow...
<p><strong>ADDENDUM</strong>: For Windows 8 this will not work; see <a href="https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights#11995662">this excellent answer</a> instead.</p> <hr /> <p>Found this solution here: <a href="https://www.robvanderwoude.com/clevertricks.php" rel="nofollow...
64, 1231, 2631
cmd, command-line, windows
<h1>How to detect if CMD is running as Administrator/has elevated privileges?</h1> <p>From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.</p> <p>The username doesn't change when "Run as Administrator" is selected, so that doesn't work.</p> <p>If there were a univ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,140
cmd
# How to detect if CMD is running as Administrator/has elevated privileges? From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges. The username doesn't change when "Run as Administrator" is selected, so that doesn't work. If there were a universally available comma...
**ADDENDUM**: For Windows 8 this will not work; see [this excellent answer](https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights#11995662) instead. --- Found this solution here: <https://www.robvanderwoude.com/clevertricks.php> ``` AT > NUL IF %ERRORLEVEL% EQU 0 ( ECHO you are A...
649634
How do I run a bat file in the background from another bat file?
104
2009-03-16 08:27:35
<p>I have a "setup" script which I run in the morning which starts all the programs that I need. Now some of those need additional setup of the environment, so I need to wrap them in small BAT scripts.</p> <p>How do I run such a script on Windows XP in the background?</p> <p><code>CALL env-script.bat</code> runs it s...
282,310
34,088
2020-09-16 13:41:06
649,937
72
2009-03-16 10:53:11
73,070
2020-09-16 13:41:06
https://stackoverflow.com/q/649634
https://stackoverflow.com/a/649937
<p>Actually, the following works fine for me and creates new windows:</p> <p>test.cmd:</p> <pre><code>@echo off start test2.cmd start test3.cmd echo Foo pause </code></pre> <p>test2.cmd</p> <pre><code>@echo off echo Test 2 pause exit </code></pre> <p>test3.cmd</p> <pre><code>@echo off echo Test 3 pause exit </code></pr...
<p>Actually, the following works fine for me and creates new windows:</p> <p>test.cmd:</p> <pre><code>@echo off start test2.cmd start test3.cmd echo Foo pause </code></pre> <p>test2.cmd</p> <pre><code>@echo off echo Test 2 pause exit </code></pre> <p>test3.cmd</p> <pre><code>@echo off echo Test 3 pause exit </code></pr...
2216, 2631, 7002
batch-file, cmd, windows-xp
<h1>How do I run a bat file in the background from another bat file?</h1> <p>I have a "setup" script which I run in the morning which starts all the programs that I need. Now some of those need additional setup of the environment, so I need to wrap them in small BAT scripts.</p> <p>How do I run such a script on Window...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,141
cmd
# How do I run a bat file in the background from another bat file? I have a "setup" script which I run in the morning which starts all the programs that I need. Now some of those need additional setup of the environment, so I need to wrap them in small BAT scripts. How do I run such a script on Windows XP in the back...
Actually, the following works fine for me and creates new windows: test.cmd: ``` @echo off start test2.cmd start test3.cmd echo Foo pause ``` test2.cmd ``` @echo off echo Test 2 pause exit ``` test3.cmd ``` @echo off echo Test 3 pause exit ``` Combine that with parameters to `start`, such as `/min`, as Moshe poi...
97371
How do I write a Windows batch script to copy the newest file from a directory?
81
2008-09-18 21:52:05
<p>I need to copy the newest file in a directory to a new location. So far I've found resources on the <a href="http://www.ss64.com/nt/forfiles.html" rel="noreferrer">forfiles</a> command, a <a href="https://stackoverflow.com/q/51837">date-related question</a> here, and another <a href="https://stackoverflow.com/q/5090...
214,007
5,269
2022-07-04 15:17:42
97,782
72
2008-09-18 22:48:39
394
2021-11-05 20:29:08
https://stackoverflow.com/q/97371
https://stackoverflow.com/a/97782
<p>Windows shell, one liner:</p> <pre><code>FOR /F &quot;delims=&quot; %%I IN ('DIR *.* /A-D /B /O:-D') DO COPY &quot;%%I&quot; &lt;&lt;NewDir&gt;&gt; &amp; EXIT </code></pre>
<p>Windows shell, one liner:</p> <pre><code>FOR /F &quot;delims=&quot; %%I IN ('DIR *.* /A-D /B /O:-D') DO COPY &quot;%%I&quot; &lt;&lt;NewDir&gt;&gt; &amp; EXIT </code></pre>
7002, 136758
batch-file, forfiles
<h1>How do I write a Windows batch script to copy the newest file from a directory?</h1> <p>I need to copy the newest file in a directory to a new location. So far I've found resources on the <a href="http://www.ss64.com/nt/forfiles.html" rel="noreferrer">forfiles</a> command, a <a href="https://stackoverflow.com/q/518...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,142
cmd
# How do I write a Windows batch script to copy the newest file from a directory? I need to copy the newest file in a directory to a new location. So far I've found resources on the [forfiles](http://www.ss64.com/nt/forfiles.html) command, a [date-related question](https://stackoverflow.com/q/51837) here, and another ...
Windows shell, one liner: ``` FOR /F "delims=" %%I IN ('DIR *.* /A-D /B /O:-D') DO COPY "%%I" <<NewDir>> & EXIT ```
37071353
How to check if a variable exists in a batch file?
62
2016-05-06 11:34:02
<p>I am using the <code>call</code> command:</p> <pre><code>call beingcalled.bat randomnumber </code></pre> <p>In <strong>beingcalled.bat</strong>:</p> <pre><code>@echo off set call=%1 echo %call% set call=%call%%call% call caller.bat %call%` </code></pre> <p>In <strong>caller.bat</strong>:</p> <pre><code>@echo of...
147,808
6,184,644
2024-01-11 19:32:09
37,073,832
72
2016-05-06 13:36:26
4,427,870
2024-01-11 19:32:09
https://stackoverflow.com/q/37071353
https://stackoverflow.com/a/37073832
<pre><code>IF &quot;%Variable%&quot;==&quot;&quot; ECHO Variable is NOT defined </code></pre> <p>This should help but this works, provided the value of Variable does not contain double quotes. Or you may try. Both worked for me.</p> <pre><code>VERIFY OTHER 2&gt;nul SETLOCAL ENABLEEXTENSIONS IF ERRORLEVEL 1 ECHO Unable ...
<pre><code>IF &quot;%Variable%&quot;==&quot;&quot; ECHO Variable is NOT defined </code></pre> <p>This should help but this works, provided the value of Variable does not contain double quotes. Or you may try. Both worked for me.</p> <pre><code>VERIFY OTHER 2&gt;nul SETLOCAL ENABLEEXTENSIONS IF ERRORLEVEL 1 ECHO Unable ...
64, 2631, 7002
batch-file, cmd, windows
<h1>How to check if a variable exists in a batch file?</h1> <p>I am using the <code>call</code> command:</p> <pre><code>call beingcalled.bat randomnumber </code></pre> <p>In <strong>beingcalled.bat</strong>:</p> <pre><code>@echo off set call=%1 echo %call% set call=%call%%call% call caller.bat %call%` </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,143
cmd
# How to check if a variable exists in a batch file? I am using the `call` command: ``` call beingcalled.bat randomnumber ``` In **beingcalled.bat**: ``` @echo off set call=%1 echo %call% set call=%call%%call% call caller.bat %call%` ``` In **caller.bat**: ``` @echo off set calltwo=%1 echo %calltwo% if "%calltwo%...
``` IF "%Variable%"=="" ECHO Variable is NOT defined ``` This should help but this works, provided the value of Variable does not contain double quotes. Or you may try. Both worked for me. ``` VERIFY OTHER 2>nul SETLOCAL ENABLEEXTENSIONS IF ERRORLEVEL 1 ECHO Unable to enable extensions IF DEFINED MyVar (ECHO MyVar IS...
28174386
How can a .bat file be 'converted' to .exe without third party tools?
53
2015-01-27 15:45:26
<p>There are many reasons to want to 'convert' a <code>.bat</code> to <code>.exe</code> - to hide/obfuscate implementation, passwords, path to resources , to create a service from batch file ... and mainly to make your work to look more complicated and important than it really is.</p> <p>There are also many reasons t...
118,648
388,389
2021-09-02 03:18:40
28,174,404
72
2015-01-27 15:46:12
388,389
2017-12-13 16:14:30
https://stackoverflow.com/q/28174386
https://stackoverflow.com/a/28174404
<p>One very obvious approach is to use <a href="http://ss64.com/nt/iexpress.html" rel="noreferrer">IEXPRESS</a> - the ancient built-in tool that creates self-extracting packages and is capable to execute post extraction commands. So here's <a href="http://ss64.com/nt/iexpress.html" rel="noreferrer">IEXPRESS</a> <a h...
<p>One very obvious approach is to use <a href="http://ss64.com/nt/iexpress.html" rel="noreferrer">IEXPRESS</a> - the ancient built-in tool that creates self-extracting packages and is capable to execute post extraction commands. So here's <a href="http://ss64.com/nt/iexpress.html" rel="noreferrer">IEXPRESS</a> <a h...
1, 7002, 26727
.net, batch-file, iexpress
<h1>How can a .bat file be 'converted' to .exe without third party tools?</h1> <p>There are many reasons to want to 'convert' a <code>.bat</code> to <code>.exe</code> - to hide/obfuscate implementation, passwords, path to resources , to create a service from batch file ... and mainly to make your work to look more com...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,144
cmd
# How can a .bat file be 'converted' to .exe without third party tools? There are many reasons to want to 'convert' a `.bat` to `.exe` - to hide/obfuscate implementation, passwords, path to resources , to create a service from batch file ... and mainly to make your work to look more complicated and important than it r...
One very obvious approach is to use [IEXPRESS](http://ss64.com/nt/iexpress.html) - the ancient built-in tool that creates self-extracting packages and is capable to execute post extraction commands. So here's [IEXPRESS](http://ss64.com/nt/iexpress.html) [sed-directive](http://ss64.com/nt/iexpress-sed.html)/.bat file th...
14237548
batch script - run command on each file in directory
52
2013-01-09 14:34:12
<p>I need to convert some xls files into xlsx files. I can successfully convert one xls file into xlsx by running this command into cmd prompt (windows):</p> <pre><code>ssconvert inputFileName.xls outputFileName.xlsx </code></pre> <p>(ssconvert is a Gnumeric's command-line utility that can convert between different s...
129,360
1,054,151
2020-01-15 23:41:01
14,237,730
72
2013-01-09 14:43:29
1,280,587
2020-01-15 23:41:01
https://stackoverflow.com/q/14237548
https://stackoverflow.com/a/14237730
<pre><code>for /r %%v in (*.xls) do ssconvert "%%v" "%%vx" </code></pre> <p>a couple have people have asked me to explain this, so:</p> <p>Part 1: <code>for /r %%v in (*.xls)</code></p> <p>This part returns an array of files in the current directory that have the <code>xls</code> extension. The <code>%%</code> may l...
<pre><code>for /r %%v in (*.xls) do ssconvert "%%v" "%%vx" </code></pre> <p>a couple have people have asked me to explain this, so:</p> <p>Part 1: <code>for /r %%v in (*.xls)</code></p> <p>This part returns an array of files in the current directory that have the <code>xls</code> extension. The <code>%%</code> may l...
631, 2631, 7002, 139301
batch-file, cmd, foreach, ssconvert
<h1>batch script - run command on each file in directory</h1> <p>I need to convert some xls files into xlsx files. I can successfully convert one xls file into xlsx by running this command into cmd prompt (windows):</p> <pre><code>ssconvert inputFileName.xls outputFileName.xlsx </code></pre> <p>(ssconvert is a Gnumer...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,145
cmd
# batch script - run command on each file in directory I need to convert some xls files into xlsx files. I can successfully convert one xls file into xlsx by running this command into cmd prompt (windows): ``` ssconvert inputFileName.xls outputFileName.xlsx ``` (ssconvert is a Gnumeric's command-line utility that ca...
``` for /r %%v in (*.xls) do ssconvert "%%v" "%%vx" ``` a couple have people have asked me to explain this, so: Part 1: `for /r %%v in (*.xls)` This part returns an array of files in the current directory that have the `xls` extension. The `%%` may look a little curious. This is basically the special `%` character f...
20791264
How to replace all spaces by underscores in all file names of a folder?
45
2013-12-26 21:06:53
<p>I'm trying to rename all the files inside a folder (all .exe files). I want to replace all the spaces with underscores, e.g. <code>qwe qwe qwe asd.exe</code> to <code>qwe_qwe_qwe_asd.exe</code>.</p> <p>I need to do this using the command line. I tried a lot of possible solutions I found on internet and even on this...
114,161
1,742,973
2025-03-27 05:46:03
20,791,817
72
2013-12-26 21:58:00
2,861,476
2013-12-26 21:58:00
https://stackoverflow.com/q/20791264
https://stackoverflow.com/a/20791817
<p>A one liner</p> <pre><code>cmd /e:on /v:on /c "for %f in ("* *.exe") do (set "n=%~nxf" &amp; set "n=!n: =_!" &amp; ren "%~ff" "!n!" )" </code></pre> <p>Spawn a cmd instance, with extensions and delayed expansion enabled, and for each exe file with spaces in name, replace spaces with underscores and rename the file...
<p>A one liner</p> <pre><code>cmd /e:on /v:on /c "for %f in ("* *.exe") do (set "n=%~nxf" &amp; set "n=!n: =_!" &amp; ren "%~ff" "!n!" )" </code></pre> <p>Spawn a cmd instance, with extensions and delayed expansion enabled, and for each exe file with spaces in name, replace spaces with underscores and rename the file...
64, 2498, 2631
cmd, replace, windows
<h1>How to replace all spaces by underscores in all file names of a folder?</h1> <p>I'm trying to rename all the files inside a folder (all .exe files). I want to replace all the spaces with underscores, e.g. <code>qwe qwe qwe asd.exe</code> to <code>qwe_qwe_qwe_asd.exe</code>.</p> <p>I need to do this using the comma...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,146
cmd
# How to replace all spaces by underscores in all file names of a folder? I'm trying to rename all the files inside a folder (all .exe files). I want to replace all the spaces with underscores, e.g. `qwe qwe qwe asd.exe` to `qwe_qwe_qwe_asd.exe`. I need to do this using the command line. I tried a lot of possible sol...
A one liner ``` cmd /e:on /v:on /c "for %f in ("* *.exe") do (set "n=%~nxf" & set "n=!n: =_!" & ren "%~ff" "!n!" )" ``` Spawn a cmd instance, with extensions and delayed expansion enabled, and for each exe file with spaces in name, replace spaces with underscores and rename the file with the new name
12434863
Executing a batch script on Windows shutdown
45
2012-09-15 05:45:33
<p>Is there any way, in <code>Windows 7 Professional</code>, to run a batch script (e.g., a .BAT file) when the user clicks on "shutdown" (not a batch file scheduled to shut down the machine, just one that runs only if the user clicks on "shutdown")?</p> <p>Ideally, such a script would show the command prompt window a...
158,189
834,316
2023-04-28 13:14:27
12,434,923
72
2012-09-15 05:56:46
761,095
2022-11-09 16:06:46
https://stackoverflow.com/q/12434863
https://stackoverflow.com/a/12434923
<p>You can create a local computer policy on Windows. See the TechNet at <a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789197(v=ws.11)" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-...
<p>You can create a local computer policy on Windows. See the TechNet at <a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789197(v=ws.11)" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-...
64, 4921, 7002, 11786, 34595
batch-file, group-policy, shutdown, windows, windows-7
<h1>Executing a batch script on Windows shutdown</h1> <p>Is there any way, in <code>Windows 7 Professional</code>, to run a batch script (e.g., a .BAT file) when the user clicks on "shutdown" (not a batch file scheduled to shut down the machine, just one that runs only if the user clicks on "shutdown")?</p> <p>Ideally...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,147
cmd
# Executing a batch script on Windows shutdown Is there any way, in `Windows 7 Professional`, to run a batch script (e.g., a .BAT file) when the user clicks on "shutdown" (not a batch file scheduled to shut down the machine, just one that runs only if the user clicks on "shutdown")? Ideally, such a script would show ...
You can create a local computer policy on Windows. See the TechNet at <https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789197(v=ws.11)> 1. Run `gpedit.msc` to open the Group Policy Editor, 2. Navigate to **Computer Configuration | Windows Settings | Scripts (Startup...
4451013
Check if process returns 0 with batch file
45
2010-12-15 14:35:57
<p>I want to start a process with a batch file and if it returns nonzero, do something else. I need the correct syntax for that.</p> <p>Something like this:</p> <pre><code>::x.bat @set RetCode=My.exe @if %retcode% is nonzero handleError.exe </code></pre> <p>As a bonus, you may consider answering the following qu...
145,408
469,935
2020-09-15 09:31:48
4,451,060
72
2010-12-15 14:40:34
17,428
2016-01-07 10:13:31
https://stackoverflow.com/q/4451013
https://stackoverflow.com/a/4451060
<p><code>ERRORLEVEL</code> will contain the return code of the last command. Sadly you can only check <code>&gt;=</code> for it. </p> <p>Note specifically this line in the <a href="http://technet.microsoft.com/en-us/library/cc772933.aspx" rel="noreferrer">MSDN documentation for the <code>If</code> statement</a>:</p> ...
<p><code>ERRORLEVEL</code> will contain the return code of the last command. Sadly you can only check <code>&gt;=</code> for it. </p> <p>Note specifically this line in the <a href="http://technet.microsoft.com/en-us/library/cc772933.aspx" rel="noreferrer">MSDN documentation for the <code>If</code> statement</a>:</p> ...
64, 5910, 7002, 10021
batch-file, exit-code, process, windows
<h1>Check if process returns 0 with batch file</h1> <p>I want to start a process with a batch file and if it returns nonzero, do something else. I need the correct syntax for that.</p> <p>Something like this:</p> <pre><code>::x.bat @set RetCode=My.exe @if %retcode% is nonzero handleError.exe </code></pre> <p>As ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,148
cmd
# Check if process returns 0 with batch file I want to start a process with a batch file and if it returns nonzero, do something else. I need the correct syntax for that. Something like this: ``` ::x.bat @set RetCode=My.exe @if %retcode% is nonzero handleError.exe ``` As a bonus, you may consider answering the ...
`ERRORLEVEL` will contain the return code of the last command. Sadly you can only check `>=` for it. Note specifically this line in the [MSDN documentation for the `If` statement](http://technet.microsoft.com/en-us/library/cc772933.aspx): > **errorlevel *Number*** > > Specifies a true > condition only if the previous...
37046771
Base64 Encode "string" - command-line Windows?
73
2016-05-05 09:15:31
<p>I have found numerous ways to base64 encode whole files using the command-line on Windows, but I can't seem to find a simple way to batch encode just a "string" using a command-line utility.</p> <p>How does one do this, for use in a batch file for example?</p>
274,472
776,264
2025-10-28 17:02:42
37,049,844
71
2016-05-05 11:49:22
1,683,264
2017-06-16 12:00:58
https://stackoverflow.com/q/37046771
https://stackoverflow.com/a/37049844
<p>Here's a PowerShell one-liner you can run from a cmd console that'll Base64 encode a string.</p> <pre><code>powershell "[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(\"Hello world!\"))" </code></pre> <p>It's probably not as fast as npocmaka's solution, but you could <a href="http://ss64.com/nt/doskey.ht...
<p>Here's a PowerShell one-liner you can run from a cmd console that'll Base64 encode a string.</p> <pre><code>powershell "[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(\"Hello world!\"))" </code></pre> <p>It's probably not as fast as npocmaka's solution, but you could <a href="http://ss64.com/nt/doskey.ht...
64, 7002
batch-file, windows
<h1>Base64 Encode "string" - command-line Windows?</h1> <p>I have found numerous ways to base64 encode whole files using the command-line on Windows, but I can't seem to find a simple way to batch encode just a "string" using a command-line utility.</p> <p>How does one do this, for use in a batch file for example?</p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,149
cmd
# Base64 Encode "string" - command-line Windows? I have found numerous ways to base64 encode whole files using the command-line on Windows, but I can't seem to find a simple way to batch encode just a "string" using a command-line utility. How does one do this, for use in a batch file for example?
Here's a PowerShell one-liner you can run from a cmd console that'll Base64 encode a string. ``` powershell "[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(\"Hello world!\"))" ``` It's probably not as fast as npocmaka's solution, but you could [set a console macro with it](http://ss64.com/nt/doskey.html). ...
6657777
Open text file and program shortcut in a Windows batch file
42
2011-07-11 23:12:32
<p>I have two files in the same folder that I'd like to run. One is a <code>.txt</code> file, and the other is the program shortcut to an <code>.exe</code>. I'd like to make a batch file in the same location to open the text file and the shortcut then close the batch file (but the text file and program remain open).</p...
359,274
134,360
2022-10-07 12:30:34
6,657,844
71
2011-07-11 23:21:35
134,360
2011-07-11 23:21:35
https://stackoverflow.com/q/6657777
https://stackoverflow.com/a/6657844
<p>I was able to figure out the solution:</p> <pre><code>start notepad "myfile.txt" "myshortcut.lnk" exit </code></pre>
<p>I was able to figure out the solution:</p> <pre><code>start notepad "myfile.txt" "myshortcut.lnk" exit </code></pre>
1231, 2631, 7002, 9938
batch-file, cmd, command-line, command-prompt
<h1>Open text file and program shortcut in a Windows batch file</h1> <p>I have two files in the same folder that I'd like to run. One is a <code>.txt</code> file, and the other is the program shortcut to an <code>.exe</code>. I'd like to make a batch file in the same location to open the text file and the shortcut then...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,150
cmd
# Open text file and program shortcut in a Windows batch file I have two files in the same folder that I'd like to run. One is a `.txt` file, and the other is the program shortcut to an `.exe`. I'd like to make a batch file in the same location to open the text file and the shortcut then close the batch file (but the ...
I was able to figure out the solution: ``` start notepad "myfile.txt" "myshortcut.lnk" exit ```
30282784
Variables are not behaving as expected
40
2015-05-17 02:35:49
<p>I've been wrestling trying to get the syntax right on this batch file and I cannot figure out why some things aren't working.</p> <ol> <li>The variable <code>i</code> is not getting incremented each time I do it.</li> <li>Concatenation on <code>strc</code> doesn't seem to concatenate.</li> </ol> <p>Here is my code...
13,592
2,026,832
2021-11-03 03:42:39
30,284,028
71
2015-05-17 06:29:05
2,152,082
2021-11-03 03:42:39
https://stackoverflow.com/q/30282784
https://stackoverflow.com/a/30284028
<p>You are not the first, who fell into the famous &quot;delayed expansion trap&quot; (and you won't be the last).</p> <p>You need delayed expansion if you want to use a variable, that you changed in the same block (a block is a series of commands within parentheses <code>(</code>and <code>)</code>).</p> <p>Delayed va...
<p>You are not the first, who fell into the famous &quot;delayed expansion trap&quot; (and you won't be the last).</p> <p>You need delayed expansion if you want to use a variable, that you changed in the same block (a block is a series of commands within parentheses <code>(</code>and <code>)</code>).</p> <p>Delayed va...
64, 2631, 7002, 9013, 19675
batch-file, cmd, delayedvariableexpansion, environment-variables, windows
<h1>Variables are not behaving as expected</h1> <p>I've been wrestling trying to get the syntax right on this batch file and I cannot figure out why some things aren't working.</p> <ol> <li>The variable <code>i</code> is not getting incremented each time I do it.</li> <li>Concatenation on <code>strc</code> doesn't see...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,151
cmd
# Variables are not behaving as expected I've been wrestling trying to get the syntax right on this batch file and I cannot figure out why some things aren't working. 1. The variable `i` is not getting incremented each time I do it. 2. Concatenation on `strc` doesn't seem to concatenate. Here is my code: ``` set i=...
You are not the first, who fell into the famous "delayed expansion trap" (and you won't be the last). You need delayed expansion if you want to use a variable, that you changed in the same block (a block is a series of commands within parentheses `(`and `)`). Delayed variables are referenced with `!var!` instead of `...
37878185
What does '__COMPAT_LAYER' actually do?
38
2016-06-17 09:38:10
<p>Recently, i was trying to give my <strong>application administrator rights without system asking for &quot;Do you want to give administrator rights?&quot;</strong> and i found a way which is working perfectly.</p> <p><strong>Solution I Found</strong></p> <p>I created a bat file named <em><strong>nonadmin.bat</strong...
109,584
2,994,869
2025-05-29 08:33:49
37,881,453
71
2016-06-17 12:21:04
4,158,862
2024-01-26 20:54:10
https://stackoverflow.com/q/37878185
https://stackoverflow.com/a/37881453
<p><strong>__COMPAT_LAYER, and How To Use It</strong><br> __COMPAT_LAYER is a system environment variable that allows you to set compatibility layers, which are the settings you can adjust when you right-click on an executable, select Properties, and go to the Compatibility tab.</p> <p><img src="https://i.sstatic.net/D...
<p><strong>__COMPAT_LAYER, and How To Use It</strong><br> __COMPAT_LAYER is a system environment variable that allows you to set compatibility layers, which are the settings you can adjust when you right-click on an executable, select Properties, and go to the Compatibility tab.</p> <p><img src="https://i.sstatic.net/D...
64, 934, 5623, 7002, 56021
administrator, admin-rights, batch-file, compatibility, windows
<h1>What does '__COMPAT_LAYER' actually do?</h1> <p>Recently, i was trying to give my <strong>application administrator rights without system asking for &quot;Do you want to give administrator rights?&quot;</strong> and i found a way which is working perfectly.</p> <p><strong>Solution I Found</strong></p> <p>I created ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,152
cmd
# What does '__COMPAT_LAYER' actually do? Recently, i was trying to give my **application administrator rights without system asking for "Do you want to give administrator rights?"** and i found a way which is working perfectly. **Solution I Found** I created a bat file named ***nonadmin.bat*** and wrote the below c...
**__COMPAT_LAYER, and How To Use It** __COMPAT_LAYER is a system environment variable that allows you to set compatibility layers, which are the settings you can adjust when you right-click on an executable, select Properties, and go to the Compatibility tab. ![Imgur](https://i.sstatic.net/DJtKd.png) There are seve...
20159122
How to silently delete files with a bat file
34
2013-11-23 05:55:14
<pre><code>del /s .jpg </code></pre> <p>deletes all .jpgs .. but the problem is: it shows, in cmd when executed =><br> C:\blabla..\this.jpg is deleted..</p> <p>I want to turn this off. Such that user will not know what is happening (i.e, what files are being deleted).</p>
59,549
3,019,006
2021-09-06 21:49:04
20,159,242
71
2013-11-23 06:09:22
661,447
2013-11-23 06:09:22
https://stackoverflow.com/q/20159122
https://stackoverflow.com/a/20159242
<p>Turn echo off to suppress showing the command being run, and redirect output to null as @Sico suggested.</p> <pre><code>@echo off del /s *.jpg &gt;nul 2&gt;&amp;1 </code></pre> <p>You should see nothing displayed when the bat file is run.</p>
<p>Turn echo off to suppress showing the command being run, and redirect output to null as @Sico suggested.</p> <pre><code>@echo off del /s *.jpg &gt;nul 2&gt;&amp;1 </code></pre> <p>You should see nothing displayed when the bat file is run.</p>
1231, 7002, 31134
batch-file, command-line, command-line-arguments
<h1>How to silently delete files with a bat file</h1> <pre><code>del /s .jpg </code></pre> <p>deletes all .jpgs .. but the problem is: it shows, in cmd when executed =><br> C:\blabla..\this.jpg is deleted..</p> <p>I want to turn this off. Such that user will not know what is happening (i.e, what files are being d...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,153
cmd
# How to silently delete files with a bat file ``` del /s .jpg ``` deletes all .jpgs .. but the problem is: it shows, in cmd when executed => C:\blabla..\this.jpg is deleted.. I want to turn this off. Such that user will not know what is happening (i.e, what files are being deleted).
Turn echo off to suppress showing the command being run, and redirect output to null as @Sico suggested. ``` @echo off del /s *.jpg >nul 2>&1 ``` You should see nothing displayed when the bat file is run.
28597379
What does %~1 do in this batch file?
30
2015-02-19 01:46:55
<p>I found this code, but there are parts that I do not understand.</p> <p>This is my code:</p> <p>Main.bat:</p> <pre><code>@echo off set "CallCount=0" set "Mood=" set /P "Mood=Your mood is: " call Receive.bat "%Mood%" rem *Random stuff* set "Food=" set /P "Food=The food you want is: " call Receive.bat "%Food%" set ...
58,421
4,573,473
2023-09-27 01:00:58
28,597,415
71
2015-02-19 01:52:48
14,749
2023-09-27 01:00:58
https://stackoverflow.com/q/28597379
https://stackoverflow.com/a/28597415
<p><code>%1</code> is the first argument from the invoking command line. If the passed argument has quotes around it, <code>%1</code> includes the quotes. Where as, <code>%~1</code> provides the argument value with quotes removed.</p> <p>Helpful reference <a href="http://ss64.com/nt/syntax-args.html" rel="noreferrer">h...
<p><code>%1</code> is the first argument from the invoking command line. If the passed argument has quotes around it, <code>%1</code> includes the quotes. Where as, <code>%~1</code> provides the argument value with quotes removed.</p> <p>Helpful reference <a href="http://ss64.com/nt/syntax-args.html" rel="noreferrer">h...
7002
batch-file
<h1>What does %~1 do in this batch file?</h1> <p>I found this code, but there are parts that I do not understand.</p> <p>This is my code:</p> <p>Main.bat:</p> <pre><code>@echo off set "CallCount=0" set "Mood=" set /P "Mood=Your mood is: " call Receive.bat "%Mood%" rem *Random stuff* set "Food=" set /P "Food=The food...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,154
cmd
# What does %~1 do in this batch file? I found this code, but there are parts that I do not understand. This is my code: Main.bat: ``` @echo off set "CallCount=0" set "Mood=" set /P "Mood=Your mood is: " call Receive.bat "%Mood%" rem *Random stuff* set "Food=" set /P "Food=The food you want is: " call Receive.bat "...
`%1` is the first argument from the invoking command line. If the passed argument has quotes around it, `%1` includes the quotes. Where as, `%~1` provides the argument value with quotes removed. Helpful reference [here](http://ss64.com/nt/syntax-args.html).
905226
What is equivalent to Linux mkdir -p in Windows?
105
2009-05-25 03:32:47
<p>In Linux, <code>mkdir -p</code> creates a folder tree.</p> <p>What is the equivalent option in Windows to create a folder tree? Is there any?</p>
176,636
110,473
2020-05-06 08:00:12
905,239
70
2009-05-25 03:39:08
14,860
2009-05-25 03:53:20
https://stackoverflow.com/q/905226
https://stackoverflow.com/a/905239
<p>The Windows mkdir does it automatically if command extensions are enabled. They are on just about every box I've ever used but, if they're not, you can create your own script to do it:</p> <pre><code>@echo off setlocal enableextensions md %1 endlocal </code></pre> <p>Expanding:</p> <p>Command extensions are an ad...
<p>The Windows mkdir does it automatically if command extensions are enabled. They are on just about every box I've ever used but, if they're not, you can create your own script to do it:</p> <pre><code>@echo off setlocal enableextensions md %1 endlocal </code></pre> <p>Expanding:</p> <p>Command extensions are an ad...
64, 2631, 7002, 24423
batch-file, cmd, mkdir, windows
<h1>What is equivalent to Linux mkdir -p in Windows?</h1> <p>In Linux, <code>mkdir -p</code> creates a folder tree.</p> <p>What is the equivalent option in Windows to create a folder tree? Is there any?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,155
cmd
# What is equivalent to Linux mkdir -p in Windows? In Linux, `mkdir -p` creates a folder tree. What is the equivalent option in Windows to create a folder tree? Is there any?
The Windows mkdir does it automatically if command extensions are enabled. They are on just about every box I've ever used but, if they're not, you can create your own script to do it: ``` @echo off setlocal enableextensions md %1 endlocal ``` Expanding: Command extensions are an added feature of cmd.exe which allow...
21704041
creating batch script to unzip a file without additional zip tools
54
2014-02-11 14:03:47
<p>I'm trying to make a .bat script for windows 7 x64 to create a folder, unzip a file into that folder without having to use additional addons like 7zip or unzip. Been searching and it seemed like windows doesn't have builtins to allow unzip easily in command. Can I unzip/expand files without additional addons? </p>
215,335
3,103,276
2025-11-30 20:59:32
21,709,923
70
2014-02-11 18:20:10
2,282,445
2025-11-21 12:25:57
https://stackoverflow.com/q/21704041
https://stackoverflow.com/a/21709923
<p>Try this:</p> <pre><code>@echo off setlocal EnableExtensions DisableDelayedExpansion cd /d &quot;%~dp0&quot; Call :UnZipFile &quot;C:\Temp\&quot; &quot;c:\path\to\batch.zip&quot; exit /b :UnZipFile &lt;ExtractTo&gt; &lt;newzipfile&gt; set vbs=&quot;%temp%\_.vbs&quot; if exist %vbs% del /a /f %vbs% &gt;%vbs% echo S...
<p>Try this:</p> <pre><code>@echo off setlocal EnableExtensions DisableDelayedExpansion cd /d &quot;%~dp0&quot; Call :UnZipFile &quot;C:\Temp\&quot; &quot;c:\path\to\batch.zip&quot; exit /b :UnZipFile &lt;ExtractTo&gt; &lt;newzipfile&gt; set vbs=&quot;%temp%\_.vbs&quot; if exist %vbs% del /a /f %vbs% &gt;%vbs% echo S...
64, 7002
batch-file, windows
<h1>creating batch script to unzip a file without additional zip tools</h1> <p>I'm trying to make a .bat script for windows 7 x64 to create a folder, unzip a file into that folder without having to use additional addons like 7zip or unzip. Been searching and it seemed like windows doesn't have builtins to allow unzip e...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,156
cmd
# creating batch script to unzip a file without additional zip tools I'm trying to make a .bat script for windows 7 x64 to create a folder, unzip a file into that folder without having to use additional addons like 7zip or unzip. Been searching and it seemed like windows doesn't have builtins to allow unzip easily in ...
Try this: ``` @echo off setlocal EnableExtensions DisableDelayedExpansion cd /d "%~dp0" Call :UnZipFile "C:\Temp\" "c:\path\to\batch.zip" exit /b :UnZipFile <ExtractTo> <newzipfile> set vbs="%temp%\_.vbs" if exist %vbs% del /a /f %vbs% >%vbs% echo Set fso = CreateObject("Scripting.FileSystemObject") >>%vbs% echo If ...
893203
.bat files, nonblocking run/launch
38
2009-05-21 14:27:39
<p>How do i launch 2 apps at once in a .bat file? my current text is</p> <pre><code>cd mydir my.exe my.exe difParams //bat is finished. i dont want my.exe to close </code></pre>
30,935
null
2016-10-03 15:54:46
893,216
70
2009-05-21 14:30:04
72,312
2016-10-03 15:54:46
https://stackoverflow.com/q/893203
https://stackoverflow.com/a/893216
<pre><code>start "MY EXE" my.exe </code></pre> <p>That kicks the exe off in the background (and avoids title issues, see below).</p> <p>The start command offers some options too, use <code>start /?</code> to list them:</p> <pre><code>C:&gt;start /? Starts a separate window to run a specified program or command. ...
<pre><code>start "MY EXE" my.exe </code></pre> <p>That kicks the exe off in the background (and avoids title issues, see below).</p> <p>The start command offers some options too, use <code>start /?</code> to list them:</p> <pre><code>C:&gt;start /? Starts a separate window to run a specified program or command. ...
2631, 7002
batch-file, cmd
<h1>.bat files, nonblocking run/launch</h1> <p>How do i launch 2 apps at once in a .bat file? my current text is</p> <pre><code>cd mydir my.exe my.exe difParams //bat is finished. i dont want my.exe to close </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,157
cmd
# .bat files, nonblocking run/launch How do i launch 2 apps at once in a .bat file? my current text is ``` cd mydir my.exe my.exe difParams //bat is finished. i dont want my.exe to close ```
``` start "MY EXE" my.exe ``` That kicks the exe off in the background (and avoids title issues, see below). The start command offers some options too, use `start /?` to list them: ``` C:>start /? Starts a separate window to run a specified program or command. START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARA...
32922226
Extract every audio and subtitles from a video with ffmpeg
32
2015-10-03 11:52:24
<p>I have multiple audio tracks and subtitles to extract in a single <em>.mkv</em> file. I'm new to <code>ffmpeg</code> commands, this is what I've tried (audio):</p> <p><code>ffmpeg -i VIDEO.mkv -vn -acodec copy AUDIO.aac</code></p> <p>It just extract 1 audio. What I want is tell <code>ffmpeg</code> to extract every...
75,709
5,081,705
2021-07-13 22:26:13
32,925,753
70
2015-10-03 18:04:56
1,109,017
2021-07-13 22:26:13
https://stackoverflow.com/q/32922226
https://stackoverflow.com/a/32925753
<p>There is no option yet in <code>ffmpeg</code> to automatically extract all streams into an appropriate container, but it is certainly possible to do manually.</p> <p>You only need to know the appropriate containers for the formats you want to extract.</p> <p>Default <a href="https://ffmpeg.org/ffmpeg.html#Stream-sel...
<p>There is no option yet in <code>ffmpeg</code> to automatically extract all streams into an appropriate container, but it is certainly possible to do manually.</p> <p>You only need to know the appropriate containers for the formats you want to extract.</p> <p>Default <a href="https://ffmpeg.org/ffmpeg.html#Stream-sel...
348, 519, 2631, 3847, 38771
audio, cmd, ffmpeg, mkv, video
<h1>Extract every audio and subtitles from a video with ffmpeg</h1> <p>I have multiple audio tracks and subtitles to extract in a single <em>.mkv</em> file. I'm new to <code>ffmpeg</code> commands, this is what I've tried (audio):</p> <p><code>ffmpeg -i VIDEO.mkv -vn -acodec copy AUDIO.aac</code></p> <p>It just extra...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,158
cmd
# Extract every audio and subtitles from a video with ffmpeg I have multiple audio tracks and subtitles to extract in a single *.mkv* file. I'm new to `ffmpeg` commands, this is what I've tried (audio): `ffmpeg -i VIDEO.mkv -vn -acodec copy AUDIO.aac` It just extract 1 audio. What I want is tell `ffmpeg` to extract ...
There is no option yet in `ffmpeg` to automatically extract all streams into an appropriate container, but it is certainly possible to do manually. You only need to know the appropriate containers for the formats you want to extract. Default [stream selection](https://ffmpeg.org/ffmpeg.html#Stream-selection) only cho...
51098378
Converting .bat to .exe with no additional external software (Create SFX)
24
2018-06-29 09:19:25
<p>Following the same steps as this <a href="https://www.howtogeek.com/50364/convert-a-batch-bat-script-to-an-executable-exe-file/" rel="noreferrer">guide</a>. I am trying to convert from bat to exe without installing any new software such as <a href="http://www.f2ko.de/en/b2e.php" rel="noreferrer">Bat to Exe Converter...
143,915
7,446,528
2024-10-28 00:04:44
51,104,332
70
2018-06-29 14:47:21
3,080,770
2018-07-01 12:12:03
https://stackoverflow.com/q/51098378
https://stackoverflow.com/a/51104332
<p>Refer to this <strong><a href="https://stackoverflow.com/questions/28174386/how-can-a-bat-file-be-converted-to-exe-without-third-party-tools?answertab=active#tab-top">How can a .bat file be 'converted' to .exe without third party tools?</a></strong></p> <p>The original script accepts two arguments - the .bat file y...
<p>Refer to this <strong><a href="https://stackoverflow.com/questions/28174386/how-can-a-bat-file-be-converted-to-exe-without-third-party-tools?answertab=active#tab-top">How can a .bat file be 'converted' to .exe without third party tools?</a></strong></p> <p>The original script accepts two arguments - the .bat file y...
64, 5680, 7002
7zip, batch-file, windows
<h1>Converting .bat to .exe with no additional external software (Create SFX)</h1> <p>Following the same steps as this <a href="https://www.howtogeek.com/50364/convert-a-batch-bat-script-to-an-executable-exe-file/" rel="noreferrer">guide</a>. I am trying to convert from bat to exe without installing any new software su...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,159
cmd
# Converting .bat to .exe with no additional external software (Create SFX) Following the same steps as this [guide](https://www.howtogeek.com/50364/convert-a-batch-bat-script-to-an-executable-exe-file/). I am trying to convert from bat to exe without installing any new software such as [Bat to Exe Converter](http://w...
Refer to this **[How can a .bat file be 'converted' to .exe without third party tools?](https://stackoverflow.com/questions/28174386/how-can-a-bat-file-be-converted-to-exe-without-third-party-tools?answertab=active#tab-top)** The original script accepts two arguments - the .bat file you want to convert and the target ...
1788473
While loop in batch
68
2009-11-24 07:39:12
<p>Here is what I want, inside the <code>BACKUPDIR</code>, I want to execute <code>cscript /nologo c:\deletefile.vbs %BACKUPDIR%</code> until number of files inside the folder is greater than 21(<code>countfiles</code> holds it). Here is my code:</p> <pre><code>@echo off SET BACKUPDIR=C:\test for /f %%x in ('dir %BACK...
528,372
151,937
2022-09-21 18:16:15
1,788,502
69
2009-11-24 07:48:00
34,065
2022-09-21 18:16:15
https://stackoverflow.com/q/1788473
https://stackoverflow.com/a/1788502
<pre><code>set /a countfiles-=%countfiles% </code></pre> <p>This will set countfiles to 0. I think you want to decrease it by 1, so use this instead:</p> <pre><code>set /a countfiles-=1 </code></pre> <p>I'm not sure if the for loop will work, better try something like this:</p> <pre><code>:loop cscript /nologo c:\delet...
<pre><code>set /a countfiles-=%countfiles% </code></pre> <p>This will set countfiles to 0. I think you want to decrease it by 1, so use this instead:</p> <pre><code>set /a countfiles-=1 </code></pre> <p>I'm not sure if the for loop will work, better try something like this:</p> <pre><code>:loop cscript /nologo c:\delet...
64, 2531, 7002, 17310
batch-file, for-loop, while-loop, windows
<h1>While loop in batch</h1> <p>Here is what I want, inside the <code>BACKUPDIR</code>, I want to execute <code>cscript /nologo c:\deletefile.vbs %BACKUPDIR%</code> until number of files inside the folder is greater than 21(<code>countfiles</code> holds it). Here is my code:</p> <pre><code>@echo off SET BACKUPDIR=C:\t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,160
cmd
# While loop in batch Here is what I want, inside the `BACKUPDIR`, I want to execute `cscript /nologo c:\deletefile.vbs %BACKUPDIR%` until number of files inside the folder is greater than 21(`countfiles` holds it). Here is my code: ``` @echo off SET BACKUPDIR=C:\test for /f %%x in ('dir %BACKUPDIR% /b ^| find /v /c ...
``` set /a countfiles-=%countfiles% ``` This will set countfiles to 0. I think you want to decrease it by 1, so use this instead: ``` set /a countfiles-=1 ``` I'm not sure if the for loop will work, better try something like this: ``` :loop cscript /nologo c:\deletefile.vbs %BACKUPDIR% set /a countfiles-=1 if %coun...
2027070
How to concatenate strings in a Windows batch file?
77
2010-01-08 11:00:40
<p>I have a directory for which I want to list all the <code>.doc</code> files with a <code>;</code>.</p> <p>I know the following batch command echos all the files:</p> <pre><code>for /r %%i In (*.doc) DO echo %%i </code></pre> <p>But now I want to put them all in a variable, add a <code>;</code> in between and echo...
222,690
109,880
2015-11-12 16:08:13
2,027,110
68
2010-01-08 11:06:22
113,794
2010-01-08 11:22:23
https://stackoverflow.com/q/2027070
https://stackoverflow.com/a/2027110
<p>What about:</p> <pre><code>@echo off set myvar="the list: " for /r %%i in (*.doc) DO call :concat %%i echo %myvar% goto :eof :concat set myvar=%myvar% %1; goto :eof </code></pre>
<p>What about:</p> <pre><code>@echo off set myvar="the list: " for /r %%i in (*.doc) DO call :concat %%i echo %myvar% goto :eof :concat set myvar=%myvar% %1; goto :eof </code></pre>
64, 7002, 7792
batch-file, string-concatenation, windows
<h1>How to concatenate strings in a Windows batch file?</h1> <p>I have a directory for which I want to list all the <code>.doc</code> files with a <code>;</code>.</p> <p>I know the following batch command echos all the files:</p> <pre><code>for /r %%i In (*.doc) DO echo %%i </code></pre> <p>But now I want to put the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,163
cmd
# How to concatenate strings in a Windows batch file? I have a directory for which I want to list all the `.doc` files with a `;`. I know the following batch command echos all the files: ``` for /r %%i In (*.doc) DO echo %%i ``` But now I want to put them all in a variable, add a `;` in between and echo them all at...
What about: ``` @echo off set myvar="the list: " for /r %%i in (*.doc) DO call :concat %%i echo %myvar% goto :eof :concat set myvar=%myvar% %1; goto :eof ```
16656229
How do I set the timezone from command line ?
38
2013-05-20 18:45:16
<p>How can I set the timezone in Windows from command line or from a batch file? </p> <p>Do I need to use powershell or cscript?</p>
69,550
1,577,343
2019-08-18 20:08:22
16,656,265
68
2013-05-20 18:47:46
1,420,197
2015-08-03 13:50:33
https://stackoverflow.com/q/16656229
https://stackoverflow.com/a/16656265
<p>The command line utility that helps you change the time zone in Windows 7 is <code>tzutil.exe</code> and is known as <em>Windows Time Zone Utility</em>. This is a great tool for all the people who prefer working from the command prompt.</p> <p>Use the <code>/s</code> parameter to <strong>set</strong> the time zone:...
<p>The command line utility that helps you change the time zone in Windows 7 is <code>tzutil.exe</code> and is known as <em>Windows Time Zone Utility</em>. This is a great tool for all the people who prefer working from the command prompt.</p> <p>Use the <code>/s</code> parameter to <strong>set</strong> the time zone:...
64, 982, 1231, 6701, 7002
batch-file, command-line, timezone, windows, wsh
<h1>How do I set the timezone from command line ?</h1> <p>How can I set the timezone in Windows from command line or from a batch file? </p> <p>Do I need to use powershell or cscript?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,165
cmd
# How do I set the timezone from command line ? How can I set the timezone in Windows from command line or from a batch file? Do I need to use powershell or cscript?
The command line utility that helps you change the time zone in Windows 7 is `tzutil.exe` and is known as *Windows Time Zone Utility*. This is a great tool for all the people who prefer working from the command prompt. Use the `/s` parameter to **set** the time zone: ``` tzutil /s "universal standard time" ``` Use t...
21554062
Executing set of SQL queries using batch file?
34
2014-02-04 13:37:29
<p>I am using a SQL Server database. I have these SQL queries:</p> <pre><code>Delete from TableA; Delete from TableB; Delete from TableC; Delete from TableD; Delete from TableE; </code></pre> <p>Is it possible to run these scripts using a batch file? The database is a remote database.</p> <p>Thanks!</p>
270,499
755,806
2016-11-28 08:38:58
21,554,189
68
2014-02-04 13:42:41
325,521
2016-01-21 18:39:04
https://stackoverflow.com/q/21554062
https://stackoverflow.com/a/21554189
<p>Save the commands in a <code>.SQL</code> file, ex: <code>ClearTables.sql</code>, say in your <code>C:\temp</code> folder.</p> <p><strong>Contents of</strong> <code>C:\Temp\ClearTables.sql</code></p> <pre><code>Delete from TableA; Delete from TableB; Delete from TableC; Delete from TableD; Delete from TableE; </cod...
<p>Save the commands in a <code>.SQL</code> file, ex: <code>ClearTables.sql</code>, say in your <code>C:\temp</code> folder.</p> <p><strong>Contents of</strong> <code>C:\Temp\ClearTables.sql</code></p> <pre><code>Delete from TableA; Delete from TableB; Delete from TableC; Delete from TableD; Delete from TableE; </cod...
30, 72, 2631, 7002
batch-file, cmd, database, sql-server
<h1>Executing set of SQL queries using batch file?</h1> <p>I am using a SQL Server database. I have these SQL queries:</p> <pre><code>Delete from TableA; Delete from TableB; Delete from TableC; Delete from TableD; Delete from TableE; </code></pre> <p>Is it possible to run these scripts using a batch file? The databas...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,166
cmd
# Executing set of SQL queries using batch file? I am using a SQL Server database. I have these SQL queries: ``` Delete from TableA; Delete from TableB; Delete from TableC; Delete from TableD; Delete from TableE; ``` Is it possible to run these scripts using a batch file? The database is a remote database. Thanks!
Save the commands in a `.SQL` file, ex: `ClearTables.sql`, say in your `C:\temp` folder. **Contents of** `C:\Temp\ClearTables.sql` ``` Delete from TableA; Delete from TableB; Delete from TableC; Delete from TableD; Delete from TableE; ``` Then use `sqlcmd` to execute it as follows. Since you said the database is rem...
12976351
Escaping parentheses within parentheses for batch file
54
2012-10-19 14:26:08
<p>This is what I am trying to do:</p> <pre><code>( @echo This is some code that is @echo Important to echo exactly as-is @echo Even if I use parenthesis @echo for something (like this) )|clip </code></pre> <p>So having that copied into clipboard. I have tried the following:</p> <pre><code>( @echo This is some code ...
48,627
1,759,622
2020-09-11 14:37:21
12,976,840
67
2012-10-19 14:52:17
463,115
2012-10-19 15:08:33
https://stackoverflow.com/q/12976351
https://stackoverflow.com/a/12976840
<p>It's obvious that you need three carets there :-)</p> <pre><code>( @echo This is some code that is @echo Important to echo exactly as-is @echo Even if I use parenthesis @echo for something (like this^^^) )|clip </code></pre> <p>Why? That is a bit tricky... </p> <p>First the parser parses the block and escapes th...
<p>It's obvious that you need three carets there :-)</p> <pre><code>( @echo This is some code that is @echo Important to echo exactly as-is @echo Even if I use parenthesis @echo for something (like this^^^) )|clip </code></pre> <p>Why? That is a bit tricky... </p> <p>First the parser parses the block and escapes th...
64, 2631, 4804, 7002, 20347
batch-file, cmd, escaping, parentheses, windows
<h1>Escaping parentheses within parentheses for batch file</h1> <p>This is what I am trying to do:</p> <pre><code>( @echo This is some code that is @echo Important to echo exactly as-is @echo Even if I use parenthesis @echo for something (like this) )|clip </code></pre> <p>So having that copied into clipboard. I have...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,167
cmd
# Escaping parentheses within parentheses for batch file This is what I am trying to do: ``` ( @echo This is some code that is @echo Important to echo exactly as-is @echo Even if I use parenthesis @echo for something (like this) )|clip ``` So having that copied into clipboard. I have tried the following: ``` ( @ech...
It's obvious that you need three carets there :-) ``` ( @echo This is some code that is @echo Important to echo exactly as-is @echo Even if I use parenthesis @echo for something (like this^^^) )|clip ``` Why? That is a bit tricky... First the parser parses the block and escapes the part `this^^^)` to `this^)`, the p...
15147900
How to supply console input ( yes / no ) as part of batch file on Windows.
27
2013-02-28 23:47:07
<p>I am writing a simple batch file (remove.bat) to remove a directory and all its subdirectories. The file contains the following command- </p> <pre><code>rmdir /S modules </code></pre> <p>where <em>modules</em> is the name of the non-empty directory. </p> <p>I get the following message - </p> <pre><code>C:\...\bi...
144,269
1,199,882
2021-08-06 14:30:45
15,148,192
67
2013-03-01 00:17:00
1,012,053
2021-03-02 18:21:14
https://stackoverflow.com/q/15147900
https://stackoverflow.com/a/15148192
<p>As others have pointed out, you should use the <code>/Q</code> option. But there is another &quot;old school&quot; way to do it that was used back in the day when commands did not have options to suppress confirmation messages. Simply ECHO the needed response and pipe the value into the command.</p> <pre><code>echo ...
<p>As others have pointed out, you should use the <code>/Q</code> option. But there is another &quot;old school&quot; way to do it that was used back in the day when commands did not have options to suppress confirmation messages. Simply ECHO the needed response and pipe the value into the command.</p> <pre><code>echo ...
64, 488, 7002
batch-file, console, windows
<h1>How to supply console input ( yes / no ) as part of batch file on Windows.</h1> <p>I am writing a simple batch file (remove.bat) to remove a directory and all its subdirectories. The file contains the following command- </p> <pre><code>rmdir /S modules </code></pre> <p>where <em>modules</em> is the name of the no...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,168
cmd
# How to supply console input ( yes / no ) as part of batch file on Windows. I am writing a simple batch file (remove.bat) to remove a directory and all its subdirectories. The file contains the following command- ``` rmdir /S modules ``` where *modules* is the name of the non-empty directory. I get the following m...
As others have pointed out, you should use the `/Q` option. But there is another "old school" way to do it that was used back in the day when commands did not have options to suppress confirmation messages. Simply ECHO the needed response and pipe the value into the command. ``` echo y|rmdir /s modules ``` I recommen...
8117060
Storing in JobExecutionContext from tasklet and accessing in another tasklet
26
2011-11-14 03:42:18
<p>I have a requirement in which a tasklet, stores all the files in the directories in an arraylist. The size of the list is stored in the job execution context. Later this count is accessed from another tasklet in another step. How do it do this. I tried to store in jobexecution context, at runtime throws unmodifiable...
90,899
378,968
2020-04-09 17:47:49
8,121,102
67
2011-11-14 11:47:25
62,201
2015-01-05 07:23:58
https://stackoverflow.com/q/8117060
https://stackoverflow.com/a/8121102
<p>you have at least 4 possibilities:</p> <ol> <li>use the ExecutionPromotionListener to <a href="http://docs.spring.io/spring-batch/trunk/reference/html/patterns.html#passingDataToFutureSteps">pass data to future steps</a></li> <li>use a (spring) bean to hold inter-step data, e.g. a ConcurrentHashMap <ul> <li>without...
<p>you have at least 4 possibilities:</p> <ol> <li>use the ExecutionPromotionListener to <a href="http://docs.spring.io/spring-batch/trunk/reference/html/patterns.html#passingDataToFutureSteps">pass data to future steps</a></li> <li>use a (spring) bean to hold inter-step data, e.g. a ConcurrentHashMap <ul> <li>without...
1211, 41895
spring, spring-batch
<h1>Storing in JobExecutionContext from tasklet and accessing in another tasklet</h1> <p>I have a requirement in which a tasklet, stores all the files in the directories in an arraylist. The size of the list is stored in the job execution context. Later this count is accessed from another tasklet in another step. How d...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,169
cmd
# Storing in JobExecutionContext from tasklet and accessing in another tasklet I have a requirement in which a tasklet, stores all the files in the directories in an arraylist. The size of the list is stored in the job execution context. Later this count is accessed from another tasklet in another step. How do it do t...
you have at least 4 possibilities: 1. use the ExecutionPromotionListener to [pass data to future steps](http://docs.spring.io/spring-batch/trunk/reference/html/patterns.html#passingDataToFutureSteps) 2. use a (spring) bean to hold inter-step data, e.g. a ConcurrentHashMap - without further action this data won't be...
14537876
batch file to list folders within a folder to one level
25
2013-01-26 14:32:05
<p>I have searched and searched to no avail so apologies if the answer does exist.</p> <p>I am not very good with batch files so please keep this in mind.</p> <p>All I am after is a single batch file that will list/save to file a list of the folders within the current folder.</p> <p>So basically if I run this batch ...
135,202
2,013,720
2022-07-30 01:39:12
14,538,042
67
2013-01-26 14:49:33
891,976
2013-01-26 14:55:13
https://stackoverflow.com/q/14537876
https://stackoverflow.com/a/14538042
<h2>Dir</h2> <p>Use the <code>dir</code> command. Type in <a href="http://ss64.com/nt/dir.html" rel="noreferrer"><code>dir /?</code></a> for help and options.</p> <pre><code>dir /a:d /b </code></pre> <hr> <h2>Redirect</h2> <p>Then use a redirect to save the list to a file.</p> <pre><code>&gt; list.txt </code></p...
<h2>Dir</h2> <p>Use the <code>dir</code> command. Type in <a href="http://ss64.com/nt/dir.html" rel="noreferrer"><code>dir /?</code></a> for help and options.</p> <pre><code>dir /a:d /b </code></pre> <hr> <h2>Redirect</h2> <p>Then use a redirect to save the list to a file.</p> <pre><code>&gt; list.txt </code></p...
7002
batch-file
<h1>batch file to list folders within a folder to one level</h1> <p>I have searched and searched to no avail so apologies if the answer does exist.</p> <p>I am not very good with batch files so please keep this in mind.</p> <p>All I am after is a single batch file that will list/save to file a list of the folders wit...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,170
cmd
# batch file to list folders within a folder to one level I have searched and searched to no avail so apologies if the answer does exist. I am not very good with batch files so please keep this in mind. All I am after is a single batch file that will list/save to file a list of the folders within the current folder....
## Dir Use the `dir` command. Type in [`dir /?`](http://ss64.com/nt/dir.html) for help and options. ``` dir /a:d /b ``` --- ## Redirect Then use a redirect to save the list to a file. ``` > list.txt ``` --- ## Together ``` dir /a:d /b > list.txt ``` This will output just the names of the directories. if you w...
15012344
How to keep cmd running after opening a .bat file script
22
2013-02-21 21:14:05
<p>Basically I have written a "script" in notepad and saved it as a <code>.bat</code> file. All it does is to change directory. Written like this: </p> <pre><code>cd C:\Users\Hello\Documents\Stuff </code></pre> <p>It does change the directory, but i want to write more after that, within the <code>cmd</code>. Ex. cho...
46,156
2,097,106
2018-02-12 21:35:13
15,020,474
67
2013-02-22 09:10:24
2,098,699
2013-02-22 09:10:24
https://stackoverflow.com/q/15012344
https://stackoverflow.com/a/15020474
<p>Put <code>cmd /k</code> on the very last line of the script.</p>
<p>Put <code>cmd /k</code> on the very last line of the script.</p>
64, 218, 2631, 7002
batch-file, cmd, directory, windows
<h1>How to keep cmd running after opening a .bat file script</h1> <p>Basically I have written a "script" in notepad and saved it as a <code>.bat</code> file. All it does is to change directory. Written like this: </p> <pre><code>cd C:\Users\Hello\Documents\Stuff </code></pre> <p>It does change the directory, but i w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,171
cmd
# How to keep cmd running after opening a .bat file script Basically I have written a "script" in notepad and saved it as a `.bat` file. All it does is to change directory. Written like this: ``` cd C:\Users\Hello\Documents\Stuff ``` It does change the directory, but i want to write more after that, within the `cmd`...
Put `cmd /k` on the very last line of the script.
4094699
How does the Windows Command Interpreter (CMD.EXE) parse scripts?
196
2010-11-04 07:38:57
<p>I ran into <a href="https://ss64.com" rel="noreferrer">ss64.com</a> which provides good help regarding how to write batch scripts that the Windows Command Interpreter will run.</p> <p>However, I have been unable to find a good explanation of the <strong>grammar</strong> of batch scripts, how things expand or do not ...
104,756
457,352
2024-02-03 02:13:10
4,094,897
66
2010-11-04 08:26:46
312,407
2024-02-03 02:13:10
https://stackoverflow.com/q/4094699
https://stackoverflow.com/a/4094897
<p>When invoking a command from a command window, tokenization of the command line arguments is not done by <code>cmd.exe</code> (a.k.a. &quot;the shell&quot;). Most often the tokenization is done by the newly formed processes' C/C++ runtime, but this is not necessarily so -- for example, if the new process was not wr...
<p>When invoking a command from a command window, tokenization of the command line arguments is not done by <code>cmd.exe</code> (a.k.a. &quot;the shell&quot;). Most often the tokenization is done by the newly formed processes' C/C++ runtime, but this is not necessarily so -- for example, if the new process was not wr...
64, 1357, 2631, 7002, 19749
batch-file, cmd, parsing, variable-expansion, windows
<h1>How does the Windows Command Interpreter (CMD.EXE) parse scripts?</h1> <p>I ran into <a href="https://ss64.com" rel="noreferrer">ss64.com</a> which provides good help regarding how to write batch scripts that the Windows Command Interpreter will run.</p> <p>However, I have been unable to find a good explanation of ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,172
cmd
# How does the Windows Command Interpreter (CMD.EXE) parse scripts? I ran into [ss64.com](https://ss64.com) which provides good help regarding how to write batch scripts that the Windows Command Interpreter will run. However, I have been unable to find a good explanation of the **grammar** of batch scripts, how thing...
When invoking a command from a command window, tokenization of the command line arguments is not done by `cmd.exe` (a.k.a. "the shell"). Most often the tokenization is done by the newly formed processes' C/C++ runtime, but this is not necessarily so -- for example, if the new process was not written in C/C++, or if the...
4743094
How can I move all the files from one folder to another using the command line?
70
2011-01-20 03:10:51
<p>What is the best command to move all files from one folder to another?</p> <p>I want to do this from within a batch file.</p>
435,163
467,610
2021-12-27 08:04:45
4,743,201
66
2011-01-20 03:34:21
14,860
2011-01-20 03:40:18
https://stackoverflow.com/q/4743094
https://stackoverflow.com/a/4743201
<p>You can use <code>move</code> for this. The documentation from <code>help move</code> states:</p> <pre><code>Moves files and renames files and directories. To move one or more files: MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination To rename a directory: MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2 ...
<p>You can use <code>move</code> for this. The documentation from <code>help move</code> states:</p> <pre><code>Moves files and renames files and directories. To move one or more files: MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination To rename a directory: MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2 ...
2631, 7002, 9938
batch-file, cmd, command-prompt
<h1>How can I move all the files from one folder to another using the command line?</h1> <p>What is the best command to move all files from one folder to another?</p> <p>I want to do this from within a batch file.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,173
cmd
# How can I move all the files from one folder to another using the command line? What is the best command to move all files from one folder to another? I want to do this from within a batch file.
You can use `move` for this. The documentation from `help move` states: ``` Moves files and renames files and directories. To move one or more files: MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination To rename a directory: MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2 [drive:][path]filename1 Specifies t...
9074476
Is it possible to embed and execute VBScript within a batch file without using a temporary file?
47
2012-01-31 04:39:57
<p>People have been embedding and executing VBScript within batch files for a long time. But all the published solutions that I have seen <em>(at the time this question was originally posed)</em> involve writing a temporary VBS file. For example: <a href="https://stackoverflow.com/q/4037709/1012053">Embed VBScript insi...
56,837
1,012,053
2020-11-13 08:01:14
9,074,483
66
2012-01-31 04:41:23
1,012,053
2017-12-26 09:59:43
https://stackoverflow.com/q/9074476
https://stackoverflow.com/a/9074483
<p><em>Note - jump to the</em> <strong><em>UPDATE 2014-04-27</em></strong> <em>section at the bottom of this answer for the best solution.</em></p> <p>I used to think the answer was no. But then DosTips user Liviu discovered that the <code>&lt;SUB&gt;</code> character (Ctrl-Z, 0x1A, decimal 26) has bizare effects when...
<p><em>Note - jump to the</em> <strong><em>UPDATE 2014-04-27</em></strong> <em>section at the bottom of this answer for the best solution.</em></p> <p>I used to think the answer was no. But then DosTips user Liviu discovered that the <code>&lt;SUB&gt;</code> character (Ctrl-Z, 0x1A, decimal 26) has bizare effects when...
494, 7002
batch-file, vbscript
<h1>Is it possible to embed and execute VBScript within a batch file without using a temporary file?</h1> <p>People have been embedding and executing VBScript within batch files for a long time. But all the published solutions that I have seen <em>(at the time this question was originally posed)</em> involve writing a ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,174
cmd
# Is it possible to embed and execute VBScript within a batch file without using a temporary file? People have been embedding and executing VBScript within batch files for a long time. But all the published solutions that I have seen *(at the time this question was originally posed)* involve writing a temporary VBS fi...
*Note - jump to the* ***UPDATE 2014-04-27*** *section at the bottom of this answer for the best solution.* I used to think the answer was no. But then DosTips user Liviu discovered that the `<SUB>` character (Ctrl-Z, 0x1A, decimal 26) has bizare effects when embedded within a batch file. If functions somewhat like a l...
6523979
How can I persistently set a variable in Windows 7 from a batch file?
47
2011-06-29 16:25:05
<p>I am trying to set the PATH environment variable in Windows 7 using a <em>.bat</em> file; however it does not seem to work.</p> <p>I am using this Windows command:</p> <pre class="lang-none prettyprint-override"><code>set PATH=%cd%;%path% pause </code></pre> <p>However, it only appears to be valid for this cmd insta...
85,161
528,590
2025-06-09 13:44:14
6,527,324
66
2011-06-29 21:12:02
821,878
2025-06-09 13:11:35
https://stackoverflow.com/q/6523979
https://stackoverflow.com/a/6527324
<p>Use <a href="https://ss64.com/nt/setx.html" rel="nofollow noreferrer">setx.exe</a> instead of set.</p> <pre><code>setx PATH &quot;%cd%;%path%;&quot; pause </code></pre> <p>Note that this sets the path for all future cmd instances, but <em>not</em> for the current one. If you need that, also run your original set co...
<p>Use <a href="https://ss64.com/nt/setx.html" rel="nofollow noreferrer">setx.exe</a> instead of set.</p> <pre><code>setx PATH &quot;%cd%;%path%;&quot; pause </code></pre> <p>Note that this sets the path for all future cmd instances, but <em>not</em> for the current one. If you need that, also run your original set co...
64, 6268, 7002, 9013
batch-file, environment-variables, path, windows
<h1>How can I persistently set a variable in Windows 7 from a batch file?</h1> <p>I am trying to set the PATH environment variable in Windows 7 using a <em>.bat</em> file; however it does not seem to work.</p> <p>I am using this Windows command:</p> <pre class="lang-none prettyprint-override"><code>set PATH=%cd%;%path%...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,175
cmd
# How can I persistently set a variable in Windows 7 from a batch file? I am trying to set the PATH environment variable in Windows 7 using a *.bat* file; however it does not seem to work. I am using this Windows command: ``` set PATH=%cd%;%path% pause ``` However, it only appears to be valid for this cmd instance....
Use [setx.exe](https://ss64.com/nt/setx.html) instead of set. ``` setx PATH "%cd%;%path%;" pause ``` Note that this sets the path for all future cmd instances, but *not* for the current one. If you need that, also run your original set command. The second parameter needs to be quoted if it contains spaces (which %pa...
8744543
How to stop/start IIS 7 application through command line?
41
2012-01-05 14:56:05
<p>I would like to create a batch file to start one IIS application, and stop another one.</p> <p>How it can be done using command line? </p> <p>How to combined it in batch file?</p>
44,284
308,795
2015-11-27 15:34:44
8,744,665
66
2012-01-05 15:05:37
343,955
2015-11-27 15:34:44
https://stackoverflow.com/q/8744543
https://stackoverflow.com/a/8744665
<p><a href="http://www.windowsnetworking.com/articles_tutorials/Configuring-IIS-7-command-line-Appcmdexe-Part1.html" rel="noreferrer">http://www.windowsnetworking.com/articles_tutorials/Configuring-IIS-7-command-line-Appcmdexe-Part1.html</a></p> <p>Put this into a file with <code>.bat</code> extension.</p> <pre><code...
<p><a href="http://www.windowsnetworking.com/articles_tutorials/Configuring-IIS-7-command-line-Appcmdexe-Part1.html" rel="noreferrer">http://www.windowsnetworking.com/articles_tutorials/Configuring-IIS-7-command-line-Appcmdexe-Part1.html</a></p> <p>Put this into a file with <code>.bat</code> extension.</p> <pre><code...
1231, 1301, 7002, 31985, 35311
batch-file, command-line, iis-7, iis-7.5, windows-server-2008
<h1>How to stop/start IIS 7 application through command line?</h1> <p>I would like to create a batch file to start one IIS application, and stop another one.</p> <p>How it can be done using command line? </p> <p>How to combined it in batch file?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,176
cmd
# How to stop/start IIS 7 application through command line? I would like to create a batch file to start one IIS application, and stop another one. How it can be done using command line? How to combined it in batch file?
<http://www.windowsnetworking.com/articles_tutorials/Configuring-IIS-7-command-line-Appcmdexe-Part1.html> Put this into a file with `.bat` extension. ``` @echo off appcmd start sites "site1" appcmd stop sites "site2" ``` **Update** Just ensure that `appcmd` is available anywhere by adding `%windir%\system32\inetsr...
15449034
Batch program to to check if process exists
38
2013-03-16 12:04:48
<p>I want a batch program, which will check if the process <code>notepad.exe</code> exists.</p> <p><strong>if</strong> <code>notepad.exe</code> exists, it will end the process, </p> <p><strong>else</strong> the batch program will close itself.</p> <p>Here is what I've done:</p> <pre><code>@echo off tasklist /fi "im...
167,858
2,176,930
2021-11-05 17:39:24
15,449,358
66
2013-03-16 12:38:07
2,128,947
2013-03-16 12:38:07
https://stackoverflow.com/q/15449034
https://stackoverflow.com/a/15449358
<p><code>TASKLIST</code> does not set errorlevel.</p> <pre><code>echo off tasklist /fi "imagename eq notepad.exe" |find ":" &gt; nul if errorlevel 1 taskkill /f /im "notepad.exe" exit </code></pre> <p>should do the job, since ":" should appear in <code>TASKLIST</code> output only if the task is NOT found, hence <code...
<p><code>TASKLIST</code> does not set errorlevel.</p> <pre><code>echo off tasklist /fi "imagename eq notepad.exe" |find ":" &gt; nul if errorlevel 1 taskkill /f /im "notepad.exe" exit </code></pre> <p>should do the job, since ":" should appear in <code>TASKLIST</code> output only if the task is NOT found, hence <code...
64, 1796, 2631, 7002
batch-file, cmd, command, windows
<h1>Batch program to to check if process exists</h1> <p>I want a batch program, which will check if the process <code>notepad.exe</code> exists.</p> <p><strong>if</strong> <code>notepad.exe</code> exists, it will end the process, </p> <p><strong>else</strong> the batch program will close itself.</p> <p>Here is what ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,177
cmd
# Batch program to to check if process exists I want a batch program, which will check if the process `notepad.exe` exists. **if** `notepad.exe` exists, it will end the process, **else** the batch program will close itself. Here is what I've done: ``` @echo off tasklist /fi "imagename eq notepad.exe" > nul if erro...
`TASKLIST` does not set errorlevel. ``` echo off tasklist /fi "imagename eq notepad.exe" |find ":" > nul if errorlevel 1 taskkill /f /im "notepad.exe" exit ``` should do the job, since ":" should appear in `TASKLIST` output only if the task is NOT found, hence `FIND` will set the errorlevel to `0` for `not found` and...
21241683
Spring-batch @BeforeStep does not work with @StepScope
36
2014-01-20 18:42:15
<p>I'm using Spring Batch version 2.2.4.RELEASE I tried to write a simple example with stateful ItemReader, ItemProcessor and ItemWriter beans.</p> <pre><code>public class StatefulItemReader implements ItemReader&lt;String&gt; { private List&lt;String&gt; list; @BeforeStep public void initializeState(Ste...
40,330
3,216,318
2021-06-21 06:11:32
21,941,127
66
2014-02-21 17:27:39
618,059
2014-02-21 17:27:39
https://stackoverflow.com/q/21241683
https://stackoverflow.com/a/21941127
<p>When you configure a bean as follows:</p> <pre><code>@Bean @StepScope public MyInterface myBean() { return new MyInterfaceImpl(); } </code></pre> <p>You are telling Spring to use the proxy mode <code>ScopedProxyMode.TARGET_CLASS</code>. However, by returning the <code>MyInterface</code>, instead of the <code>...
<p>When you configure a bean as follows:</p> <pre><code>@Bean @StepScope public MyInterface myBean() { return new MyInterfaceImpl(); } </code></pre> <p>You are telling Spring to use the proxy mode <code>ScopedProxyMode.TARGET_CLASS</code>. However, by returning the <code>MyInterface</code>, instead of the <code>...
17, 1211, 41895
java, spring, spring-batch
<h1>Spring-batch @BeforeStep does not work with @StepScope</h1> <p>I'm using Spring Batch version 2.2.4.RELEASE I tried to write a simple example with stateful ItemReader, ItemProcessor and ItemWriter beans.</p> <pre><code>public class StatefulItemReader implements ItemReader&lt;String&gt; { private List&lt;Strin...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,178
cmd
# Spring-batch @BeforeStep does not work with @StepScope I'm using Spring Batch version 2.2.4.RELEASE I tried to write a simple example with stateful ItemReader, ItemProcessor and ItemWriter beans. ``` public class StatefulItemReader implements ItemReader<String> { private List<String> list; @BeforeStep ...
When you configure a bean as follows: ``` @Bean @StepScope public MyInterface myBean() { return new MyInterfaceImpl(); } ``` You are telling Spring to use the proxy mode `ScopedProxyMode.TARGET_CLASS`. However, by returning the `MyInterface`, instead of the `MyInterfaceImpl`, the proxy only has visibility into th...
47075661
Error "User limit of inotify watches reached". ExtReact build
29
2017-11-02 12:44:50
<p>I installed ExtReact, with examples. When I run</p> <pre><code>npm start </code></pre> <p>I get an error: </p> <pre><code>ERROR in [@extjs/reactor-webpack-plugin]: Error: [ERR] BUILD FAILED [ERR] com.sencha.exceptions.BasicException: User limit of inotify watches reached [ERR] [ERR] Total time: 13 seconds [ERR]...
42,192
7,194,186
2023-02-20 17:39:05
53,078,114
66
2018-10-31 07:14:58
2,396,539
2023-02-20 17:39:05
https://stackoverflow.com/q/47075661
https://stackoverflow.com/a/53078114
<p><strong>Why?</strong></p> <p>Programs that sync files such as dropbox, git etc use inotify to notice changes to the file system. The limit can be see by -</p> <pre><code>cat /proc/sys/fs/inotify/max_user_watches </code></pre> <p>For me, it shows <strong>100000</strong>. When this limit is not enough to monitor all f...
<p><strong>Why?</strong></p> <p>Programs that sync files such as dropbox, git etc use inotify to notice changes to the file system. The limit can be see by -</p> <pre><code>cat /proc/sys/fs/inotify/max_user_watches </code></pre> <p>For me, it shows <strong>100000</strong>. When this limit is not enough to monitor all f...
4025, 87610
extjs, sencha-cmd
<h1>Error "User limit of inotify watches reached". ExtReact build</h1> <p>I installed ExtReact, with examples. When I run</p> <pre><code>npm start </code></pre> <p>I get an error: </p> <pre><code>ERROR in [@extjs/reactor-webpack-plugin]: Error: [ERR] BUILD FAILED [ERR] com.sencha.exceptions.BasicException: User limi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,179
cmd
# Error "User limit of inotify watches reached". ExtReact build I installed ExtReact, with examples. When I run ``` npm start ``` I get an error: ``` ERROR in [@extjs/reactor-webpack-plugin]: Error: [ERR] BUILD FAILED [ERR] com.sencha.exceptions.BasicException: User limit of inotify watches reached [ERR] [ERR] Tot...
**Why?** Programs that sync files such as dropbox, git etc use inotify to notice changes to the file system. The limit can be see by - ``` cat /proc/sys/fs/inotify/max_user_watches ``` For me, it shows **100000**. When this limit is not enough to monitor all files inside a directory it throws this error. --- **Inc...
2458571
Run multiple sql files in mysql batch
29
2010-03-16 22:17:30
<p>to run a single file you can run in mysql </p> <blockquote> <p>.\ filename</p> </blockquote> <p>or you outside of mysql you can run </p> <blockquote> <p>mysql &lt; filename</p> </blockquote> <p>I have a directory of sql files so I'm trying to run them all at once by using a wildcard</p> <blockquote> <p>*....
47,926
1,100,768
2023-04-01 17:29:57
2,458,628
66
2010-03-16 22:31:01
172,594
2010-03-16 22:31:01
https://stackoverflow.com/q/2458571
https://stackoverflow.com/a/2458628
<p>Assuming you're using bash:</p> <p><code>cat *.sql | mysql</code></p>
<p>Assuming you're using bash:</p> <p><code>cat *.sql | mysql</code></p>
21, 7002
batch-file, mysql
<h1>Run multiple sql files in mysql batch</h1> <p>to run a single file you can run in mysql </p> <blockquote> <p>.\ filename</p> </blockquote> <p>or you outside of mysql you can run </p> <blockquote> <p>mysql &lt; filename</p> </blockquote> <p>I have a directory of sql files so I'm trying to run them all at onc...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,180
cmd
# Run multiple sql files in mysql batch to run a single file you can run in mysql > .\ filename or you outside of mysql you can run > mysql < filename I have a directory of sql files so I'm trying to run them all at once by using a wildcard > *.sql but it doesn't work. Any ideas?
Assuming you're using bash: `cat *.sql | mysql`
7769591
"was unexpected at this time."
50
2011-10-14 15:03:34
<p>I'm running this command on a batch file: </p> <pre><code>for %I in (*.txt *.doc) do copy %I c:\test2 </code></pre> <p>...and it keeps returning:</p> <blockquote> <p>I was unexpected at this time.</p> </blockquote> <p>What is the cause of this error?</p>
119,443
995,633
2024-09-04 20:14:16
7,769,757
65
2011-10-14 15:16:28
14,860
2011-10-14 15:16:28
https://stackoverflow.com/q/7769591
https://stackoverflow.com/a/7769757
<p>If you're running within a batch/cmd file, you need to <em>double</em> the <code>%</code> markers:</p> <pre><code>for %%i in (*.txt *.doc) do copy %%i c:\test2 </code></pre> <p>The single <code>%</code> variant only works from the command line.</p>
<p>If you're running within a batch/cmd file, you need to <em>double</em> the <code>%</code> markers:</p> <pre><code>for %%i in (*.txt *.doc) do copy %%i c:\test2 </code></pre> <p>The single <code>%</code> variant only works from the command line.</p>
64, 379, 2313, 7002
arguments, batch-file, error-handling, windows
<h1>"was unexpected at this time."</h1> <p>I'm running this command on a batch file: </p> <pre><code>for %I in (*.txt *.doc) do copy %I c:\test2 </code></pre> <p>...and it keeps returning:</p> <blockquote> <p>I was unexpected at this time.</p> </blockquote> <p>What is the cause of this error?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,181
cmd
# "was unexpected at this time." I'm running this command on a batch file: ``` for %I in (*.txt *.doc) do copy %I c:\test2 ``` ...and it keeps returning: > I was unexpected at this time. What is the cause of this error?
If you're running within a batch/cmd file, you need to *double* the `%` markers: ``` for %%i in (*.txt *.doc) do copy %%i c:\test2 ``` The single `%` variant only works from the command line.
11156754
What the C# equivalent of "mklink /J"?
49
2012-06-22 13:05:24
<p>I know how to create a symbolic link in windows in a .bat script:</p> <pre><code>mklink /J &lt;LinkPath&gt; &lt;OriginalResourcePath&gt; </code></pre> <p>How to do the same thing in C# ?</p> <p>I've not been happy with the googling, because i'm a beginner in C# and I probably don't use the right terms. Anybody ca...
34,027
1,060,205
2023-01-25 14:53:19
11,156,870
65
2012-06-22 13:11:59
893,099
2020-10-13 08:47:39
https://stackoverflow.com/q/11156754
https://stackoverflow.com/a/11156870
<p><strong>Warning</strong>: The question is not clear as it refers to <strong>symbolic links</strong> but at the same time refers to the <strong>/J</strong> switch that is used to create a junction. This answer refers to &quot;how to create a symbolic link in c#&quot; (without the /J). Instead, For creating <strong>ju...
<p><strong>Warning</strong>: The question is not clear as it refers to <strong>symbolic links</strong> but at the same time refers to the <strong>/J</strong> switch that is used to create a junction. This answer refers to &quot;how to create a symbolic link in c#&quot; (without the /J). Instead, For creating <strong>ju...
9, 64, 7002, 66250
batch-file, c#, mklink, windows
<h1>What the C# equivalent of "mklink /J"?</h1> <p>I know how to create a symbolic link in windows in a .bat script:</p> <pre><code>mklink /J &lt;LinkPath&gt; &lt;OriginalResourcePath&gt; </code></pre> <p>How to do the same thing in C# ?</p> <p>I've not been happy with the googling, because i'm a beginner in C# and ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,182
cmd
# What the C# equivalent of "mklink /J"? I know how to create a symbolic link in windows in a .bat script: ``` mklink /J <LinkPath> <OriginalResourcePath> ``` How to do the same thing in C# ? I've not been happy with the googling, because i'm a beginner in C# and I probably don't use the right terms. Anybody can in...
**Warning**: The question is not clear as it refers to **symbolic links** but at the same time refers to the **/J** switch that is used to create a junction. This answer refers to "how to create a symbolic link in c#" (without the /J). Instead, For creating **junctions**, please refer to [In .NET, how do I Create a Jun...
6781799
Batch equivalent of "source" on Windows: how to run a Python script from a virtualenv
42
2011-07-21 19:43:05
<p>I've done a fair bit of bash scripting, but very little batch scripting on Windows. I'm trying to activate a Python virtualenv, run a Python script, then deactivate the virtualenv when the script exits.</p> <p>I've got a folder called <code>env</code>, which is my virtualenv, and a folder called work, which contain...
35,464
788,337
2019-03-27 10:04:49
6,782,236
65
2011-07-21 20:20:01
838,975
2019-03-27 10:01:00
https://stackoverflow.com/q/6781799
https://stackoverflow.com/a/6782236
<p>I'd say you just need to prepend 'call' to your activate.bat invocation, to ensure that the current batch file is resumed after activate is executed:</p> <pre><code>call %~dp0env\Scripts\activate.bat </code></pre> <p>Consider doing the same for <code>deactivate.bat</code>. Furthermore, if you want to ensure that t...
<p>I'd say you just need to prepend 'call' to your activate.bat invocation, to ensure that the current batch file is resumed after activate is executed:</p> <pre><code>call %~dp0env\Scripts\activate.bat </code></pre> <p>Consider doing the same for <code>deactivate.bat</code>. Furthermore, if you want to ensure that t...
16, 64, 531, 7002, 14529
batch-file, python, scripting, virtualenv, windows
<h1>Batch equivalent of "source" on Windows: how to run a Python script from a virtualenv</h1> <p>I've done a fair bit of bash scripting, but very little batch scripting on Windows. I'm trying to activate a Python virtualenv, run a Python script, then deactivate the virtualenv when the script exits.</p> <p>I've got a ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,183
cmd
# Batch equivalent of "source" on Windows: how to run a Python script from a virtualenv I've done a fair bit of bash scripting, but very little batch scripting on Windows. I'm trying to activate a Python virtualenv, run a Python script, then deactivate the virtualenv when the script exits. I've got a folder called `e...
I'd say you just need to prepend 'call' to your activate.bat invocation, to ensure that the current batch file is resumed after activate is executed: ``` call %~dp0env\Scripts\activate.bat ``` Consider doing the same for `deactivate.bat`. Furthermore, if you want to ensure that the current cmd.exe environment is not ...
524081
BAT file to create Java CLASSPATH
39
2009-02-07 16:36:37
<p>I want to distribute a command-line application written in Java on Windows. </p> <p>My application is distributed as a zip file, which has a lib directory entry which has the .jar files needed for invoking my main class. Currently, for Unix environments, I have a shell script which invokes the java command with a C...
90,037
3,973
2017-04-03 13:42:24
524,491
65
2009-02-07 20:16:20
6,414
2012-06-19 13:00:40
https://stackoverflow.com/q/524081
https://stackoverflow.com/a/524491
<p>You want to use the for loop in Batch script</p> <pre><code> @echo off setLocal EnableDelayedExpansion set CLASSPATH=" for /R ./lib %%a in (*.jar) do ( set CLASSPATH=!CLASSPATH!;%%a ) set CLASSPATH=!CLASSPATH!" echo !CLASSPATH! </code></pre> <p>This really helped me when I was looking for a batch script t...
<p>You want to use the for loop in Batch script</p> <pre><code> @echo off setLocal EnableDelayedExpansion set CLASSPATH=" for /R ./lib %%a in (*.jar) do ( set CLASSPATH=!CLASSPATH!;%%a ) set CLASSPATH=!CLASSPATH!" echo !CLASSPATH! </code></pre> <p>This really helped me when I was looking for a batch script t...
17, 64, 1231, 7002
batch-file, command-line, java, windows
<h1>BAT file to create Java CLASSPATH</h1> <p>I want to distribute a command-line application written in Java on Windows. </p> <p>My application is distributed as a zip file, which has a lib directory entry which has the .jar files needed for invoking my main class. Currently, for Unix environments, I have a shell scr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,184
cmd
# BAT file to create Java CLASSPATH I want to distribute a command-line application written in Java on Windows. My application is distributed as a zip file, which has a lib directory entry which has the .jar files needed for invoking my main class. Currently, for Unix environments, I have a shell script which invokes...
You want to use the for loop in Batch script ``` @echo off setLocal EnableDelayedExpansion set CLASSPATH=" for /R ./lib %%a in (*.jar) do ( set CLASSPATH=!CLASSPATH!;%%a ) set CLASSPATH=!CLASSPATH!" echo !CLASSPATH! ``` This really helped me when I was looking for a batch script to iterate through all the f...
44926858
Batch script to convert, youtube-dl webm file to mp3 with ffmpeg
36
2017-07-05 12:53:12
<p>I'm using <a href="https://github.com/rg3/youtube-dl/blob/master/README.md#readme" rel="noreferrer">youtube-dl</a> to extract the best possible audio quality from youtube videos. However the best quality audio usually turns out to be the webm format, which isn't useful. I would like to write a batch script that conv...
56,812
6,995,214
2024-04-01 01:28:34
44,929,515
65
2017-07-05 14:47:57
null
2017-07-05 14:47:57
https://stackoverflow.com/q/44926858
https://stackoverflow.com/a/44929515
<p>youtube-dl already contains this functionality - just specify that you want mp3:</p> <pre><code>youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=BaW_jenozKc </code></pre> <p>Replace <code>https://www.youtube.com/watch?v=BaW_jenozKc</code> with your actual URL.</p>
<p>youtube-dl already contains this functionality - just specify that you want mp3:</p> <pre><code>youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=BaW_jenozKc </code></pre> <p>Replace <code>https://www.youtube.com/watch?v=BaW_jenozKc</code> with your actual URL.</p>
1033, 3847, 7002, 57063, 72317
batch-file, ffmpeg, mp3, webm, youtube-dl
<h1>Batch script to convert, youtube-dl webm file to mp3 with ffmpeg</h1> <p>I'm using <a href="https://github.com/rg3/youtube-dl/blob/master/README.md#readme" rel="noreferrer">youtube-dl</a> to extract the best possible audio quality from youtube videos. However the best quality audio usually turns out to be the webm ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,185
cmd
# Batch script to convert, youtube-dl webm file to mp3 with ffmpeg I'm using [youtube-dl](https://github.com/rg3/youtube-dl/blob/master/README.md#readme) to extract the best possible audio quality from youtube videos. However the best quality audio usually turns out to be the webm format, which isn't useful. I would l...
youtube-dl already contains this functionality - just specify that you want mp3: ``` youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=BaW_jenozKc ``` Replace `https://www.youtube.com/watch?v=BaW_jenozKc` with your actual URL.
23926620
How to execute a for loop in batches?
31
2014-05-29 05:55:35
<pre><code>for x in records: data = {} for y in sObjectName.describe()['fields'] data[y['name']] = x[y['name']] ls.append(adapter.insert_posts(collection, data)) </code></pre> <p>I want to execute the code ls.append(adapter.insert_post(collection, x)) in the batch size of 500, where x should contain ...
42,783
2,297,135
2023-10-02 22:29:56
23,926,699
65
2014-05-29 06:00:46
1,204,143
2023-10-02 22:29:56
https://stackoverflow.com/q/23926620
https://stackoverflow.com/a/23926699
<p>The general structure I use looks like this:</p> <pre><code>worklist = [...] batchsize = 500 for i in range(0, len(worklist), batchsize): batch = worklist[i:i+batchsize] # the result might be shorter than batchsize at the end # do stuff with batch </code></pre> <p>Note that we're using the <code>step</code>...
<p>The general structure I use looks like this:</p> <pre><code>worklist = [...] batchsize = 500 for i in range(0, len(worklist), batchsize): batch = worklist[i:i+batchsize] # the result might be shorter than batchsize at the end # do stuff with batch </code></pre> <p>Note that we're using the <code>step</code>...
16, 30645, 59047
batch-processing, python, python-2.7
<h1>How to execute a for loop in batches?</h1> <pre><code>for x in records: data = {} for y in sObjectName.describe()['fields'] data[y['name']] = x[y['name']] ls.append(adapter.insert_posts(collection, data)) </code></pre> <p>I want to execute the code ls.append(adapter.insert_post(collection, x)) in...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,186
cmd
# How to execute a for loop in batches? ``` for x in records: data = {} for y in sObjectName.describe()['fields'] data[y['name']] = x[y['name']] ls.append(adapter.insert_posts(collection, data)) ``` I want to execute the code ls.append(adapter.insert_post(collection, x)) in the batch size of 500, wh...
The general structure I use looks like this: ``` worklist = [...] batchsize = 500 for i in range(0, len(worklist), batchsize): batch = worklist[i:i+batchsize] # the result might be shorter than batchsize at the end # do stuff with batch ``` Note that we're using the `step` argument of `range` to simplify the...
24048430
Logging Method signature using swift
56
2014-06-04 22:07:54
<p>I am trying to rewrite my logging class and I would like to know how to substitute <strong>PRETTY_FUNCTION</strong> or NSStringFromSelector(_cmd) in a swift file in order to track the method calls?</p>
41,034
1,538,839
2024-04-24 05:36:15
24,129,867
64
2014-06-09 22:10:35
144,857
2018-06-18 01:39:01
https://stackoverflow.com/q/24048430
https://stackoverflow.com/a/24129867
<p>Check out a new library I've just published: <a href="https://github.com/DaveWoodCom/XCGLogger" rel="noreferrer">https://github.com/DaveWoodCom/XCGLogger</a></p> <p>It's a debug logging library for Swift.</p> <p>The key to being able to use the <code>#function</code> macros, is to set them as default values to you...
<p>Check out a new library I've just published: <a href="https://github.com/DaveWoodCom/XCGLogger" rel="noreferrer">https://github.com/DaveWoodCom/XCGLogger</a></p> <p>It's a debug logging library for Swift.</p> <p>The key to being able to use the <code>#function</code> macros, is to set them as default values to you...
2631, 58338, 104797, 104810
cmd, ios, ios8, swift
<h1>Logging Method signature using swift</h1> <p>I am trying to rewrite my logging class and I would like to know how to substitute <strong>PRETTY_FUNCTION</strong> or NSStringFromSelector(_cmd) in a swift file in order to track the method calls?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,187
cmd
# Logging Method signature using swift I am trying to rewrite my logging class and I would like to know how to substitute **PRETTY_FUNCTION** or NSStringFromSelector(_cmd) in a swift file in order to track the method calls?
Check out a new library I've just published: <https://github.com/DaveWoodCom/XCGLogger> It's a debug logging library for Swift. The key to being able to use the `#function` macros, is to set them as default values to your logging function. The compiler will then fill them in using the expected values. ``` func log(l...
8713960
cmd.exe /k switch
45
2012-01-03 14:44:24
<p>I am trying to switch to a directory using <code>cmd</code> and then execute a batch file:</p> <pre><code>cmd /k cd &quot;C:\myfolder&quot; startbatch.bat </code></pre> <p>I have also tried (without success)</p> <pre><code>cmd cd /k cd &quot;C:\myfolder&quot; | startbatch.bat </code></pre> <p>Although the first line...
157,752
742,465
2024-12-16 14:44:03
8,714,013
64
2012-01-03 14:48:02
54,937
2022-02-02 21:02:26
https://stackoverflow.com/q/8713960
https://stackoverflow.com/a/8714013
<p>Correct syntax is:</p> <pre><code>cmd /k &quot;cd /d c:\myfolder &amp;&amp; startbatch.bat&quot; </code></pre>
<p>Correct syntax is:</p> <pre><code>cmd /k &quot;cd /d c:\myfolder &amp;&amp; startbatch.bat&quot; </code></pre>
64, 1231, 2631
cmd, command-line, windows
<h1>cmd.exe /k switch</h1> <p>I am trying to switch to a directory using <code>cmd</code> and then execute a batch file:</p> <pre><code>cmd /k cd &quot;C:\myfolder&quot; startbatch.bat </code></pre> <p>I have also tried (without success)</p> <pre><code>cmd cd /k cd &quot;C:\myfolder&quot; | startbatch.bat </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,188
cmd
# cmd.exe /k switch I am trying to switch to a directory using `cmd` and then execute a batch file: ``` cmd /k cd "C:\myfolder" startbatch.bat ``` I have also tried (without success) ``` cmd cd /k cd "C:\myfolder" | startbatch.bat ``` Although the first line (`cmd /k`) seems to run okay, but the second command is ...
Correct syntax is: ``` cmd /k "cd /d c:\myfolder && startbatch.bat" ```
25384358
Batch - If, ElseIf, Else
41
2014-08-19 13:13:25
<p>Whats wrong with this code?</p> <pre><code>IF "%language%" == "de" ( goto languageDE ) ELSE ( IF "%language%" == "en" ( goto languageEN ) ELSE ( echo Not found. ) </code></pre> <p>I'm not really good in Batch..</p>
302,712
3,956,488
2023-05-25 08:33:48
25,387,395
64
2014-08-19 15:30:54
2,128,947
2019-03-28 18:03:54
https://stackoverflow.com/q/25384358
https://stackoverflow.com/a/25387395
<pre><code>@echo off title Test echo Select a language. (de/en) set /p language= IF /i "%language%"=="de" goto languageDE IF /i "%language%"=="en" goto languageEN echo Not found. goto commonexit :languageDE echo German goto commonexit :languageEN echo English goto commonexit :commonexit pause </code></pre> <p>Th...
<pre><code>@echo off title Test echo Select a language. (de/en) set /p language= IF /i "%language%"=="de" goto languageDE IF /i "%language%"=="en" goto languageEN echo Not found. goto commonexit :languageDE echo German goto commonexit :languageEN echo English goto commonexit :commonexit pause </code></pre> <p>Th...
2773, 7002
batch-file, if-statement
<h1>Batch - If, ElseIf, Else</h1> <p>Whats wrong with this code?</p> <pre><code>IF "%language%" == "de" ( goto languageDE ) ELSE ( IF "%language%" == "en" ( goto languageEN ) ELSE ( echo Not found. ) </code></pre> <p>I'm not really good in Batch..</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,189
cmd
# Batch - If, ElseIf, Else Whats wrong with this code? ``` IF "%language%" == "de" ( goto languageDE ) ELSE ( IF "%language%" == "en" ( goto languageEN ) ELSE ( echo Not found. ) ``` I'm not really good in Batch..
``` @echo off title Test echo Select a language. (de/en) set /p language= IF /i "%language%"=="de" goto languageDE IF /i "%language%"=="en" goto languageEN echo Not found. goto commonexit :languageDE echo German goto commonexit :languageEN echo English goto commonexit :commonexit pause ``` The point is that batc...
10519389
Get last created directory batch command
27
2012-05-09 15:38:05
<p>How can i get newest subfolder in directory ? <br> I need it in <code>MKLINK /D</code> command.</p> <p>Thanks </p>
41,451
312,251
2016-12-15 21:27:01
10,519,606
64
2012-05-09 15:52:04
63,733
2016-12-15 21:27:01
https://stackoverflow.com/q/10519389
https://stackoverflow.com/a/10519606
<pre><code>FOR /F "delims=" %%i IN ('dir /b /ad-h /t:c /od') DO SET a=%%i echo Most recent subfolder: %a% </code></pre> <p><em>(<code>%i</code> for windows 10)</em></p> <ul> <li><code>/b</code> is for bare format</li> <li><code>/ad-h</code> only directories, but not the hidden ones</li> <li><code>t:c</code> means to ...
<pre><code>FOR /F "delims=" %%i IN ('dir /b /ad-h /t:c /od') DO SET a=%%i echo Most recent subfolder: %a% </code></pre> <p><em>(<code>%i</code> for windows 10)</em></p> <ul> <li><code>/b</code> is for bare format</li> <li><code>/ad-h</code> only directories, but not the hidden ones</li> <li><code>t:c</code> means to ...
7002
batch-file
<h1>Get last created directory batch command</h1> <p>How can i get newest subfolder in directory ? <br> I need it in <code>MKLINK /D</code> command.</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,190
cmd
# Get last created directory batch command How can i get newest subfolder in directory ? I need it in `MKLINK /D` command. Thanks
``` FOR /F "delims=" %%i IN ('dir /b /ad-h /t:c /od') DO SET a=%%i echo Most recent subfolder: %a% ``` *(`%i` for windows 10)* - `/b` is for bare format - `/ad-h` only directories, but not the hidden ones - `t:c` means to use the creation date for sorting (use `t:w` for last write date) - `/od` sort oldest first - Th...
660320
How to automate a process with the sqlite3.exe command line tool?
62
2009-03-18 22:16:08
<p>I'm trying to bulk load a lot of data ( 5.5 million rows ) into an SQLite database file. Loading via INSERTs seems to be far too slow, so I'm trying to use the sqlite3 command line tool and the .import command.</p> <p>It works perfectly if I enter the commands by hand, but I can't for the life of me work out how to...
83,789
41,477
2017-08-25 10:42:20
660,352
63
2009-03-18 22:29:16
73,070
2009-03-18 22:29:16
https://stackoverflow.com/q/660320
https://stackoverflow.com/a/660352
<p>Create a text file with the lines you want to enter into the sqlite command line program, like this:</p> <pre> CREATE TABLE log_entry ( ); .separator "\t" .import logfile.log log_entry</pre> <p>and then just call <code>sqlite3 database.db &lt; commands.txt</code></p>
<p>Create a text file with the lines you want to enter into the sqlite command line program, like this:</p> <pre> CREATE TABLE log_entry ( ); .separator "\t" .import logfile.log log_entry</pre> <p>and then just call <code>sqlite3 database.db &lt; commands.txt</code></p>
121, 531, 7002
batch-file, scripting, sqlite
<h1>How to automate a process with the sqlite3.exe command line tool?</h1> <p>I'm trying to bulk load a lot of data ( 5.5 million rows ) into an SQLite database file. Loading via INSERTs seems to be far too slow, so I'm trying to use the sqlite3 command line tool and the .import command.</p> <p>It works perfectly if I...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,191
cmd
# How to automate a process with the sqlite3.exe command line tool? I'm trying to bulk load a lot of data ( 5.5 million rows ) into an SQLite database file. Loading via INSERTs seems to be far too slow, so I'm trying to use the sqlite3 command line tool and the .import command. It works perfectly if I enter the comma...
Create a text file with the lines you want to enter into the sqlite command line program, like this: ``` CREATE TABLE log_entry ( ); .separator "\t" .import logfile.log log_entry ``` and then just call `sqlite3 database.db < commands.txt`
26216727
How to submit a job to any [subset] of nodes from nodelist in SLURM?
45
2014-10-06 12:57:42
<p>I have a couple of thousand jobs to run on a SLURM cluster with 16 nodes. These jobs should run only on a subset of the available nodes of size 7. Some of the tasks are parallelized, hence use all the CPU power of a single node while others are single threaded. Therefore, multiple jobs should run at the same time on...
76,608
2,584,278
2024-02-02 12:51:50
26,246,348
63
2014-10-07 22:30:03
1,763,614
2024-02-02 12:51:50
https://stackoverflow.com/q/26216727
https://stackoverflow.com/a/26246348
<p>You can work the other way around; rather than specifying which nodes to use, with the effect that each job is allocated all the 7 nodes, specify which nodes not to use:</p> <pre><code>sbatch --exclude=myCluster[01-09] myScript.sh </code></pre> <p>and Slurm will never allocate more than 7 nodes to your jobs. Make su...
<p>You can work the other way around; rather than specifying which nodes to use, with the effect that each job is allocated all the 7 nodes, specify which nodes not to use:</p> <pre><code>sbatch --exclude=myCluster[01-09] myScript.sh </code></pre> <p>and Slurm will never allocate more than 7 nodes to your jobs. Make su...
9228, 30645, 97759, 105553
batch-processing, cluster-computing, sbatch, slurm
<h1>How to submit a job to any [subset] of nodes from nodelist in SLURM?</h1> <p>I have a couple of thousand jobs to run on a SLURM cluster with 16 nodes. These jobs should run only on a subset of the available nodes of size 7. Some of the tasks are parallelized, hence use all the CPU power of a single node while other...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,192
cmd
# How to submit a job to any [subset] of nodes from nodelist in SLURM? I have a couple of thousand jobs to run on a SLURM cluster with 16 nodes. These jobs should run only on a subset of the available nodes of size 7. Some of the tasks are parallelized, hence use all the CPU power of a single node while others are sin...
You can work the other way around; rather than specifying which nodes to use, with the effect that each job is allocated all the 7 nodes, specify which nodes not to use: ``` sbatch --exclude=myCluster[01-09] myScript.sh ``` and Slurm will never allocate more than 7 nodes to your jobs. Make sure though that the cluste...
27246899
Batch check if mapped network drive exists
43
2014-12-02 10:18:17
<p>I'm currently writing a script that should map a network drive to the letter <code>Z</code> , i'm using the command <code>net use z: \\path</code> , the thing is that if the user is already using this letter i won't be able to map it, is there any way to check the existense of this drive (z) and if it exists to unm...
137,915
3,502,786
2020-02-14 18:22:00
27,247,398
63
2014-12-02 10:42:35
3,510,480
2014-12-02 10:42:35
https://stackoverflow.com/q/27246899
https://stackoverflow.com/a/27247398
<p>You can check whether the drive is mounted by <code>IF EXIST Z:\</code>. This should work:</p> <pre><code>if exist z:\ ( net use z: /delete ) net use z: \\path </code></pre>
<p>You can check whether the drive is mounted by <code>IF EXIST Z:\</code>. This should work:</p> <pre><code>if exist z:\ ( net use z: /delete ) net use z: \\path </code></pre>
2631, 7002, 30645
batch-file, batch-processing, cmd
<h1>Batch check if mapped network drive exists</h1> <p>I'm currently writing a script that should map a network drive to the letter <code>Z</code> , i'm using the command <code>net use z: \\path</code> , the thing is that if the user is already using this letter i won't be able to map it, is there any way to check the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,193
cmd
# Batch check if mapped network drive exists I'm currently writing a script that should map a network drive to the letter `Z` , i'm using the command `net use z: \\path` , the thing is that if the user is already using this letter i won't be able to map it, is there any way to check the existense of this drive (z) and...
You can check whether the drive is mounted by `IF EXIST Z:\`. This should work: ``` if exist z:\ ( net use z: /delete ) net use z: \\path ```
19652678
How to mention C:\Program Files in batchfile
38
2013-10-29 08:00:48
<p>I need to invoke an exe file in C:\Program Files directory from a batch file.How can we mention the directory name &quot;Program Files&quot; in batch file.I am getting error like C:\Program not found.</p> <p>I believe that % or ~ needs to be added in between but couldn't get it.Kindly assist.</p>
182,435
1,493,971
2022-05-01 12:21:11
19,652,711
63
2013-10-29 08:02:49
2,072,833
2017-03-12 21:26:16
https://stackoverflow.com/q/19652678
https://stackoverflow.com/a/19652711
<p>Surround the script call with <code>""</code>, generally it's good practices to do so with filepath.</p> <pre><code>"C:\Program Files" </code></pre> <p>Although for this particular name you probably should use environment variable like this :</p> <pre><code>"%ProgramFiles%\batch.cmd" </code></pre> <p>or for 32 b...
<p>Surround the script call with <code>""</code>, generally it's good practices to do so with filepath.</p> <pre><code>"C:\Program Files" </code></pre> <p>Although for this particular name you probably should use environment variable like this :</p> <pre><code>"%ProgramFiles%\batch.cmd" </code></pre> <p>or for 32 b...
7002
batch-file
<h1>How to mention C:\Program Files in batchfile</h1> <p>I need to invoke an exe file in C:\Program Files directory from a batch file.How can we mention the directory name &quot;Program Files&quot; in batch file.I am getting error like C:\Program not found.</p> <p>I believe that % or ~ needs to be added in between but ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,194
cmd
# How to mention C:\Program Files in batchfile I need to invoke an exe file in C:\Program Files directory from a batch file.How can we mention the directory name "Program Files" in batch file.I am getting error like C:\Program not found. I believe that % or ~ needs to be added in between but couldn't get it.Kindly as...
Surround the script call with `""`, generally it's good practices to do so with filepath. ``` "C:\Program Files" ``` Although for this particular name you probably should use environment variable like this : ``` "%ProgramFiles%\batch.cmd" ``` or for 32 bits program on 64 bit windows : ``` "%ProgramFiles(x86)%\batc...
4133244
change directory in batch file using variable
33
2010-11-09 11:39:58
<p>Here's the question:</p> <pre><code>set Pathname = C:\Program Files cd %Pathname% pause </code></pre> <p>The above doesn't change the directory, as I would expect. Can anybody please tell me why?</p>
110,604
23,724
2014-05-10 08:38:49
4,133,322
63
2010-11-09 11:51:31
7,903
2014-05-10 08:38:49
https://stackoverflow.com/q/4133244
https://stackoverflow.com/a/4133322
<p>The <code>set</code> statement doesn't treat spaces the way you expect; your variable is really named <code>Pathname[space]</code> and is equal to <code>[space]C:\Program Files</code>.</p> <p>Remove the spaces from both sides of the <code>=</code> sign, and put the value in double quotes:</p> <pre><code>set Pathna...
<p>The <code>set</code> statement doesn't treat spaces the way you expect; your variable is really named <code>Pathname[space]</code> and is equal to <code>[space]C:\Program Files</code>.</p> <p>Remove the spaces from both sides of the <code>=</code> sign, and put the value in double quotes:</p> <pre><code>set Pathna...
1231, 7002
batch-file, command-line
<h1>change directory in batch file using variable</h1> <p>Here's the question:</p> <pre><code>set Pathname = C:\Program Files cd %Pathname% pause </code></pre> <p>The above doesn't change the directory, as I would expect. Can anybody please tell me 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,195
cmd
# change directory in batch file using variable Here's the question: ``` set Pathname = C:\Program Files cd %Pathname% pause ``` The above doesn't change the directory, as I would expect. Can anybody please tell me why?
The `set` statement doesn't treat spaces the way you expect; your variable is really named `Pathname[space]` and is equal to `[space]C:\Program Files`. Remove the spaces from both sides of the `=` sign, and put the value in double quotes: ``` set Pathname="C:\Program Files" ``` Also, if your command prompt is not op...
14905876
How to return an error code without closing the Command Prompt window?
31
2013-02-16 01:15:33
<p>I am writing a batch file which validates a couple of files. When one of the file isn't valid, I want the batch script to stop and return an error code >0. The code below seem to do the job, but calling "EXIT 2" closes the Command Prompt window in which the script was running.</p> <pre><code>:Validate SETLOCAL Vali...
38,328
42,024
2020-06-05 09:37:27
14,905,970
63
2013-02-16 01:28:08
17,034
2013-02-16 01:28:08
https://stackoverflow.com/q/14905876
https://stackoverflow.com/a/14905970
<p>To get help for command prompt commands use their /? option. <code>Exit /?</code> shows:</p> <blockquote> <p>Quits the CMD.EXE program (command interpreter) or the current batch script.</p> <p>EXIT [/B] [exitCode]</p> <p>/B specifies to exit the current batch script instead of ...
<p>To get help for command prompt commands use their /? option. <code>Exit /?</code> shows:</p> <blockquote> <p>Quits the CMD.EXE program (command interpreter) or the current batch script.</p> <p>EXIT [/B] [exitCode]</p> <p>/B specifies to exit the current batch script instead of ...
64, 7002, 9938
batch-file, command-prompt, windows
<h1>How to return an error code without closing the Command Prompt window?</h1> <p>I am writing a batch file which validates a couple of files. When one of the file isn't valid, I want the batch script to stop and return an error code >0. The code below seem to do the job, but calling "EXIT 2" closes the Command Prompt...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,196
cmd
# How to return an error code without closing the Command Prompt window? I am writing a batch file which validates a couple of files. When one of the file isn't valid, I want the batch script to stop and return an error code >0. The code below seem to do the job, but calling "EXIT 2" closes the Command Prompt window i...
To get help for command prompt commands use their /? option. `Exit /?` shows: > Quits the CMD.EXE program (command interpreter) or the current batch > script. > > EXIT [/B] [exitCode] > > /B specifies to exit the current batch script instead of > CMD.EXE. If executed from outside a batch script, it > will quit CMD.EXE...
4692673
How to change Screen buffer size in Windows Command Prompt from batch script
57
2011-01-14 15:29:18
<p>I know you can do right click properties ->layout and there change it manually.</p> <p>But how would you go about changing it from a Windows batch script?</p> <p>I know you can change size of it from script using something like this</p> <p><code>MODE CON: COLS=90 LINES=10</code></p> <p>But how can you change buf...
149,974
117,386
2020-04-15 07:57:32
5,779,422
62
2011-04-25 14:35:40
534,318
2011-04-25 14:35:40
https://stackoverflow.com/q/4692673
https://stackoverflow.com/a/5779422
<p>I was just searching for an answer to this exact question, come to find out the command itself adjusts the buffer!</p> <pre><code>mode con:cols=140 lines=70 </code></pre> <p>The <strong>lines=70</strong> part actually adjusts the Height in the 'Screen Buffer Size' setting, NOT the Height in the 'Window Size' setti...
<p>I was just searching for an answer to this exact question, come to find out the command itself adjusts the buffer!</p> <pre><code>mode con:cols=140 lines=70 </code></pre> <p>The <strong>lines=70</strong> part actually adjusts the Height in the 'Screen Buffer Size' setting, NOT the Height in the 'Window Size' setti...
64, 2631, 7002
batch-file, cmd, windows
<h1>How to change Screen buffer size in Windows Command Prompt from batch script</h1> <p>I know you can do right click properties ->layout and there change it manually.</p> <p>But how would you go about changing it from a Windows batch script?</p> <p>I know you can change size of it from script using something like t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,197
cmd
# How to change Screen buffer size in Windows Command Prompt from batch script I know you can do right click properties ->layout and there change it manually. But how would you go about changing it from a Windows batch script? I know you can change size of it from script using something like this `MODE CON: COLS=90...
I was just searching for an answer to this exact question, come to find out the command itself adjusts the buffer! ``` mode con:cols=140 lines=70 ``` The **lines=70** part actually adjusts the Height in the 'Screen Buffer Size' setting, NOT the Height in the 'Window Size' setting. Easily proven by running the comman...