<?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>Teh Tech &#187; Batch</title>
	<atom:link href="http://tehtech.com/tag/batch/feed/" rel="self" type="application/rss+xml" />
	<link>http://tehtech.com</link>
	<description>Being an Admin is Hard Enough</description>
	<lastBuildDate>Wed, 14 Jul 2010 16:14:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Add Date and Time to any Batch File Output</title>
		<link>http://tehtech.com/add-date-and-time-to-any-batch-file-output/</link>
		<comments>http://tehtech.com/add-date-and-time-to-any-batch-file-output/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 14:59:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[Log]]></category>
		<category><![CDATA[Time]]></category>

		<guid isPermaLink="false">http://tehtech.com/?p=352</guid>
		<description><![CDATA[This trick is useful for both troubleshooting batch file tasks and when using a batch file to create a log. For example I have a scheduled task that renames some of my backup folders at night and then moved a few files around for me. When the batch file starts I uses the below code [...]]]></description>
			<content:encoded><![CDATA[<p>This trick is useful for both troubleshooting batch file tasks and when using a batch file to create a log. For example I have a scheduled task that renames some of my backup folders at night and then moved a few files around for me. When the batch file starts I uses the below code to print the time it starts, I repeat the two lines at the end of the batch file so that I can see what time the job completed. This is useful for figuring out average time of a task so that you can schedule other things without interfering.</p>
<p><span id="more-352"></span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-2740910196434334";
google_ad_slot = "5492961778";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<div class="box">Date /T &gt;&gt; c:\script.log<br />
Time /T &gt;&gt; c:\script.log</div>
<p>Â </p>
<p>And here is what it looks like in a actual batch file:</p>
<div class="box">Echo running backup script &gt;&gt; G:\log\backup.log<br />
Date /T &gt;&gt; G:\log\backup.log<br />
Time /T &gt;&gt; G:\log\backup.log<br />
Rename f:\backup\full f:\backup\full_old<br />
md f:\backup\full<br />
Move f:\backup\full_old g:\archive<br />
Delete f:\backup\full\log.txt<br />
Echo completed at &gt;&gt; G:\log\backup.log<br />
Date /T &gt;&gt; G:\log\backup.log</div>
<div class="box">Time /T &gt;&gt; G:\log\backup.log</div>
<p>Â </p>
<p>The output would look like:</p>
<div class="box">Running backup script<br />
Thu 04/23/2009<br />
10:53 AM<br />
Completed at<br />
Thu 04/23/2009<br />
11:23 AM</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2740910196434334";
google_ad_slot = "5492961778";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://tehtech.com/add-date-and-time-to-any-batch-file-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Rename a File Over a Network Through a Batch File</title>
		<link>http://tehtech.com/how-to-rename-a-file-over-a-network-through-a-batch-file/</link>
		<comments>http://tehtech.com/how-to-rename-a-file-over-a-network-through-a-batch-file/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 04:12:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[Command Prompt]]></category>

		<guid isPermaLink="false">http://tehtech.com/?p=349</guid>
		<description><![CDATA[Sometime you need to rename a file or a folder that does not reside on your sever. For example I run a scheduled task on one sever to rename the folder on another server so that I can automatically archive backups weekly. Batch files or command line operations do not support UNC paths like \\myserver\my_share [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime you need to rename a file or a folder that does not reside on your sever. For example I run a scheduled task on one sever to rename the folder on another server so that I can automatically archive backups weekly. Batch files or command line operations do not support UNC paths like \\myserver\my_share without taking some steps first.<br />
<span id="more-349"></span></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2740910196434334";
google_ad_slot = "5492961778";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>For this example I have a server called &#8220;server01&#8243; is is running a script that will rename a folder called &#8216;Full&#8217; that resides in a share called backup on a server called &#8216;server02&#8242;. First we map to the share, perform the operation, and then unmap the session. This method does not require a drive letter and thus works well and will never cause a DLA conflict.</p>
<p>Â </p>
<div class="box">net use \\server02\backup<br />
rename \\server02\backup\full \\server02\backup\archive<br />
net use /delete \\server02\backup</div>
<p>Essentially the net use function allows you to then use the path in the script. Remember that if you do not have rights to the folder you are mapping to you may need to specify them in the first line.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2740910196434334";
google_ad_slot = "5492961778";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://tehtech.com/how-to-rename-a-file-over-a-network-through-a-batch-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change your Power Options to &#8216;Always On&#8217;</title>
		<link>http://tehtech.com/change-your-power-options-to-always-on/</link>
		<comments>http://tehtech.com/change-your-power-options-to-always-on/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 07:31:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Kaseya]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Always On]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[Login Script]]></category>
		<category><![CDATA[Power Options]]></category>

		<guid isPermaLink="false">http://tehtech.com/?p=148</guid>
		<description><![CDATA[It is anoying as hell when you push out an update or a patch and a computer is off. Â This hopefully will limit this problem. Although it is impossible to keep a user fromÂ shuttingÂ down this will at least keep the computer from doing it on its own. Â This can be pushed in a batch file, [...]]]></description>
			<content:encoded><![CDATA[<p>It is anoying as hell when you push out an update or a patch and a computer is off. Â This hopefully will limit this problem. Although it is impossible to keep a user fromÂ shuttingÂ down this will at least keep the computer from doing it on its own. Â This can be pushed in a batch file, or deployed as part of a login script for rollouts, and of course through kasyea. Â Note this will only work on windows xp sp2 or higher.<br />
<span id="more-148"></span><br />
Batch or login script:</p>
<div class="box">powercfg /setactive &#8220;always on&#8221;</div>
<p>Kaseya</p>
<div class="box">Script Name: Power Option &#8211; Always onÂ </div>
<p>Script Description: Turns the computers power configuation to the &#8216;always on&#8217; setting</p>
<p>IF TrueÂ </p>
<p>THEN</p>
<p>Â Â  Execute Shell Command</p>
<p>Â Â  Â  Parameter 1 : powercfg /setactive &#8220;always on&#8221;</p>
<p>Â Â  Â  Parameter 2 : 1</p>
<p>Â Â  Â  Â  Â  OS Type : 0</p>
<p>ELSE</p>
<p>Â <br />
<script type="text/javascript"><!--
google_ad_client = "pub-2740910196434334";
google_ad_slot = "5492961778";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://tehtech.com/change-your-power-options-to-always-on/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Automatically Remove Windows Search 4.0</title>
		<link>http://tehtech.com/automatically-remove-windows-search-40/</link>
		<comments>http://tehtech.com/automatically-remove-windows-search-40/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 02:24:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Kaseya]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[KB940157]]></category>
		<category><![CDATA[Windows Search]]></category>
		<category><![CDATA[Windows update]]></category>

		<guid isPermaLink="false">http://tehtech.com/?p=99</guid>
		<description><![CDATA[Microsoft has a funny way of sneaking &#8216;features&#8217; in with patches. In this case Windows Search 4.0 is not really a feature as much as a problem. It was installed on a few of the networksÂ I support as part of our weekly patching, and the next day I got a bunch of calls about reduced [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft has a funny way of sneaking &#8216;features&#8217; in with patches. In this case Windows Search 4.0 is not really a feature as much as a problem. It was installed on a few of the networksÂ I support as part of our weekly patching, and the next day I got a bunch of calls about reduced performance. I figured that people would complain until it finished indexing. Not the case, it seemed to cripple computers and crush servers. It indexed to the point of actually leaving no resources for users to authenticate to one of our terminal servers. I started looking for a fix and came up with this:<br />
<span id="more-99"></span><br />
<span style="color: #000000;">Kaseya:</span></p>
<div class="box">
<p>Script Name: Remove Windows Search 4.0<br />
Script Description:</p>
<p>IF Test File<br />
Parameter 1 : C:WINDOWS$NtUninstallKB940157$spuninstspuninst.exe<br />
Exists :<br />
THEN<br />
Execute File<br />
Parameter 1 : C:WINDOWS$NtUninstallKB940157$spuninstspuninst.exe<br />
Parameter 2 : /quiet /norestart<br />
Parameter 3 : 3<br />
OS Type : 0<br />
ELSE</p></div>
<p><span style="color: #000000;">Windows logon script or batch file:</span></p>
<div class="box">C:WINDOWS$NtUninstallKB940157$spuninstspuninst.exe /quiet /norestart</div>
<p>If you are using kasaya you can import that script directly and run it to remove the &#8216;feature&#8217;. You can also add the above line to a login script or batch file. This will automatically, silently remove the update with no user intervention or popup. Â itÂ literallyÂ just disappears.</p>
<p><span style="color: #ff0000;">WARNING: running this on a terminal server with users logged in will cause new users to not be able to authenticate until you restart the server. Â Always follow best practice for software uninstalls. Â Careful when you run it on servers <img src='http://tehtech.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></p>
<p>Just a nice simple way to remove windows search 4.0 infection from your network.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2740910196434334";
google_ad_slot = "5492961778";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://tehtech.com/automatically-remove-windows-search-40/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Inserting a Wait in a Batch File, Using Netstat in a Login Script</title>
		<link>http://tehtech.com/inserting-a-wait-in-a-batch-file-using-netstat-in-a-login-script/</link>
		<comments>http://tehtech.com/inserting-a-wait-in-a-batch-file-using-netstat-in-a-login-script/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 16:50:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[Login Script]]></category>
		<category><![CDATA[Netstat]]></category>
		<category><![CDATA[Pause]]></category>

		<guid isPermaLink="false">http://tehtech.com/?p=91</guid>
		<description><![CDATA[So you want to pause a batch file for a few seconds.Â  Unfortunately windows doesn&#8217;t provide a very simple way of doing this.Â Â  I wanted to run &#8216;netstat -b&#8217; 25 seconds after a user logged into their computer as to give the computer enough time to start up all background applications.Â  But, there is no [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to pause a batch file for a few seconds.Â  Unfortunately windows doesn&#8217;t provide a very simple way of doing this.Â Â  I wanted to run &#8216;netstat -b&#8217; 25 seconds after a user logged into their computer as to give the computer enough time to start up all background applications.Â  But, there is no wait function in batch files.Â  Well I found a workaround.Â  If you use the &#8216;-n&#8217; argument with the ping command you can specify the amount of time to run a ping for.Â  Thus ping -n 60 127.0.0.1 will ping your local host for 60 seconds.Â  This will more or less keep the batch file at a standstill for a specified number of seconds before continuing.Â  In my case I used it for a pause in a login script.<br />
<span id="more-91"></span></p>
<div class="box">echo off<br />
title login script<br />
color 1f<br />
set name=%computername%<br />
ping -n 25 127.0.0.1<br />
echo %computername% &gt;&gt; g:\%name%.log<br />
date /T &gt;&gt; g:\%name%.log<br />
time /T &gt;&gt; g:\%name%.log<br />
netstat -b &gt;&gt; g:\%name%.log<br />
echo *********************************************** &gt;&gt; g:\%name%.log<br />
echo *********************************************** &gt;&gt; g:\%name%.log<br />
echo *********************************************** &gt;&gt; g:\%name%.log<br />
echo *********************************************** &gt;&gt; g:\%name%.log<br />
echo *********************************************** &gt;&gt; g:\%name%.log</div>
<p>Â <br />
In this script the &#8216;G&#8217; Drive is a mapped drive for administration.Â  When a user logs in they will open the log stamp it with their computer name, the date and the time.Â  Then the netstat output, followed by a few lines of asterisks to separate the uses visually.Â  I have an OU with this script applied to it.Â  If I suspect a user is doing something sketchy I add them to this OU, to do a little snooping.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2740910196434334";
google_ad_slot = "5492961778";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://tehtech.com/inserting-a-wait-in-a-batch-file-using-netstat-in-a-login-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

