<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shawson&#039;s Code Blog &#187; Batch Scripting</title>
	<atom:link href="http://codeblog.shawson.co.uk/category/windows/batch-scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeblog.shawson.co.uk</link>
	<description>development notes for my failing memory</description>
	<lastBuildDate>Tue, 15 May 2012 15:22:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Open Windows Firewall ports for SQL Server 2008</title>
		<link>http://codeblog.shawson.co.uk/open-windows-firewall-ports-for-sql-server-2008/</link>
		<comments>http://codeblog.shawson.co.uk/open-windows-firewall-ports-for-sql-server-2008/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 15:23:12 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[Batch Scripting]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://codeblog.shawson.co.uk/?p=1274</guid>
		<description><![CDATA[http://support.microsoft.com/kb/968872 As noted in the article, you can run this batch file; @echo ========= SQL Server Ports =================== @echo Enabling SQLServer default instance port 1433 netsh firewall set portopening TCP 1433 "SQLServer" @echo Enabling Dedicated Admin Connection port 1434 netsh firewall set portopening TCP 1434 "SQL Admin Connection" @echo Enabling conventional SQL Server Service Broker [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/' rel='bookmark' title='Command line to delete every file older than 30 days'>Command line to delete every file older than 30 days</a></li>
<li><a href='http://codeblog.shawson.co.uk/how-to-run-sql-profiler-against-local-sql-express-instances/' rel='bookmark' title='How to run SQL Profiler against local SQL Express instances'>How to run SQL Profiler against local SQL Express instances</a></li>
<li><a href='http://codeblog.shawson.co.uk/aspnet-role-membership-providers-under-iis7-doesnt-work/' rel='bookmark' title='ASP.Net Role &amp; Membership Providers (Under IIS7) &#8211; DOESN&#8217;T Work!'>ASP.Net Role &#038; Membership Providers (Under IIS7) &#8211; DOESN&#8217;T Work!</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p><a href="http://support.microsoft.com/kb/968872">http://support.microsoft.com/kb/968872</a></p>
<p>As noted in the article, you can run this batch file;</p>
<pre>
@echo =========  SQL Server Ports  ===================
@echo Enabling SQLServer default instance port 1433
netsh firewall set portopening TCP 1433 "SQLServer"
@echo Enabling Dedicated Admin Connection port 1434
netsh firewall set portopening TCP 1434 "SQL Admin Connection"
@echo Enabling conventional SQL Server Service Broker port 4022
netsh firewall set portopening TCP 4022 "SQL Service Broker"
@echo Enabling Transact-SQL Debugger/RPC port 135
netsh firewall set portopening TCP 135 "SQL Debugger/RPC"
@echo =========  Analysis Services Ports  ==============
@echo Enabling SSAS Default Instance port 2383
netsh firewall set portopening TCP 2383 "Analysis Services"
@echo Enabling SQL Server Browser Service port 2382
netsh firewall set portopening TCP 2382 "SQL Browser"
@echo =========  Misc Applications  ==============
@echo Enabling HTTP port 80
netsh firewall set portopening TCP 80 "HTTP"
@echo Enabling SSL port 443
netsh firewall set portopening TCP 443 "SSL"
@echo Enabling port for SQL Server Browser Service's 'Browse' Button
netsh firewall set portopening UDP 1434 "SQL Browser"
@echo Allowing multicast broadcast response on UDP (Browser Service Enumerations OK)
netsh firewall set multicastbroadcastresponse ENABLE
</pre>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/' rel='bookmark' title='Command line to delete every file older than 30 days'>Command line to delete every file older than 30 days</a></li>
<li><a href='http://codeblog.shawson.co.uk/how-to-run-sql-profiler-against-local-sql-express-instances/' rel='bookmark' title='How to run SQL Profiler against local SQL Express instances'>How to run SQL Profiler against local SQL Express instances</a></li>
<li><a href='http://codeblog.shawson.co.uk/aspnet-role-membership-providers-under-iis7-doesnt-work/' rel='bookmark' title='ASP.Net Role &amp; Membership Providers (Under IIS7) &#8211; DOESN&#8217;T Work!'>ASP.Net Role &#038; Membership Providers (Under IIS7) &#8211; DOESN&#8217;T Work!</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/open-windows-firewall-ports-for-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command Line- create a folder named with todays date</title>
		<link>http://codeblog.shawson.co.uk/command-line-create-a-folder-named-with-todays-date/</link>
		<comments>http://codeblog.shawson.co.uk/command-line-create-a-folder-named-with-todays-date/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 15:08:15 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[Batch Scripting]]></category>

		<guid isPermaLink="false">http://codeblog.shawson.co.uk/?p=1170</guid>
		<description><![CDATA[mkdir %date:~-4,4%%date:~-7,2%%date:~0,2% will produce a folder named like this; YYYYMMDD Thanks to Mr Carmichael for this.. Related posts:Command line Batch File to Remove Direcories, using a Wild Card! Command line to delete every file older than 30 days


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/' rel='bookmark' title='Command line Batch File to Remove Direcories, using a Wild Card!'>Command line Batch File to Remove Direcories, using a Wild Card!</a></li>
<li><a href='http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/' rel='bookmark' title='Command line to delete every file older than 30 days'>Command line to delete every file older than 30 days</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>mkdir %date:~-4,4%%date:~-7,2%%date:~0,2%<br />
will produce a folder named like this; YYYYMMDD</p>
<p>Thanks to Mr Carmichael for this..</p>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/' rel='bookmark' title='Command line Batch File to Remove Direcories, using a Wild Card!'>Command line Batch File to Remove Direcories, using a Wild Card!</a></li>
<li><a href='http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/' rel='bookmark' title='Command line to delete every file older than 30 days'>Command line to delete every file older than 30 days</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/command-line-create-a-folder-named-with-todays-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line to delete every file older than 30 days</title>
		<link>http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/</link>
		<comments>http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 10:56:41 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[Batch Scripting]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=483</guid>
		<description><![CDATA[I found a new command line directive i&#8217;d never heard of today, along with a brilliant example of it&#8217;s use- once you have changed your working directory, running this will remove any files or folders older than 30 days; FORFILES /D -30 /C &#34;CMD /C IF @isdir==FALSE (echo Deleting File @file) &#38; (ATTRIB -H @file) [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/' rel='bookmark' title='Command line Batch File to Remove Direcories, using a Wild Card!'>Command line Batch File to Remove Direcories, using a Wild Card!</a></li>
<li><a href='http://codeblog.shawson.co.uk/open-windows-firewall-ports-for-sql-server-2008/' rel='bookmark' title='Open Windows Firewall ports for SQL Server 2008'>Open Windows Firewall ports for SQL Server 2008</a></li>
<li><a href='http://codeblog.shawson.co.uk/umbraco-installation-folder-permissions-setup/' rel='bookmark' title='Umbraco Installation &#8211; folder permissions setup'>Umbraco Installation &#8211; folder permissions setup</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>I found a new command line directive i&#8217;d never heard of today, along with a brilliant example of it&#8217;s use- once you have changed your working directory, running this will remove any files or folders older than 30 days;</p>
<pre class="brush: php">
FORFILES /D -30 /C &quot;CMD /C IF @isdir==FALSE (echo Deleting File @file) &amp; (ATTRIB -H @file) &amp; (DEL /F /Q @file) ELSE (echo Deleting Directory @file) &amp; (ATTRIB -H @FILE) &amp; (RD /S /Q @FILE)&quot;
</pre>
<p>As an example, I&#8217;ve since used this to iterate over a bunch of folders, deleting any files over 30 days;</p>
<pre class="brush: php">
d:
for /f &quot;delims=|&quot; %%f in (&#039;dir /b D:\_SQL_Backup\&#039;) DO (
  cd \_SQL_Backup
  cd %%f
  FORFILES /D -14 /C &quot;CMD /C IF @isdir==FALSE (echo Deleting File @file) &amp; (ATTRIB -H @file) &amp; (DEL /F /Q @file)&quot;
)
</pre>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/' rel='bookmark' title='Command line Batch File to Remove Direcories, using a Wild Card!'>Command line Batch File to Remove Direcories, using a Wild Card!</a></li>
<li><a href='http://codeblog.shawson.co.uk/open-windows-firewall-ports-for-sql-server-2008/' rel='bookmark' title='Open Windows Firewall ports for SQL Server 2008'>Open Windows Firewall ports for SQL Server 2008</a></li>
<li><a href='http://codeblog.shawson.co.uk/umbraco-installation-folder-permissions-setup/' rel='bookmark' title='Umbraco Installation &#8211; folder permissions setup'>Umbraco Installation &#8211; folder permissions setup</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Umbraco Installation &#8211; folder permissions setup</title>
		<link>http://codeblog.shawson.co.uk/umbraco-installation-folder-permissions-setup/</link>
		<comments>http://codeblog.shawson.co.uk/umbraco-installation-folder-permissions-setup/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 10:18:46 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[Batch Scripting]]></category>
		<category><![CDATA[Umbraco]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=399</guid>
		<description><![CDATA[Just a real quick batch script i knocked up which sets the appropriate permissions to the various folders in the root of a fresh umbraco install- just drop this into a batch file, and run it from the root of your umbraco install; REM 2009.10.22 SY - Set permissions- user/ folders from "Install Umbraco 4 [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/paged-list-of-child-nodes-un-umbraco/' rel='bookmark' title='Paged List of Child Nodes in Umbraco'>Paged List of Child Nodes in Umbraco</a></li>
<li><a href='http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/' rel='bookmark' title='Command line Batch File to Remove Direcories, using a Wild Card!'>Command line Batch File to Remove Direcories, using a Wild Card!</a></li>
<li><a href='http://codeblog.shawson.co.uk/giving-umbraco-trees-children/' rel='bookmark' title='Giving Umbraco custom tree&#8217;s children!'>Giving Umbraco custom tree&#8217;s children!</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Just a real quick batch script i knocked up which sets the appropriate permissions to the various folders in the root of a fresh umbraco install- just drop this into a batch file, and run it from the root of your umbraco install;</p>
<pre>
REM 2009.10.22 SY - Set permissions- user/ folders from "Install Umbraco 4 on Windows Vista" guide
icacls app_code /grant "Network Service":(OI)(CI)(F)
icacls bin /grant "Network Service":(OI)(CI)(F)
icacls config /grant "Network Service":(OI)(CI)(F)
icacls css /grant "Network Service":(OI)(CI)(F)
icacls data /grant "Network Service":(OI)(CI)(F)
icacls masterpages /grant "Network Service":(OI)(CI)(F)
icacls media /grant "Network Service":(OI)(CI)(F)
icacls python /grant "Network Service":(OI)(CI)(F)
icacls scripts /grant "Network Service":(OI)(CI)(F)
icacls umbraco /grant "Network Service":(OI)(CI)(F)
icacls usercontrols /grant "Network Service":(OI)(CI)(F)
icacls xslt /grant "Network Service":(OI)(CI)(F)
pause
</pre>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/paged-list-of-child-nodes-un-umbraco/' rel='bookmark' title='Paged List of Child Nodes in Umbraco'>Paged List of Child Nodes in Umbraco</a></li>
<li><a href='http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/' rel='bookmark' title='Command line Batch File to Remove Direcories, using a Wild Card!'>Command line Batch File to Remove Direcories, using a Wild Card!</a></li>
<li><a href='http://codeblog.shawson.co.uk/giving-umbraco-trees-children/' rel='bookmark' title='Giving Umbraco custom tree&#8217;s children!'>Giving Umbraco custom tree&#8217;s children!</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/umbraco-installation-folder-permissions-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line Batch File to Remove Direcories, using a Wild Card!</title>
		<link>http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/</link>
		<comments>http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 14:27:20 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[Batch Scripting]]></category>
		<category><![CDATA[Command Line]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=393</guid>
		<description><![CDATA[We have a bunch of web services which log details of requests that come in, in folders named using the current date- in the format YYYY-MM-DDD-HH-MM-SS. I wanted to produce a simple cleanup batch file which we could run every month to bin all logs for transactions which happened 3 months ago- using the dos [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/' rel='bookmark' title='Command line to delete every file older than 30 days'>Command line to delete every file older than 30 days</a></li>
<li><a href='http://codeblog.shawson.co.uk/umbraco-installation-folder-permissions-setup/' rel='bookmark' title='Umbraco Installation &#8211; folder permissions setup'>Umbraco Installation &#8211; folder permissions setup</a></li>
<li><a href='http://codeblog.shawson.co.uk/command-line-create-a-folder-named-with-todays-date/' rel='bookmark' title='Command Line- create a folder named with todays date'>Command Line- create a folder named with todays date</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>We have a bunch of web services which log details of requests that come in, in folders named using the current date- in the format YYYY-MM-DDD-HH-MM-SS.  I wanted to produce a simple cleanup batch file which we could run every month to bin all logs for transactions which happened 3 months ago- using the dos commands which exist on Windows Server 2003.</p>
<p>The dos &#8220;del&#8221; command allows you to delete using wild cards &#8211; so for example &#8220;dev 2009-07-*&#8221; would erase any files starting with &#8220;2009-07-&#8221;; However this doesn&#8217;t work with folders- so it fell to the rd (remove directory) command- but this doesn&#8217;t support wild cards (I&#8217;m assuming for safety- to stop you permanently erasing 100&#8242;s of folders and their contents accidently- remember there&#8217;s no recycle bin when you delete from the command line!).</p>
<p>To get around this I created a simple Batch file which accepted a wildcard as a parameter, then removes all those folders at the current level (it wont check recursivly).  Just in case this is of use to anyone else, here&#8217;s the code;</p>
<pre>
REM - performs a remove directory, with wildcard matching - example ; rd-wildcard 2007-*
dir %1 /b >loglist.txt
setlocal enabledelayedexpansion
for /f %%a in (./loglist.txt) do (
	rd /s /q %%a
)
del /q loglist.txt
endlocal
</pre>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/command-line-to-delete-every-file-older-than-30-days/' rel='bookmark' title='Command line to delete every file older than 30 days'>Command line to delete every file older than 30 days</a></li>
<li><a href='http://codeblog.shawson.co.uk/umbraco-installation-folder-permissions-setup/' rel='bookmark' title='Umbraco Installation &#8211; folder permissions setup'>Umbraco Installation &#8211; folder permissions setup</a></li>
<li><a href='http://codeblog.shawson.co.uk/command-line-create-a-folder-named-with-todays-date/' rel='bookmark' title='Command Line- create a folder named with todays date'>Command Line- create a folder named with todays date</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/command-line-batch-file-to-remove-direcories-using-a-wild-card/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

