<?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>yakk0.org &#187; batch</title>
	<atom:link href="http://www.yakk0.org/tag/batch/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yakk0.org</link>
	<description>a blog on technology in the real world</description>
	<lastBuildDate>Sun, 05 Sep 2010 08:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Path variables in batch files</title>
		<link>http://www.yakk0.org/2010/04/22/path-variables-in-batch-files/</link>
		<comments>http://www.yakk0.org/2010/04/22/path-variables-in-batch-files/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 15:42:33 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[sccm 2007]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.yakk0.org/2010/04/22/path-variables-in-batch-files/</guid>
		<description><![CDATA[This is another post documenting something I used to fix a problem at work so I don’t forget about it. We were pushing out Firefox to all our systems yesterday via SCCM. It’s pushed out using a batch file to configure various things, and I noticed that although the batch file was being called from [...]]]></description>
			<content:encoded><![CDATA[<p>This is another post documenting something I used to fix a problem at work so I don’t forget about it. We were pushing out Firefox to all our systems yesterday via SCCM. It’s pushed out using a batch file to configure various things, and I noticed that although the batch file was being called from the dozen or so distribution points we have, the script was calling back to the main server. I’ve seen this before but never looked into a solution. I started searching for a variable or a way to get the path the script is run from and found <a href="http://www.myitforum.com/articles/8/view.asp?id=12036">this article</a> posted in 2008 on <a href="http://myITforum.com">myITforum.com</a>. It is addressing the exact situation I was encountering. </p>
<p> <span id="more-299"></span>
<p>In short I needed to use the variable <em>%~dp0</em> before the items on the distribution point share. For example I changed <em>“\\SCCM\packages\MozillaFirefox\Firefox Setup 3.6.3.exe”</em> in the script to <em>“%~dp0\Firefox Setup 3.6.3.exe.” </em>I tested it with a test script that echoed out the commands instead of running them, and the paths were correct. </p>
<p>The myITforum article goes into further detail about the other uses of this variable. It’s actually a modification of the %0, %1, %2 convention of dos batch files for referencing command-line arguments. %0 references the script itself, including the full drive and path, %1 is the first argument, and %2 is the second, and so on. The <em>“~d”</em> modifier before the number 0 resolves the variable to the drive letter only and <em>“~p”</em> would resolve it to the path only. Combining the two into&#160; <em>“~dp”</em> resolves it into drive and the path, or in this case the full UNC path. More information can be found by typing <em>“FOR /?”</em> from a command prompt.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yakk0.org/2010/04/22/path-variables-in-batch-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One line administration – search and delete computer accounts</title>
		<link>http://www.yakk0.org/2009/05/06/one-line-administration-search-and-delete-computer-accounts/</link>
		<comments>http://www.yakk0.org/2009/05/06/one-line-administration-search-and-delete-computer-accounts/#comments</comments>
		<pubDate>Wed, 06 May 2009 19:02:29 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.yakk0.org/2009/05/06/one-line-administration-search-and-delete-computer-accounts/</guid>
		<description><![CDATA[Here’s a quick one-line script I’ve been using to clean up some old computer accounts in active directory. It requires the dsquery and dsrm tools from the Server 2003 Admin Pack or the Remote Server Administration Toolkit. @for /f %%a in ('DSQUERY COMPUTER -NAME *%1') do (dsrm %%a) Save that in as a batch file [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">Here’s a quick one-line script I’ve been using to clean up some old computer accounts in active directory. It requires the dsquery and dsrm tools from the Server 2003 Admin Pack or the Remote Server Administration Toolkit.</p>
<pre>
<span style="color: #008000;"><strong><em>@for /f %%a in ('DSQUERY COMPUTER -NAME *%1') do (dsrm %%a)</em></strong></span></pre>
<p align="justify">Save that in as a batch file and it’ll query Active Directory for computers including the argument passed.  Here’s an example with a naming structure where we have the last 4 digits of the MAC address in the name for uniqueness.</p>
<pre><span style="color: #008000;"><strong><em>C:\&gt;adrm.cmd 6736
C:\&gt;(dsrm "CN=LABPC6736,OU=Labs,DC=yakk0,DC=org" )
Are you sure you wish to delete CN=LABPC6736,OU=Labs,DC=yakk0,DC=org (Y/N)? y
dsrm succeeded:CN=LABPC6736,OU=Labs,DC=yakk0,DC=org</em></strong></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yakk0.org/2009/05/06/one-line-administration-search-and-delete-computer-accounts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
