<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://entorb.net//wiki/index.php?action=history&amp;feed=atom&amp;title=Windows_Batch_Scripting</id>
	<title>Windows Batch Scripting - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://entorb.net//wiki/index.php?action=history&amp;feed=atom&amp;title=Windows_Batch_Scripting"/>
	<link rel="alternate" type="text/html" href="https://entorb.net//wiki/index.php?title=Windows_Batch_Scripting&amp;action=history"/>
	<updated>2026-05-06T09:41:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://entorb.net//wiki/index.php?title=Windows_Batch_Scripting&amp;diff=5412&amp;oldid=prev</id>
		<title>Torben: /* Run as other user */</title>
		<link rel="alternate" type="text/html" href="https://entorb.net//wiki/index.php?title=Windows_Batch_Scripting&amp;diff=5412&amp;oldid=prev"/>
		<updated>2026-04-17T17:07:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Run as other user&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:07, 17 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l238&quot;&gt;Line 238:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 238:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  /K to keep window open when finished&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  /K to keep window open when finished&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  /C to close window when finished&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  /C to close window when finished&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;===checks.cmd - Run chk_*.cmd===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;run all chk_*.cmd scripts in same dir and print summary of failed ones&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; @echo off&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; title %~n0&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; setlocal enabledelayedexpansion&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; cd %~dp0\..&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; set failures=0&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; set &quot;failed_list=&quot;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; for %%f in (%~dp0chk_*.cmd) do (&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;     echo.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;     echo === %%~nf ===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;     call &quot;%%f&quot;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;     if errorlevel 1 (&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;         set /a failures+=1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;         set &quot;failed_list=!failed_list! %%~nf&quot;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;     )&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; )&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; echo.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; if !failures!==0 (&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;     echo All checks passed.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; ) else (&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;     echo !failures! checks failed:!failed_list!&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; )&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; echo.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; pause&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Other scripts contain&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; ...&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; some_command&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; if errorlevel 1 exit /b 1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Torben</name></author>
	</entry>
	<entry>
		<id>https://entorb.net//wiki/index.php?title=Windows_Batch_Scripting&amp;diff=5411&amp;oldid=prev</id>
		<title>Torben at 17:04, 17 April 2026</title>
		<link rel="alternate" type="text/html" href="https://entorb.net//wiki/index.php?title=Windows_Batch_Scripting&amp;diff=5411&amp;oldid=prev"/>
		<updated>2026-04-17T17:04:49Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:04, 17 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Software]][[Category:Windows]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Software]][[Category:Windows]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch see &amp;quot;Top 10 DOS Batch tips&amp;quot;] and [http://www.axel-hahn.de/batch/batchecke/tipps/ BATch-Dateien - kleine Tipps] for more stuff&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch see &amp;quot;Top 10 DOS Batch tips&amp;quot;] and [http://www.axel-hahn.de/batch/batchecke/tipps/ BATch-Dateien - kleine Tipps] for more stuff&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;===Template===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; @echo off&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; title %~n0&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; setlocal&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===current dir and filename===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===current dir and filename===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Torben</name></author>
	</entry>
	<entry>
		<id>https://entorb.net//wiki/index.php?title=Windows_Batch_Scripting&amp;diff=5399&amp;oldid=prev</id>
		<title>Torben: /* Net use for network drive mounting */</title>
		<link rel="alternate" type="text/html" href="https://entorb.net//wiki/index.php?title=Windows_Batch_Scripting&amp;diff=5399&amp;oldid=prev"/>
		<updated>2026-03-06T14:27:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Net use for network drive mounting&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Software]][[Category:Windows]]&lt;br /&gt;
[http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch see &amp;quot;Top 10 DOS Batch tips&amp;quot;] and [http://www.axel-hahn.de/batch/batchecke/tipps/ BATch-Dateien - kleine Tipps] for more stuff&lt;br /&gt;
&lt;br /&gt;
===current dir and filename===&lt;br /&gt;
 # current working dir&lt;br /&gt;
 echo %CD%&lt;br /&gt;
 # path of current file&lt;br /&gt;
 echo %0&lt;br /&gt;
# filename without the extension.&lt;br /&gt;
 echo %~n0&lt;br /&gt;
# filename and extension.&lt;br /&gt;
 echo %~nx0&lt;br /&gt;
# or &lt;br /&gt;
 echo %~n0%~x0&lt;br /&gt;
&lt;br /&gt;
===Title to Dirname===&lt;br /&gt;
 @echo off&lt;br /&gt;
 for %%f in (%cd%) do set dirname=%%~nxf&lt;br /&gt;
 title %dirname%&lt;br /&gt;
&lt;br /&gt;
===Empty c:\tmp===&lt;br /&gt;
 @echo off&lt;br /&gt;
 rmdir /q /s c:\tmp&lt;br /&gt;
 # or rd /q /s c:\tmp&lt;br /&gt;
 mkdir c:\tmp&lt;br /&gt;
&lt;br /&gt;
===find files / search (and delete) old files===&lt;br /&gt;
via forfiles&lt;br /&gt;
 forfiles /P &amp;quot;C:\tmp\test-del&amp;quot; /S /D -30 /C &amp;quot;cmd /c echo @path&amp;quot;&lt;br /&gt;
 forfiles /P &amp;quot;C:\tmp\test-del&amp;quot; /S /D -30 /C &amp;quot;cmd /c del @path&amp;quot;&lt;br /&gt;
 forfiles /P &amp;quot;C:\tmp\test-del&amp;quot; -S -D 90 -m *.log -c &amp;quot;cmd /c del @path&amp;quot;&lt;br /&gt;
&lt;br /&gt;
via robocopy&lt;br /&gt;
 robocopy &amp;quot;C:\tmp\test-del&amp;quot; &amp;quot;*.log&amp;quot; &amp;quot;C:\cleanup-logs&amp;quot; /mov /minage:90 /NP&lt;br /&gt;
 del C:\cleanup-logs /q&lt;br /&gt;
&lt;br /&gt;
===ReadOnly Flag / WriteProtection===&lt;br /&gt;
Remove&lt;br /&gt;
 attrib -h -r -s /s /d *.*&lt;br /&gt;
Set &lt;br /&gt;
 attrib +r c:\Users\torben\Desktop\SyncedFolder\*.* /s&lt;br /&gt;
&lt;br /&gt;
  R   Read-only file attribute.&lt;br /&gt;
  S   System file attribute.&lt;br /&gt;
  H   Hidden file attribute.&lt;br /&gt;
  /S  Processes matching files in the current folder and all subfolders.&lt;br /&gt;
  /D  Processes folders as well.&lt;br /&gt;
&lt;br /&gt;
===Set Current Working Dir to Script Location ===&lt;br /&gt;
This is important if the script is started using a taskmanager etc.&lt;br /&gt;
 e:&lt;br /&gt;
 cd %~dp0&lt;br /&gt;
&lt;br /&gt;
===Set Window Title===&lt;br /&gt;
 TITLE My Window Title&lt;br /&gt;
or when opening via START from another Batch file&lt;br /&gt;
 START &amp;quot;My Window Title&amp;quot; 2.cmd&lt;br /&gt;
&lt;br /&gt;
===Get FolderName===&lt;br /&gt;
This when excecuted in c:\sub\folder it returns &amp;quot;folder&amp;quot;&lt;br /&gt;
 for %%* in (%CD%) do set CurrDirName=%%~nx*&lt;br /&gt;
 echo %CurrDirName%&lt;br /&gt;
&lt;br /&gt;
===List of files to Textfile===&lt;br /&gt;
 dir *.* /b &amp;gt; ..\liste.txt&lt;br /&gt;
&lt;br /&gt;
===Pipe output to textfile===&lt;br /&gt;
From [https://support.microsoft.com/en-us/help/110930/redirecting-error-messages-from-command-prompt-stderr-stdout] You can print the errors and standard output to a single file by using the &amp;quot;&amp;amp;1&amp;quot; command to redirect the output for STDERR to STDOUT and then sending the output from STDOUT to a file:&lt;br /&gt;
 some_command &amp;gt; output.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
 some_command 1&amp;gt; output.log 2&amp;gt; error.log&lt;br /&gt;
&lt;br /&gt;
===exit if command fails with error===&lt;br /&gt;
 some_command1&lt;br /&gt;
 IF %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%&lt;br /&gt;
 some_command2&lt;br /&gt;
 IF %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%&lt;br /&gt;
&lt;br /&gt;
===Net use for network drive mounting===&lt;br /&gt;
 net use Y: \\server\path /user:myuser&lt;br /&gt;
 &lt;br /&gt;
 net use Y: /delete&lt;br /&gt;
&lt;br /&gt;
===Zip */*.ini===&lt;br /&gt;
 @echo off&lt;br /&gt;
 setlocal EnableDelayedExpansion&lt;br /&gt;
 set &amp;quot;OUT=inis.zip&amp;quot;&lt;br /&gt;
 REM Use PowerShell to expand glob pattern and pipe relative paths to tar with --files-from=-&lt;br /&gt;
 powershell -NoLogo -NoProfile -Command &amp;quot;Get-ChildItem -Path &amp;#039;*\*.ini&amp;#039; -File | ForEach-Object { $_.FullName.Substring((Get-Location).Path.Length + 1) } | tar -c -a -f &amp;#039;%OUT%&amp;#039; --files-from=-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
====if====&lt;br /&gt;
check if mounting (net use) was successful&lt;br /&gt;
 net use q: \\server\share&lt;br /&gt;
 q:&lt;br /&gt;
 cd \&lt;br /&gt;
 IF NOT EXIST dir1\dir2 (&lt;br /&gt;
   echo mouting of share failed&lt;br /&gt;
   pause&lt;br /&gt;
   c:&lt;br /&gt;
   net use q: /delete&lt;br /&gt;
   EXIT /B 1&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
====for====&lt;br /&gt;
loop over values&lt;br /&gt;
 for %%L in (cn, de, en, es, fr, ko, sk, vn) do (&lt;br /&gt;
 echo %%L&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
loop over all dirs&lt;br /&gt;
 FOR /D %%D in (&amp;quot;*&amp;quot;) DO (&lt;br /&gt;
 echo %%D&lt;br /&gt;
 )&lt;br /&gt;
double loop over all dirs&lt;br /&gt;
 FOR /D %%P in (&amp;quot;*&amp;quot;) DO (&lt;br /&gt;
 echo parent = %%P&lt;br /&gt;
   FOR /D %%C in (&amp;quot;%%P\*&amp;quot;) DO (&lt;br /&gt;
   echo child = %%C&lt;br /&gt;
   )&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
loop over files&lt;br /&gt;
 for %%F in (*.pdf) do (&lt;br /&gt;
 echo %%F&lt;br /&gt;
 copy %%F %%~nF.old&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
====for and grep.exe====&lt;br /&gt;
using UnixUtils grep.exe one can easily extract exceptions from logs:&lt;br /&gt;
 for %%F in (*.log) do (&lt;br /&gt;
   grep -B3 -A3 &amp;quot;exception&amp;quot; %%F &amp;gt; %%~nF-error.txt &lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
 :: no spaces around &amp;#039;=&amp;#039;!!!&lt;br /&gt;
 set xyz=myfile.bat&lt;br /&gt;
 set /p xyz=Variable Eingeben:&lt;br /&gt;
 set /p xyz= &amp;lt; TMP.dat &lt;br /&gt;
 echo %xyz%&lt;br /&gt;
&lt;br /&gt;
====Substrings====&lt;br /&gt;
Substring via &amp;quot;:~&amp;quot;&lt;br /&gt;
 set year=%date:~-4,4&lt;br /&gt;
Path, filename and extension of file stored in variable %%F&lt;br /&gt;
 set path=%%~pF&lt;br /&gt;
 set name=%%~nF&lt;br /&gt;
 set ext=%%~cF&lt;br /&gt;
&lt;br /&gt;
====Set Variable to Program Output====&lt;br /&gt;
 for /f &amp;quot;delims=&amp;quot; %%a in (&amp;#039; powershell -c &amp;quot;$lastmonth = (Get-Date).addMonths(-3); $lastmonth.tostring(\&amp;quot;yyyy-MM\&amp;quot;)&amp;quot; &amp;#039;) do set &amp;quot;MONTH=%%a&amp;quot;&lt;br /&gt;
 echo %MONTH%&lt;br /&gt;
&lt;br /&gt;
===Date &amp;amp; Time ===&lt;br /&gt;
====DateString====&lt;br /&gt;
 set DATESTR=%date:~-4,4%-%date:~-7,2%-%date:~-10,2%_%time:~0,2%:%time:~3,2%:%time:~6,2%&lt;br /&gt;
 or&lt;br /&gt;
 set DATESTR=%date:~-2,4%%date:~-7,2%%date:~-10,2%_%time:~0,2%%time:~3,2%%time:~6,2%&lt;br /&gt;
 :: replace &amp;#039; &amp;#039; in small hours with 0&lt;br /&gt;
 set DATESTR=%DATESTR: =0%&lt;br /&gt;
 = 240419_085724 &lt;br /&gt;
 zip.exe -9 %DATESTR%.zip *.bat&lt;br /&gt;
for better example of zipping see [[Backup#Zip_Folder|zip folder in Backup section]]&lt;br /&gt;
&lt;br /&gt;
====DayOfWeek====&lt;br /&gt;
from [https://stackoverflow.com/questions/25537313/issue-with-getting-batch-script-to-print-keeps-given-a-error-about-set-was-unexp here]&lt;br /&gt;
 SETLOCAL enabledelayedexpansion&lt;br /&gt;
 SET /a count=0&lt;br /&gt;
 FOR /F &amp;quot;skip=1&amp;quot; %%D IN (&amp;#039;wmic path win32_localtime get dayofweek&amp;#039;) DO (&lt;br /&gt;
     if &amp;quot;!count!&amp;quot; GTR &amp;quot;0&amp;quot; GOTO next&lt;br /&gt;
     set dow=%%D&lt;br /&gt;
     SET /a count+=1&lt;br /&gt;
 )&lt;br /&gt;
 :next&lt;br /&gt;
 echo %dow%&lt;br /&gt;
&lt;br /&gt;
====Yesterday====&lt;br /&gt;
from [https://stackoverflow.com/questions/2954359/dos-batch-programming-howto-get-and-display-yesterday-date here]&lt;br /&gt;
 set befehl=&amp;quot;PowerShell $date = Get-Date; $date=$date.AddDays(-1); $date.ToString(&amp;#039;yyyy-MM-dd&amp;#039;)&amp;quot;&lt;br /&gt;
 for /f %%i in (&amp;#039;%befehl%&amp;#039;) do set yesterday=%%i&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Copy all files from subfolders to one folder ===&lt;br /&gt;
from [https://stackoverflow.com/questions/11720681/windows-batch-copy-files-from-subfolders-to-one-folder here]&lt;br /&gt;
 set source=c:\source&lt;br /&gt;
 set target=c:\target&lt;br /&gt;
 cd %source%&lt;br /&gt;
 for /r %%a in (*.*) do (&lt;br /&gt;
  COPY &amp;quot;%%a&amp;quot; &amp;quot;%target%&amp;quot;&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
===FTP===&lt;br /&gt;
====FTP-Upload====&lt;br /&gt;
file &amp;quot;ftp.bat&amp;quot;&lt;br /&gt;
 @echo off&lt;br /&gt;
 ftp &amp;quot;-s:FtpScript&amp;quot;&lt;br /&gt;
 pause&lt;br /&gt;
 cls&lt;br /&gt;
&lt;br /&gt;
file &amp;quot;FtpScript&amp;quot;&lt;br /&gt;
 open www.xyz.de&lt;br /&gt;
 [User]&lt;br /&gt;
 [Password]&lt;br /&gt;
 BINARY&lt;br /&gt;
 put [File]&lt;br /&gt;
 quit&lt;br /&gt;
&lt;br /&gt;
===UnixUtils===&lt;br /&gt;
Using [https://sourceforge.net/projects/unxutils/ UnixUtils] for Windows wget, grep, etc are usable to scripts in Windows. In the UnixUtils.zip the .exe files are located in foltder usr/local/wbin/ . Examples:&lt;br /&gt;
 head.exe -c 1000 mylog.log &amp;gt; outHead1000Bytes.log&lt;br /&gt;
 head.exe -n 1000 mylog.log &amp;gt; outHead1000Lines.log&lt;br /&gt;
 tail.exe -c 1000 mylog.log &amp;gt; outTail1000Bytes.log&lt;br /&gt;
 tail.exe -n 1000 mylog.log &amp;gt; outTail1000Lines.log&lt;br /&gt;
 grep.exe -i -B3 -A1 &amp;quot;ERROR&amp;quot; mylog.log &amp;gt; outGrepErrors.log&lt;br /&gt;
&lt;br /&gt;
====Curl to check if page online====&lt;br /&gt;
 @echo off&lt;br /&gt;
 set URL1=https://my.server.com&lt;br /&gt;
 :loop&lt;br /&gt;
 for /f &amp;quot;delims=&amp;quot; %%i in (&amp;#039;curl -o nul -I -s -w &amp;quot;%%{http_code}&amp;quot; &amp;quot;%URL%&amp;quot;&amp;#039;) do set HTTP_STATUS=%%i&lt;br /&gt;
 echo Status: %HTTP_STATUS% at %date% %time%&lt;br /&gt;
 timeout /t 5&lt;br /&gt;
 goto loop&lt;br /&gt;
&lt;br /&gt;
===TOP CPU RAM Disk I/O===&lt;br /&gt;
# CPU + RAM&lt;br /&gt;
 top&lt;br /&gt;
# I/O&lt;br /&gt;
 sudo iotop -o -d 2 -k&lt;br /&gt;
&lt;br /&gt;
===Run as other user===&lt;br /&gt;
 runas /user:MYDOMAIN\myuser /savecred  &amp;quot;cmd /K cd c:\mydir &amp;amp;&amp;amp; my_programm.exe&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 /K to keep window open when finished&lt;br /&gt;
 /C to close window when finished&lt;/div&gt;</summary>
		<author><name>Torben</name></author>
	</entry>
</feed>