<?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>Logical Tech &#187; Batch Files</title>
	<atom:link href="http://blog.integrii.net/?feed=rss2&#038;cat=10" rel="self" type="application/rss+xml" />
	<link>http://blog.integrii.net</link>
	<description>Work smarter, not harder.</description>
	<lastBuildDate>Fri, 11 Jun 2010 15:11:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adaptation to EricBackup.bat</title>
		<link>http://blog.integrii.net/?p=239</link>
		<comments>http://blog.integrii.net/?p=239#comments</comments>
		<pubDate>Tue, 23 Jun 2009 18:10:49 +0000</pubDate>
		<dc:creator>Martijn Jonker</dc:creator>
				<category><![CDATA[Batch Files]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[cmd]]></category>
		<category><![CDATA[ntbackup]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=239</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I took the liberty to adapt EricBackup.bat created by Eric.<br />
Eric graciously permitted me to post to his blog aswell.</p>
<p>I have almost completely rewritten the batchfile for it to meet my fancy ;)<br />
Replaced blat with sendmail and using delage32 to cleanup previous backupfiles and logfiles.<br />
Date and time variables are in European format, change this if you want/need to.<br />
The first part declares a bunch of variables, read this carefully.</p>
<p>Hands down to Eric, he laid the foundation for me to create this.</p>
<p>Below the source I have created. Comments are welcome.</p>
<p><strong>MyBackup.bat</strong></p>
<blockquote><p>@ECHO OFF<br />
:: ====<br />
:: PROGRAM           : MYBACKUP.BAT<br />
:: BY                : M.T.D. JONKER<br />
:: ADAPTED FROM      : EricBackup.bat Version 2.8, <a href="mailto:EricGreer@GMail.com">EricGreer@GMail.com</a>, <a href="http://blog.integrii.net/?p=76">http://blog.integrii.net/?p=76</a><br />
:: CREATION DATE     : 20-12-2008<br />
:: LATEST REVISION   : 22-02-2009<br />
::====<br />
::22-02-2009: REDID REMOVAL OF OLD BACKUPFILES AND LOGFILES THROUGH EXTERNAL TOOL DELAGE32<br />
::20-01-2009: ADDED REMOVAL OF PREVIOUS LOGFILES<br />
::20-01-2009: CREATED VARIABLE &#8220;BACKUPFILE&#8221; TO REMOVE CLUTTER<br />
::20-01-2009: REWROTE REMOVAL OF PREVIOUS BACKUPFILES<br />
::10-01-2009: ADDED REMOVAL OF PREVIOUS BACKUPFILES<br />
::22-12-2008: REPLACED BLAT WITH SENDMAIL<br />
::20-12-2008: REWROTE BATCHFILE<br />
::====<br />
TITLE ADVANCED NTBACKUP SCRIPT<br />
COLOR 1F<br />
::====SET VARIABLES.HERE====<br />
::ADJUST VARIABLES TO MEET YOUR PREFERENCE</p>
<p>::BACKUP RELATED VARIABLES<br />
::SET USERNAME (AS SHOWN IN C:\DOCUMENTS AND SETTINGS\&lt;USERNAME&gt;),<br />
SET USER=&lt;username&gt;<br />
::PATH TO PUT LOGFILES OF THIS BATCHFILE AND NTBACKUP<br />
SET ARCHIVEPATH=C:\Backups\logs<br />
:: ORIGINAL (DEFAULT) LOCATION OF NTBACKUP LOGFILE<br />
SET LOGPATH=&#8221;%USERPROFILE%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data&#8221;<br />
::SET THE DESTINATION FOLDER OF YOUR BACKUP<br />
SET DESTINATION=C:\BACKUPS\%COMPUTERNAME%<br />
::SET PATH TO SENDMAIL.EXE<br />
SET MAILPATH=C:\Backups\sendmail.exe<br />
::SET PATH TO delage32.exe<br />
SET DAPATH=C:\Backups\delage32.exe<br />
::SET NAME OR IP OF SMTPSERVER TO BE USED<br />
SET SMTPSERVER=smtp.server.com<br />
::SET THE TO ADDRESS<br />
SET <a href="mailto:TO=name@domain.com">TO=name@domain.com</a><br />
::SET THE FROM ADDRESS<br />
SET <a href="mailto:FROM=name@domain.com">FROM=name@domain.com</a><br />
::SET THE SOURCE OF YOUR BACKUP (FOR EXAMPLE: D:) NOT USED IN SYSTEMSTATE BACKUP<br />
::SET SOURCE=D:<br />
::SET A NOTE TO DESCRIBE YOUR BACKUP (USED IN FILENAME, SO REFRAIN FROM USING NON COMPATIBLE CHARACTERS)<br />
::SET NOTE=D-DRIVE<br />
::====COMMAND LINE PASSING====<br />
::THE VARIABLES NOTE AND SOURCE CAN BE PASSED FROM THE COMMAND LINE.<br />
::EIHTER SET THEM ABOVE OR USE THE SETTING BELOW<br />
::COMMENT/UNCOMMENT AS NEEDED<br />
::WHEN PASSED FROM THE COMMAND LINE BOTH SOURCE AND NOTE MUST BE PROPERLY FILLED<br />
::SO USE SHORT FILENAMES SUCH AS C:\DOCUME~1\, WITHOUT QUOTES<br />
SET SOURCE=%2<br />
::USED IN FILENAME, SO REFRAIN FROM USING NON COMPATIBLE CHARACTERS<br />
SET NOTE=%3<br />
::====DONE SETTING MANUAL VARIABLES====</p>
<p>::DETERMINE BACKUPMODE<br />
SET BACKUPMODE=NONE<br />
IF &#8220;%1&#8243; == &#8220;systemstate&#8221; SET BACKUPMODE=SYSTEMSTATE<br />
IF &#8220;%1&#8243; == &#8220;normal&#8221; SET BACKUPMODE=NORMAL<br />
IF &#8220;%1&#8243; == &#8220;differential&#8221; SET BACKUPMODE=DIFFERENTIAL<br />
IF %BACKUPMODE% == NONE GOTO NOPARAMS</p>
<p>::SET TIME AND DATE VARIABLES, (EUROPEAN FORMAT)  DO NOT TOUCH (UNLESS OTHER FORMAT)<br />
FOR /F &#8220;TOKENS=1,2 DELIMS=:&#8221; %%A IN (&#8217;TIME /T&#8217;) DO (<br />
SET HR=%%A<br />
SET MIN=%%B<br />
SET TM=%%A%%B<br />
SET TME=%%A:%%B<br />
)<br />
FOR /F &#8220;TOKENS=2,3,4 DELIMS=- &#8221; %%A IN (&#8217;DATE /T&#8217;) DO (<br />
SET D=%%A<br />
SET M=%%B<br />
SET Y=%%C<br />
SET DT=%%A-%%B-%%C<br />
SET DTE=%%C%%B%%A<br />
)<br />
::====!!!OTHER VARIABLES, DO NOT CHANGE!!!====<br />
:: NAME OF SYSTEM TO BE BACKED UP<br />
SET SYS=%COMPUTERNAME%<br />
::NAME OF BACKUPFILE (THIS IS LATER USED IN REMOVING PREVIOUS BACKUPFILES)<br />
SET BACKUPFILE=%SYS%_%BACKUPMODE%_%NOTE%_%DT%.bkf<br />
::LOGFILE OF THIS BATCHFILE<br />
SET BATCHLOG=%ARCHIVEPATH%\%BACKUPMODE%_%NOTE%_%DT%_%TM%.txt<br />
::NAME OF NTBACKUP LOGFILE TO BE ARCHIVED<br />
SET NTBARCLOG=%BACKUPMODE%_%NOTE%_%DT%_%TM%.log<br />
::====DONE SETTING VARIABLES====<br />
::====</p>
<p>::CREATE ARCHIVE AND DESTINATION PATHS IF THEY DO NOT EXIST<br />
IF NOT EXIST &#8220;%ARCHIVEPATH%&#8221; MD &#8220;%ARCHIVEPATH%&#8221; &amp; ECHO &#8220;ARCHIVE PATH DID NOT EXIST, SO IT WAS CREATED.&#8221; &amp; ECHO.&gt;&gt; %BATCHLOG%<br />
IF NOT EXIST &#8220;%DESTINATION%&#8221; MD &#8220;%DESTINATION%&#8221; &amp; ECHO &#8220;DESTINATION PATH DID NOT EXIST, SO IT WAS CREATED.&#8221; &amp; ECHO.&gt;&gt; %BATCHLOG%</p>
<p>::BACKUP SELECTION, LOG TO CMD WINDOW<br />
ECHO.<br />
ECHO *********************************************************<br />
ECHO * JOB %NOTE% STARTED<br />
ECHO *********************************************************<br />
ECHO *<br />
IF %BACKUPMODE% NEQ SYSTEMSTATE ECHO * JOB SOURCE: %SOURCE%</p>
<p>IF %BACKUPMODE% == SYSTEMSTATE ECHO * %SYS% %BACKUPMODE% BACKUP STARTED AT %TME% ON %DT% &amp; ECHO * TO %DESTINATION%\%BACKUPFILE% &amp; ECHO %SYS% %BACKUPMODE% BACKUP STARTED AT %TME% ON %DT% TO %DESTINATION%\%BACKUPFILE% &gt;&gt; %BATCHLOG%<br />
IF %BACKUPMODE% == DIFFERENTIAL ECHO * %SYS% %BACKUPMODE% BACKUP OF %SOURCE% STARTED AT %TME% ON %DT% &amp; ECHO * TO %DESTINATION%\%BACKUPFILE% &amp; ECHO %SYS% %BACKUPMODE% BACKUP OF %SOURCE% STARTED AT %TME% ON %DT% TO %DESTINATION%\%BACKUPFILE% &gt;&gt; %BATCHLOG%<br />
IF %BACKUPMODE% == NORMAL ECHO * %SYS% %BACKUPMODE% BACKUP OF %SOURCE% STARTED AT %TME% ON %DT% &amp; ECHO * TO %DESTINATION%\%BACKUPFILE% &amp; ECHO %SYS% %BACKUPMODE% BACKUP OF %SOURCE% STARTED AT %TME% ON %DT% TO %DESTINATION%\%BACKUPFILE% &gt;&gt; %BATCHLOG%</p>
<p>::START BACKUP DEPENDING ON BACKUPMODE<br />
IF %BACKUPMODE% == SYSTEMSTATE ntbackup.exe backup systemstate /n &#8220;%sys%-Backup&#8221; /d &#8220;%sys%-Backup&#8221; /v:no /r:no /rs:no /hc:off /j &#8220;%sys%-Backup&#8221; /l:s /f &#8220;%destination%\%BACKUPFILE%&#8221; &gt;&gt; %BATCHLOG%<br />
IF %BACKUPMODE% == DIFFERENTIAL ntbackup.exe backup &#8220;%source%&#8221; /n &#8220;%sys%-Backup&#8221; /d &#8220;%sys%-Backup&#8221; /v:no /r:no /rs:no /hc:off /m differential /j &#8220;%sys%-Backup&#8221; /l:s /f &#8220;%destination%\%BACKUPFILE%&#8221; &gt;&gt; %BATCHLOG%<br />
IF %BACKUPMODE% == NORMAL ntbackup.exe backup &#8220;%source%&#8221; /n &#8220;%sys%-Backup&#8221; /d &#8220;%sys%-Backup&#8221; /v:no /r:no /rs:no /hc:off /m normal /j &#8220;%sys%-Backup&#8221; /l:s /f &#8220;%destination%\%BACKUPFILE%&#8221; &gt;&gt; %BATCHLOG%</p>
<p>::ARCHIVE LOGFILES<br />
::CLEAR TIME VARIABLES AND SET ANEW<br />
SET HR=<br />
SET MIN=<br />
SET TM=<br />
SET TME=<br />
FOR /F &#8220;TOKENS=1,2 DELIMS=:&#8221; %%A IN (&#8217;TIME /T&#8217;) DO (<br />
SET HR=%%A<br />
SET MIN=%%B<br />
SET TM=%%A%%B<br />
SET TME=%%A:%%B<br />
)<br />
::GET NTBACKUP LOGFILE NAME<br />
FOR /F &#8220;TOKENS=1,2,4 DELIMS= &#8221; %%A IN (&#8217;dir %LOGPATH% *.log ^| find &#8220;%dt%&#8221; ^| find &#8220;%tme%&#8221;&#8216;) DO SET NTBLOG=%%C &gt;NUL<br />
ECHO NTBACKUP LOGFILE FOT THIS JOB: %LOGPATH%\%NTBLOG% &gt;&gt; %BATCHLOG%<br />
::COPY AND RENAME THE NTBACKUP LOGFILE<br />
IF EXIST %LOGPATH%\%NTBLOG% copy %LOGPATH%\%NTBLOG% %ARCHIVEPATH% /Y &gt;NUL<br />
IF EXIST %ARCHIVEPATH%\%NTBLOG% ren %ARCHIVEPATH%\%NTBLOG% &#8220;%NTBARCLOG%&#8221;<br />
::CHECK LOGFILE FOR BACKUP SUCCESS<br />
SET ERRORLEVEL=<br />
find /I &#8220;BACKUP COMPLETED&#8221; &#8220;%ARCHIVEPATH%\%NTBARCLOG%&#8221; &gt;NUL<br />
GOTO %ERRORLEVEL%<br />
:0<br />
SET SUCCESS=1<br />
ECHO * BACKUP COMPLETED SUCCESSFULLY &amp; ECHO BACKUP COMPLETED SUCCESSFULLY &gt;&gt; %BATCHLOG%<br />
GOTO SUCCESSBACKUP<br />
:1<br />
SET SUCCESS=0<br />
ECHO * BACKUP FAILED &amp; ECHO BACKUP FAILED &gt;&gt; %BATCHLOG%<br />
GOTO FAILBACKUP</p>
<p>:SUCCESSBACKUP<br />
::SEND EMAIL WITH NTBACKUP LOGFILE ATTACHED<br />
IF %SUCCESS% == 1 %MAILPATH% /smtpserver %SMTPSERVER% /to %TO% /from %FROM% /subject %BACKUPMODE% Backup %NOTE% Successful /body %BACKUPMODE% Backup %NOTE% Successful /attachment %ARCHIVEPATH%\%NTBARCLOG% &gt;&gt; %BATCHLOG%</p>
<p>::CLEANUP PREVIOUS BACKUPFILES<br />
::IF NO PREVIOUS BACKUPFILE EXISTS, SKIP TO CLEANIN LOGFILES<br />
IF NOT EXIST %DESTINATION%\*%BACKUPMODE%_%NOTE%* ECHO NO PREVIOUS BACKUPFILE(S) FOR %BACKUPMODE%_%NOTE% EXIST &gt;&gt; %BATCHLOG% &amp; GOTO CLLOG<br />
::IF PREVIOUS BACKUPFILE(S) EXIST, DELETE ALL PREVIOUS BACKUPFILES. FILTERED BY VARIABLES %BACKUPMODE% &amp; %NOTE%<br />
::THE FOLLOWING STATEMENT IS COMPLETELY DEPENDEND ON THE MAKEUP OF THE VARIABLE %BACKUPFILE%<br />
IF %NOTE% == note %DAPATH% %DESTINATION%\*%BACKUPMODE%_%NOTE%* 60 &gt;&gt; %BATCHLOG% &amp; GOTO CLLOG<br />
IF %BACKUPMODE% == SYSTEMSTATE %DAPATH% %DESTINATION%\*%BACKUPMODE%_%NOTE%* 60 &gt;&gt; %BATCHLOG% &amp; GOTO CLLOG<br />
::FOR /F &#8220;TOKENS=1-7 DELIMS=_-.&#8221; %%A IN (&#8217;DIR %DESTINATION%\*%BACKUPMODE%_%NOTE%* /B&#8217;) DO IF &#8220;%%F%%E%%D&#8221; LSS &#8220;%DTE%&#8221; SET BF=%%A_%%B_%%C_%%D-%%E-%%F.%%G &amp; DEL %DESTINATION%\%BF% &amp; IF ERROLEVEL NEQ 0 ECHO PREVIOUS BACKUPFILE %DESTINATION%\%BF% DELETED &gt;&gt; %BATCHLOG% &amp; GOTO CLLOG<br />
ECHO NO (PREVIOUS) BACKUPFILE(S) DELETED &gt;&gt; %BATCHLOG%</p>
<p>:CLLOG<br />
::CLEANUP ARCHIVED LOGFILES<br />
::IF NO PREVIOUS LOGFILE EXISTS, SKIP TO NEXT<br />
IF NOT EXIST %DESTINATION%\*%BACKUPMODE%_%NOTE%* ECHO NO PREVIOUS LOGFILE(S) FOR %BACKUPMODE%_%NOTE% EXIST &gt;&gt; %BATCHLOG% &amp; GOTO NEXT<br />
::IF PREVIOUS LOGFILE(S) EXIST, DELETE ALL PREVIOUS LOGFILES. FILTERED BY VARIABLES %BACKUPMODE% &amp; %NOTE%<br />
::THE FOLLOWING STATEMENT IS DEPENDEND ON THE MAKEUP OF THE VARIABLE %BATCHLOG% &amp; %NTBARCLOG%<br />
IF %NOTE% == note %DAPATH% %ARCHIVEPATH%\*%BACKUPMODE%_%NOTE%* 60 &gt;&gt; %BATCHLOG% &amp; GOTO NEXT<br />
::FOR /F &#8220;TOKENS=1-5 DELIMS=_-.&#8221; %%A IN (&#8217;DIR %ARCHIVEPATH%\*%BACKUPMODE%_%NOTE%* /B&#8217;) DO IF &#8220;%%F%%E%%D&#8221; LSS &#8220;%DTE%&#8221; SET LF=%%A_%%B_%%C-%%D-%%E_*.* &amp; DEL %ARCHIVEPATH%\%LF% &amp; IF ERROLEVEL NEQ 0 ECHO PREVIOUS LOGFILE(S) %ARCHIVEPATH%\%LF% DELETED &gt;&gt; %BATCHLOG% &amp; GOTO NEXT<br />
ECHO NO (PREVIOUS) LOGFILE(S) DELETED &gt;&gt; %BATCHLOG% &amp; GOTO NEXT</p>
<p>:FAILBACKUP<br />
IF %SUCCESS% == 0 %MAILPATH% /smtpserver %SMTPSERVER% /to %TO% /from %FROM% /subject %BACKUPMODE% Backup %NOTE% Failed /body %BACKUPMODE% Backup %NOTE% Failed /attachment %ARCHIVEPATH%\%NTBARCLOG% &gt;&gt; &#8220;%BATCHLOG%&#8221;</p>
<p>:NEXT<br />
IF EXIST &#8220;%ARCHIVEPATH%\%NTBARCLOG%&#8221; ECHO NTBACKUP.EXE .LOG FILE ARCHIVED AT &#8220;%ARCHIVEPATH%\%NTBARCLOG%&#8221; &gt;&gt; %BATCHLOG%<br />
ECHO BATCHLOG .TXT FILE ARCHIVED AT &#8220;%BATCHLOG%&#8221; &gt;&gt; %BATCHLOG%</p>
<p>GOTO END</p>
<p>:NOPARAMS<br />
ECHO ********************************************************<br />
ECHO THIS FILE MUST BE CONFIGURED BY OPENING IT IN NOTEPAD.<br />
ECHO SETTING THE VARIABLES IN THE VARIABLES SECTION.<br />
ECHO TO RUN THE FILE AFTER YOU CONFIGURE IT,<br />
ECHO YOU MUST SPECIFY A BACKUP TYPE AS THE FIRST PARAMETER.<br />
ECHO THE FIRST PARAMETER SHOULD BE IN lowercase.<br />
ECHO SOURCE AND NOTE CAN BE PASSED FROM THE COMMAND LINE,<br />
ECHO READ THE VARIABLES SECTION OF THIS FILE<br />
ECHO.<br />
ECHO EXAMPLE 1:<br />
ECHO MYBACKUP systemstate [source] [note]<br />
ECHO.<br />
ECHO EXAMPLE 2:<br />
ECHO MYBACKUP normal [source] [note]<br />
ECHO.<br />
ECHO EXAMPLE 3:<br />
ECHO MYBACKUP differential [source] [note]<br />
ECHO.<br />
ECHO ********************************************************<br />
PAUSE</p>
<p>:END<br />
CLS<br />
EXIT</p></blockquote>
<p>Source and support files can be downloaded <a href="http://blog.integrii.net/wp-content/uploads/2009/06/MyBackup.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=239</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SharePoint Services 3.0 Command Line Backup Script With 7 Day Full Retention and Email Reporting</title>
		<link>http://blog.integrii.net/?p=122</link>
		<comments>http://blog.integrii.net/?p=122#comments</comments>
		<pubDate>Sat, 19 Jul 2008 01:18:28 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>
		<category><![CDATA[newbie.blog]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=122</guid>
		<description><![CDATA[This backup script fully backs up your SharePoint Services 3.0 site to a specified location and keeps copies of backups for 7 days.  You&#8217;ll have to set the variables at the top of the script, then schedule it to run with the windows task scheduler, and then you&#8217;re off!  
Oh, and you&#8217;ll need [...]]]></description>
			<content:encoded><![CDATA[<p>This backup script fully backs up your SharePoint Services 3.0 site to a specified location and keeps copies of backups for 7 days.  You&#8217;ll have to set the variables at the top of the script, then schedule it to run with the windows task scheduler, and then you&#8217;re off!  </p>
<p>Oh, and you&#8217;ll need blat.exe &#8211; you can download it directly from me if you like <a href="http://blog.integrii.net/programs/blat.exe">here</a>. OR Google it if you don&#8217;t trust me.</p>
<p><strong>location</strong> &#8211; Location you want your backups to be stored.<br />
<strong>blat</strong> &#8211; Location of blat.exe<br />
<strong>relayserver</strong> &#8211; An email server you have relay access to.<br />
<strong>yourserver</strong> &#8211; Your SharePoint site&#8217;s URL.<br />
<strong>templog</strong> &#8211; Temp location logs are stored before being emailed.<br />
<strong>file</strong> &#8211; Name of the SharePoint backup files that will be created.<br />
<strong>to</strong> &#8211; Who the email reports go to.<br />
<strong>who</strong> &#8211; Who the email should come from.<br />
<strong>reply</strong> &#8211; Where email replies should go.</p>
<p><strong>SPBackup.bat</strong></p>
<blockquote><p>
echo blog.integrii.net SharePoint Services 3 7 Day Command Line Backup Script Version 1</p>
<p>set location=d:\sharepoint\backup<br />
set blat=c:\windows\system32\blat.exe<br />
set relayserver=mail.yourrelayserver.com<br />
set yoursite=https://sharepoint.yoursite.com<br />
set emailsub=SharePointBackupReport<br />
set templog=c:\batch\spbackup.txt<br />
set file=Backup.bak<br />
set to=sys-ops@yourdomain.com<br />
set who=sharepointbackup@yourdomain.com<br />
set reply=noreply@yourdomain.com</p>
<p>del %location%\%file%.7day<br />
rename %location%\%file%.6day %file%.7day<br />
rename %location%\%file%.5day %file%.6day<br />
rename %location%\%file%.4day %file%.5day<br />
rename %location%\%file%.3day %file%.4day<br />
rename %location%\%file%.2day %file%.3day<br />
rename %location%\%file%.1day %file%.2day<br />
rename %location%\%file% %file%.1day<br />
&#8220;C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\Stsadm.exe&#8221; -o backup -overwrite -url %yoursite% -backupmethod full -filename %location%\%file% > %templog%<br />
dir %location% >> %templog%<br />
%blat% &#8220;%templog%&#8221; -t %to% -s &#8220;%emailsub%&#8221; -i %who% -f &#8220;%reply%&#8221; -q -server &#8220;%relayserver%&#8221;
</p></blockquote>
<p>Please comment any problems you have so we can get this baby just right!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=122</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Automatic and Dynamic All Purpose NTBackup.exe Script with Email Notifications and Log Archiving (EricBackup.bat)</title>
		<link>http://blog.integrii.net/?p=76</link>
		<comments>http://blog.integrii.net/?p=76#comments</comments>
		<pubDate>Wed, 08 Aug 2007 19:21:31 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=76</guid>
		<description><![CDATA[This script can do a SystemState, Normal or Differential backup via NTBackup from any location, to any location and have an email report sent to you shortly before the logfile is archived in your designated directory.  All you have to do is set all the settings that i describe below in the top section [...]]]></description>
			<content:encoded><![CDATA[<p>This script can do a SystemState, Normal or Differential backup via NTBackup from any location, to any location and have an email report sent to you shortly before the logfile is archived in your designated directory.  All you have to do is set all the settings that i describe below in the top section of the script, put in any mapped drives you need to be mapped (net use x: \\server\share /user:user pass) where I have it commented and run it with the desired backup type specified.  You can run ericbackup.bat alone to see a help display, too. This certainly isn&#8217;t anything new, but it is handy because this script can be easily molded, with it&#8217;s built in settings, to work in almost any situation.  If you are running this as a task, you must remember to include the type of backup in the run line of the task.  Simply specifying the .bat will not work, you must specify as the example useage below shows.</p>
<p>I would also like everyone to know that this file can be run remotely with psexec&#8230; see <a href="http://blog.integrii.net/?p=56" target="_blank">this article for PowerShell</a> and <a href="http://blog.integrii.net/?p=20" target="_blank">this article for batch</a> on how to do that.  But remember: If you use psexec to run this remotely, the user will be &#8220;Default User&#8221;.</p>
<p><strong>blatpath</strong> &#8211; <em>The path to <a href="http://blog.integrii.net/programs/blat.exe" target="_blank">blat.exe</a>, which is used to email your reports to you.</em><br />
<strong>relayserver</strong> &#8211; <em>An email server your computer has access to.  This is required to have your report email sent to you.</em><br />
<strong>email</strong> &#8211; <em>The email your reports will be sent to.</em><br />
<strong>fromemail</strong> &#8211; <em>This is the address the email will appear to be sent from.  Important because some mailservers will filter mail baised ont his.  Your own email should be fine.</em><br />
<strong>emailuser</strong> &#8211; <em>Your email server user login.</em><br />
<strong>emailpass</strong> &#8211; <em>Your email server password.</em><br />
<strong>source</strong> &#8211; <em>The directory your backup will be targeting.  Systemstate backups will ignore this automatically.  If you&#8217;re targeting the root of a drive, you leave out the ending \ character (ex: c: not c:\).  If you want to use a ANSI .bks file, you can specify that here with an @ symbol ahead of it.  EX) @c:\filelist.bks  Using a unicode .bks file lets you list multiple target locations.</em><br />
<strong>destination</strong> &#8211; <em>The location your backup files will be placed into&#8230; in *.BKF format.  If you&#8217;re targeting the root of a drive, you leave out the ending \ character (ex: c: not c:\).</em><br />
<strong>textlogpath</strong> &#8211; <em>Path to the text logfile which will track progress and be emailed then archived.</em><br />
<strong>archivepath</strong> &#8211; <em>The place logs will be placed for storage.  Files will be renamed appropriately.</em><br />
<strong>username</strong> &#8211; <em>This is very important.  This is the name of the folder in your user profile.  For example, if you opened a CMD window you would see the path to your local profile.  This variable is the name of the last folder in that path. If my user folder is eric.greer then this will be eric.greer.  Most of the time this folder name is the exact same as the user name it will run under.  If this script is running in remotely via PSExec or as the system account, it will require Default User, without quotes, to be entered here.<em><br />
<strong>note</strong> &#8211; <em>Just a note.  This will be placed on your email subject along with on the filename.  Good to include the location.  Spaces are not supported very well here, and don&#8217;t use quotation marks either.</em></p>
<p><strong>Example Useage:</strong> <em>(After setting variables on the top of the script!)</em></p>
<blockquote><p>
ericbackup.bat normal
</p></blockquote>
<blockquote><p>
ericbackup.bat systemstate
</p></blockquote>
<blockquote><p>
ericbackup.bat differential
</p></blockquote>
<p><em>This will start a normal backup with the settings you specified within the batch file.</em></p>
<p><strong>EricBackup.bat</strong></p>
<blockquote><p>
<code>@echo off<br />
:Variables</p>
<p>REM Insert your variables below before running this batch from the command line.</p>
<p>set blatpath=c:\programs\blat.exe<br />
set relayserver=localhost<br />
set email=blog@integrii.net<br />
set fromemail=blog@integrii.net<br />
set emailuser=your.user<br />
set emailpass=your.pass<br />
set source=C:\Scripts<br />
set destination=K:\Backup<br />
set textlogpath=K:\Backup\%computername%-Backup.txt<br />
set archivepath=K:\Backup\OldLogs<br />
set username=administrator<br />
set note=ScriptsBackup</p>
<p>REM Map your drives here if you need to.</p>
<p>REM If you use psexec to run this remotely, the user will be "Default User"<br />
REM Dont touch anything below here.<br />
REM Dont touch anything below here.<br />
REM Dont touch anything below here.<br />
REM Dont touch anything below here.<br />
REM Dont touch anything below here.</p>
<p>:TimeStuffFromMichaelSmith</p>
<p>for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (<br />
                                set Month=%%j<br />
                                set Day=%%k<br />
                                set Year=%%l<br />
                                set Date=%%j-%%k-%%l<br />
                                set dirdate=%%j%%k%%l<br />
                )<br />
                for /f "Tokens=1-2 delims=/ " %%i in ('time /t') do (<br />
                                set tm=%%i<br />
                                set ampm=%%j<br />
                )</p>
<p>:Preparation</p>
<p>echo.<br />
echo **************************<br />
echo EricBackup.bat Version 2.8<br />
echo EricGreer@GMail.com<br />
echo http://blog.integrii.net/?p=76<br />
echo **************************<br />
echo.</p>
<p>if "%1" == "systemstate" set backupmode=systemstate &#038; echo "%1 mode selected." &#038; goto goodtogo<br />
if "%1" == "normal" set backupmode=normal &#038; echo "%1 mode selected." &#038; goto goodtogo<br />
if "%1" == "differential" set backupmode=differential &#038; echo "%1 mode selected." &#038; goto goodtogo<br />
if "%1" == "Systemstate" set backupmode=systemstate &#038; echo "%1 mode selected." &#038; goto goodtogo<br />
if "%1" == "Normal" set backupmode=normal &#038; echo "%1 mode selected." &#038; goto goodtogo<br />
if "%1" == "Differential" set backupmode=differential &#038; echo "%1 mode selected." &#038; goto goodtogo<br />
if "%1" == "SystemState" set backupmode=systemstate &#038; echo "%1 mode selected." &#038; goto goodtogo</p>
<p>goto noparams</p>
<p>:goodtogo</p>
<p>set server=%computername%<br />
set logpath=C:\Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data</p>
<p>if not exist "%archivepath%" md "%archivepath%" &#038; echo "Archive Path did not exist, so it was created." >> %textlogpath%<br />
if exist "%textlogpath%" del "%textlogpath%" &#038; echo "Previous %textlogpath% existed, so it was deleted." >> %textlogpath%<br />
if exist "%logpath%\*.log" del "%logpath%\*.log" &#038; echo "Previous ntbackup logfile existed, so it was deleted." >> %textlogpath%</p>
<p>:Backup</p>
<p>echo %server% backup started at %tm% %ampm% on %Year%-%Month%-%Day% into "%destination%" >> %textlogpath%<br />
echo %server% backup starts %tm% %ampm% on %Year%-%Month%-%Day% into "%destination%"</p>
<p>if %backupmode% == systemstate ntbackup.exe backup systemstate "%source%" /n "%server%-Backup" /d "%server%-Backup" /v:no /r:no /rs:no /hc:off /j "%server%-Backup" /l:s /f "%destination%\%server%-Backup-%Year%-%Month%-%Day%-SYSTEMSTATE.bkf" >> %textlogpath%<br />
if %backupmode% == differential ntbackup.exe backup "%source%" /n "%server%-Backup" /d "%server%-Backup" /v:no /r:no /rs:no /hc:off /m differential /j "%server%-Backup" /l:s /f "%destination%\%server%-Backup-%Year%-%Month%-%Day%-DIFFERENTIAL.bkf" >> %textlogpath%<br />
if %backupmode% == normal ntbackup.exe backup "%source%" /n "%server%-Backup" /d "%server%-Backup" /v:no /r:no /rs:no /hc:off /m normal /j "%server%-Backup" /l:s /f "%destination%\%server%-Backup-%Year%-%Month%-%Day%-NORMAL.bkf" >> %textlogpath%</p>
<p>:RenameLogs</p>
<p>if exist "%logpath%\*.log" ren "%logpath%\*.log" %server%-Backup.log<br />
if exist "%logpath%\%server%-Backup.log" copy "%logpath%\%server%-Backup.log" "%archivepath%" /y</p>
<p>echo NTBackup.exe .log file archived at "%archivepath%\%note%-%server%-%Year%-%Month%-%Day%.log"  >> %textlogpath%<br />
echo EricBackup.bat .txt file archived at "%archivepath%\%Year%-%Month%-%Day%-%server%-%note%.txt"  >> "%textlogpath%"</p>
<p>:Send<br />
%blatpath% "%textlogpath%" -attach "%archivepath%\%server%-Backup.log" -t %email% -s "%server% Backup Log %Year%-%Month%-%Day% at %tm% %ampm%" -i %fromemail% -f "%fromemail%" -q -server "%relayserver%" -u "%emailuser%" -pw "%emailpass%"</p>
<p>:Archive<br />
if exist "%archivepath%\templog.txt" del "%archivepath%\templog.txt"<br />
if exist %textlogpath% copy "%textlogpath%" "%archivepath%\templog.txt"<br />
if exist "%archivepath%\%Year%-%Month%-%Day%-%server%-%note%.txt" del %archivepath%\%Year%-%Month%-%Day%-%server%-%note%.txt<br />
if exist %archivepath%\templog.txt ren %archivepath%\templog.txt "%Year%-%Month%-%Day%-%server%-%note%.txt"</p>
<p>if exist "%archivepath%\%note%-%server%-%Year%-%Month%-%Day%.log" del "%archivepath%\%note%-%server%-%Year%-%Month%-%Day%.log"<br />
if exist "%archivepath%\%server%-Backup.log" ren "%archivepath%\%server%-Backup.log" "%note%-%server%-%Year%-%Month%-%Day%.log"<br />
if exist "%archivepath%\%server%-Backup.log" del "%archivepath%\%server%-Backup.log"<br />
if exist "%logpath%\%server%-Backup.log" del "%logpath%\%server%-Backup.log"</p>
<p>if exist "%textlogpath%" del "%textlogpath%"</p>
<p>goto eof</p>
<p>:noparams<br />
echo This file must be configured by opening it in notepad and setting the variables in the variables section at the top of the script.<br />
echo You do not need to touch anything else beyond the variables with remarks above them!<br />
echo To run the file after you configure it in notepad you must specify a backup type as the first paramiter.<br />
echo.<br />
echo EXAMPLE 1:<br />
echo ericbackup Systemstate<br />
echo.<br />
echo EXAMPLE 2:<br />
echo ericbackup Normal<br />
echo.<br />
echo EXAMPLE 3:<br />
echo ericbackup Differential<br />
echo.<br />
echo **************************<br />
echo.</p>
<p>:eof</code></p></blockquote>
<p><a href="http://blog.integrii.net/programs/blat.exe" target="_blank">Download BLAT</a></p>
<p>This script has been a lot of work to get just right, and I would appreciate it if any problems are reported to me.  This is a big timesaver for me and i use it every other day in different environments with no problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=76</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Burn CDs from Command Line</title>
		<link>http://blog.integrii.net/?p=50</link>
		<comments>http://blog.integrii.net/?p=50#comments</comments>
		<pubDate>Thu, 05 Jul 2007 17:21:16 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=50</guid>
		<description><![CDATA[Check out this awesome tool by Alex Feinman to burn CDs from a command line.  This program makes it really easy to script CD burning for scheduled archive procedures!
Check out how easy the command line is for it:
createcd -r:d c:\burnfiles
Thats it!  That would automatically gather all the files from c:\burnfiles and within, then [...]]]></description>
			<content:encoded><![CDATA[<p>Check out this awesome tool by Alex Feinman to burn CDs from a command line.  This program makes it really easy to script CD burning for scheduled archive procedures!</p>
<p>Check out how easy the command line is for it:</p>
<blockquote><p>createcd -r:d c:\burnfiles</p></blockquote>
<p>Thats it!  That would automatically gather all the files from c:\burnfiles and within, then burn them using drive D.  Best of all, it&#8217;s freeware.</p>
<p>Rehosted <a href='http://blog.integrii.net/wp-content/uploads/2007/07/createcd.exe' title='createcd.exe'>here. (createcd.exe)</a>.<br />
<em>This utility is free for non-commercial (personal) use. </em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=50</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delete files older than X days</title>
		<link>http://blog.integrii.net/?p=33</link>
		<comments>http://blog.integrii.net/?p=33#comments</comments>
		<pubDate>Wed, 13 Jun 2007 15:25:48 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=33</guid>
		<description><![CDATA[This batch is a direct modification to the &#8216;copyout.bat&#8217; file I posted  here.  This file scans a location for files older than a number of specified days and deletes them.  The file is also setup to use blat.exe (download from sourceforge) to send email reports.
NOTE:  This must not be used on [...]]]></description>
			<content:encoded><![CDATA[<p>This batch is a direct modification to the &#8216;copyout.bat&#8217; file I posted  <a href="http://blog.integrii.net/?p=27">here.</a>  This file scans a location for files older than a number of specified days and deletes them.  The file is also setup to use blat.exe (download from sourceforge) to send email reports.</p>
<p><strong>NOTE:</strong>  This must not be used on a computer with a &#8216;forfiles&#8217; version created before 2000 as the syntax has since changed.</p>
<p><strong>loglocation</strong> &#8211; the location you want your log to be recorded at<br />
<strong>olderthan</strong> &#8211; number of days old the files you want to delete have to be<br />
<strong>source</strong> &#8211; the location the files will start at (dont end this field in a \)<br />
<strong>email</strong> &#8211; the address that will be notified when the operation sends an email report<br />
<strong>blat</strong> &#8211; the path to the blat.exe file (this, and all the others, can be a UNC path). Must be downloaded from souce forge most of the time.<br />
<strong>extension</strong> &#8211; The file extension(s) to copy then delete, just use * for all files.<br />
<strong>relayserver</strong> &#8211; Target mail server with relay enabled. (required)</p>
<p><strong>Use at your own risk, no warranties and stuff.</strong></p>
<p><strong>deleteold.bat</strong></p>
<blockquote><p><code><br />
@echo off</p>
<p>set loglocation=C:\Deleteold.txt<br />
set olderthan=31<br />
set source=F:<br />
set email=blog@integrii.net<br />
set blat=c:\blat.exe<br />
set extension=bkf<br />
set relayserver=localhost</p>
<p>color 1f<br />
if exist %loglocation% del %loglocation%</p>
<p>echo blog@integrii.net - deleteold.bat - v1.3<br />
echo Deleting files older than %olderthan% days with the file extension *.%extension% located at %source%.<br />
echo Deleting files older than %olderthan% days with the file extension *.%extension% located at %source%. >> %loglocation%</p>
<p>cd %source%</p>
<p>echo List of files to be removed: >> %loglocation%<br />
echo List of files to be removed:</p>
<p>FORFILES -p %source% /d -%olderthan% -m *.%extension% -c "CMD /C Echo "@FILE"<br />
FORFILES -p %source% /d -%olderthan% -m *.%extension% -c "CMD /C Echo "@FILE" >> %loglocation%</p>
<p>echo Starting delete...<br />
echo Starting delete... >> %loglocation%<br />
date /t >> %loglocation%<br />
time /t >> %loglocation%</p>
<p>FORFILES -p %source% /d -%olderthan% -m *.%extension% -c "CMD /C del %source%\@FILE /q &#038; echo %source%\@FILE deleted." >> %loglocation%</p>
<p>echo Log file located at %loglocation%</p>
<p>echo Delete finished... Sending Report.<br />
echo Delete finished... >> %loglocation%<br />
date /t >> %loglocation%<br />
time /t >> %loglocation%</p>
<p>set server=%computername%<br />
%blat% %loglocation% -t %email% -s "%server% Deletion Log" -server %relayserver% -f do-not-reply@%server%.delete.log</p>
<p>echo Report sent!</p>
<p>exit
</p></blockquote>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=33</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Copy then delete files older than X days [Updated 8/7/07]</title>
		<link>http://blog.integrii.net/?p=27</link>
		<comments>http://blog.integrii.net/?p=27#comments</comments>
		<pubDate>Sun, 10 Jun 2007 16:24:23 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=27</guid>
		<description><![CDATA[This script simply uses the forfiles command along with xcopy to copy ntbackup files from a source location to a destination location.  The script then checks if the file exists in the destionation location, and if it does, deletes the source file.  A report is then sent using blat.exe to the specified account [...]]]></description>
			<content:encoded><![CDATA[<p>This script simply uses the forfiles command along with xcopy to copy ntbackup files from a source location to a destination location.  The script then checks if the file exists in the destionation location, and if it does, deletes the source file.  A report is then sent using <a href="http://sourceforge.net/projects/blat">blat.exe</a> to the specified account in the email variable.  The script was written to be VERY verbose for logging purposes, there is only an actual few lines of action taking place.  I currently use this to move backups from one location to another to free up space automatically.  I am sure it has LOTS more uses.  </p>
<p><strong>NOTE:</strong>  This must not be used on a computer with a &#8216;forfiles&#8217; version created before 2000 as the syntax has since changed.<br />
<strong>If you only want to delete files, check out <a href="http://blog.integrii.net/?p=33">deleteold.bat</a>.</strong></p>
<p>All you need to do is change the variables at the top of the batch file.  Heres what they should be, in case my names aren&#8217;t totally self-explanitory.</p>
<p><strong>loglocation</strong> &#8211; the location you want your logs to be recorded at<br />
<strong>olderthan</strong> &#8211; number of days old the files you want to target have to be<br />
<strong>source</strong> &#8211; the location the files will start at (this field must not end with a \)<br />
<strong>destination</strong> &#8211; the location you want to move the files to before deleting<br />
<strong>email</strong> &#8211; the address that will be notified when the operation sends an email report<br />
<strong>blat</strong> &#8211; the path to the blat.exe file (this, and all the others, can be a UNC path).  Must be downloaded from souce forge most of the time.<br />
<strong>extension</strong> &#8211; The file extension(s) to copy then delete, just use * for all files.<br />
<strong>relayserver</strong> &#8211; Target mail server with relay enabled. <strong>(required)</strong><br />
<strong>subject</strong> &#8211; The subject of the report email that will be sent.</p>
<p>This is a very multi-purpose file and can be used for all kinds of stuff!  Enjoy!</p>
<p><strong>copyout.bat</strong></p>
<blockquote><p><code><br />
@echo off</p>
<p>set loglocation=C:\logs\Copyout.txt<br />
set olderthan=10<br />
set source=H:\backups<br />
set destination=K:\<br />
set email=blog@integrii.net<br />
set blat=c:\blat.exe<br />
set extension=*<br />
set relayserver=localhost<br />
set subject="Copyout.bat Report"</p>
<p>if exist %loglocation% del %loglocation%</p>
<p>echo ericgreer@gmail.com - copyout.bat - v1.78<br />
echo Copying and deleting files older than %olderthan% days with the file extension *.%extension%.<br />
echo Copying and deleting files older than %olderthan% days with the file extension *.%extension%. >> %loglocation%<br />
echo Copying from %source% to %destination% and deleting from %source%.<br />
echo Copying from %source% to %destination% and deleting from %source%. >> %loglocation%<br />
echo This file may take an extremely long time to run while it looks unresponsive.<br />
echo Check %loglocation% for copy progress.</p>
<p>cd %source%</p>
<p>echo List of files to be copied and removed: >> %loglocation%<br />
echo List of files to be copied and removed:</p>
<p>FORFILES -p %source% /d -%olderthan% -m *.%extension% -c "CMD /C Echo "@FILE"<br />
FORFILES -p %source% /d -%olderthan% -m *.%extension% -c "CMD /C Echo "@FILE" >> %loglocation%</p>
<p>echo Starting copy...<br />
echo Starting copy... >> %loglocation%<br />
date /t >> %loglocation%<br />
time /t >> %loglocation%</p>
<p>FORFILES -p %source% /d -%olderthan% -m *.%extension% -c "CMD /C XCOPY %source%\@FILE %destination%"</p>
<p>echo Starting delete...<br />
echo Starting delete... >> %loglocation%<br />
date /t >> %loglocation%<br />
time /t >> %loglocation%</p>
<p>FORFILES -p %source% /d -%olderthan% -m *.%extension% -c "CMD /C if exist %destination%\@FILE del %source%\@FILE /Q &#038; echo @FILE Deleted." >> %loglocation%</p>
<p>echo Log file located at %loglocation%</p>
<p>echo Copy and Delete finished... Sending Report.<br />
echo Copy and Delete finished... >> %loglocation%</p>
<p>echo Source Directory Contents: >> %loglocation%<br />
echo. >> %loglocation%<br />
dir %source% >> %loglocation%</p>
<p>echo. >> %loglocation%<br />
echo. >> %loglocation%<br />
echo. >> %loglocation%</p>
<p>echo Destination Directory Contents: >> %loglocation%<br />
echo. >> %loglocation%<br />
dir %destination% >> %loglocation%</p>
<p>date /t >> %loglocation%<br />
time /t >> %loglocation%</p>
<p>set server=%computername%<br />
%blat% %loglocation% -t %email% -s "%server% %subject%" -server %relayserver% -f do-not-reply@%server%.copyout.bat</p>
<p>echo Report sent!
</p></blockquote>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=27</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Error ID command line lookup (EventID.net)</title>
		<link>http://blog.integrii.net/?p=23</link>
		<comments>http://blog.integrii.net/?p=23#comments</comments>
		<pubDate>Thu, 31 May 2007 01:08:32 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=23</guid>
		<description><![CDATA[This simple little script just looks up an error code on www.EventID.net when you supply an event. I find this prety useful when I am digging into server logs.
Sample:
id 2000
(looks up errorid 2000 on eventid.net)
id.bat

@echo off
color 1f
start http://www.eventid.net/display.asp?eventid=%1

]]></description>
			<content:encoded><![CDATA[<p>This simple little script just looks up an error code on <a href="http://www.eventid.net/">www.EventID.net</a> when you supply an event. I find this prety useful when I am digging into server logs.</p>
<p>Sample:<br />
<strong>id 2000</strong><br />
(looks up errorid 2000 on eventid.net)</p>
<p>id.bat</p>
<blockquote><p><code><br />
@echo off<br />
color 1f<br />
start http://www.eventid.net/display.asp?eventid=%1<br />
</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=23</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PsExec Batch Shortcut</title>
		<link>http://blog.integrii.net/?p=20</link>
		<comments>http://blog.integrii.net/?p=20#comments</comments>
		<pubDate>Fri, 25 May 2007 00:33:38 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=20</guid>
		<description><![CDATA[This batch file simply saves the trouble of worrying about getting all the context right for psexec and makes it easier to run things on multiple computers with varying usernames.  Help is built into the file as you can see below, so just run the batch without any paramiters for a listing.
runremote.bat


@echo off
color 1f
if "%1" [...]]]></description>
			<content:encoded><![CDATA[<p>This batch file simply saves the trouble of worrying about getting all the context right for psexec and makes it easier to run things on multiple computers with varying usernames.  Help is built into the file as you can see below, so just run the batch without any paramiters for a listing.</p>
<p>runremote.bat</p>
<p><code></p>
<blockquote>
<p>@echo off<br />
color 1f</p>
<p>if "%1" == "" goto help</p>
<p>:runit<br />
psexec @serverlist.txt -c -s -f -n 10 -u %1 %2<br />
goto end</p>
<p>:help<br />
echo ---<br />
echo blog@integrii.net<br />
echo PsExec Batch File Shortcut<br />
echo http://blog.integrii.net<br />
echo ---<br />
echo PURPOSE:<br />
echo Runs a file or command on a list of remote computers with a specified username.<br />
echo ---<br />
echo USEAGE:<br />
echo runstuff [remote username] [command or file]<br />
echo ---<br />
echo NOTE:<br />
echo You MUST CHANGE the serverlist.txt to contain a list of target computers. One computer per line, hostname or IP address.<br />
echo ---<br />
pause</p>
<p>:end</p>
</blockquote>
<p></code><br />
 View more about PsExec here:<br />
<a href="http://www.microsoft.com/technet/sysinternals/Security/PsExec.mspx">http://www.microsoft.com/technet/sysinternals/Security/PsExec.mspx</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=20</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto-Ban FTP Attacks with Remote Service Install</title>
		<link>http://blog.integrii.net/?p=18</link>
		<comments>http://blog.integrii.net/?p=18#comments</comments>
		<pubDate>Thu, 24 May 2007 04:02:54 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=18</guid>
		<description><![CDATA[This .zip file contains everything you need (including cscript.exe) to deply a service on a list of remote computers.  The service this script deploys is .vbs script that looks for failed logon attempts to the Administrator account.  When the script detects a failed login to the Administrator account it adds a route that breaks the [...]]]></description>
			<content:encoded><![CDATA[<p>This .zip file contains everything you need (including cscript.exe) to deply a service on a list of remote computers.  The service this script deploys is .vbs script that looks for failed logon attempts to the Administrator account.  When the script detects a failed login to the Administrator account it adds a route that breaks the connection almost immidately.  Then, the hostile IP is added to the ban list for all FTP sites on the machine.  This ban is at the root level, not just the site level.</p>
<p> This script is very effective at stopping strong-arm attackers because almost any brute force attack tries the Administrator account right away.  The only prolem with this script is that it will NOT stop failed attempts on other accounts.  From my experience, this script stops at least half of all attackers right away, and most eventually.</p>
<p>Steps to install:</p>
<ol>
<li>Open the serverlist.txt and put one server on each line, (this installer works with psexec from sysinternals) then save and close the file. </li>
<li>Open up the runstuff.bat in your favorite text editor (Notepad++ for me) and change the &#8216;administrator&#8217; username to whatever domain administrator you use on your network.  Including the domain might or might not be required depending on how your target computers are set up. </li>
<li>Cut and paste the files to a place on the network available to all the target computers.</li>
<li>Open the install.bat in a text editor and change the (INSERT NETWORK LOCATION HERE) to the UNC path on your network.</li>
<li>Open the runstuff.bat file and enter your password when prompted.</li>
</ol>
<p>Download .zip: <a href="http://blog.integrii.net/wp-content/uploads/2007/05/banip-remote-installer.zip" title="BanIP Remote Installer">BanIP Remote Installer</a></p>
<p>Thanks the .vbs script&#8217;s author <a href="http://blog.netnerds.net/2006/07/ban-administrator-ftp-login-attemps/">Chrissy</a> and to <a href="http://blogs.mscorlib.com/Home/tabid/111/EntryID/42/Default.aspx">frijoles</a> for the great instructions I used to write this.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=18</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multi-Remote Desktop (RDP) via Run Line</title>
		<link>http://blog.integrii.net/?p=14</link>
		<comments>http://blog.integrii.net/?p=14#comments</comments>
		<pubDate>Thu, 24 May 2007 03:11:54 +0000</pubDate>
		<dc:creator>Eric Greer</dc:creator>
				<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://blog.integrii.net/?p=14</guid>
		<description><![CDATA[ This is a script I wrote real quick one day when I got tired of clicking on the Terminal Services icon 4 times when I wanted to connect to 4 servers.  With this script, I simply open up the run line (Windows+R) and type &#8220;rdp server1 server2 server3&#8243; all the way to up to 9  [...]]]></description>
			<content:encoded><![CDATA[<p> This is a script I wrote real quick one day when I got tired of clicking on the Terminal Services icon 4 times when I wanted to connect to 4 servers.  With this script, I simply open up the run line (Windows+R) and type &#8220;rdp server1 server2 server3&#8243; all the way to up to 9  connections at once.  I know a few people around my office use this, even if they dont connect to multiple servers at once.  Must have for the admin who uses mstsc.exe to manage his or her network.</p>
<p>rdp.bat</p>
<blockquote><p> @echo off</p>
<p>echo <a href="mailto:blog@integrii.net">blog@integrii.net</a><br />
echo Multiple RDP Connection Batch File Shortcut<br />
echo <a href="http://blog.integrii.net/">http://blog.integrii.net</a><br />
echo &#8212;&#8212;&#8212;&#8212;</p>
<p>color 1f</p>
<p>if not &#8220;%9&#8243;==&#8221;" GOTO nine<br />
if not &#8220;%8&#8243;==&#8221;" GOTO eight<br />
if not &#8220;%7&#8243;==&#8221;" GOTO seven<br />
if not &#8220;%6&#8243;==&#8221;" GOTO six<br />
if not &#8220;%5&#8243;==&#8221;" GOTO five<br />
if not &#8220;%4&#8243;==&#8221;" GOTO four<br />
if not &#8220;%3&#8243;==&#8221;" GOTO three<br />
if not &#8220;%2&#8243;==&#8221;" GOTO two<br />
if not &#8220;%1&#8243;==&#8221;" GOTO one<br />
if &#8220;%1&#8243;==&#8221;" echo No Servers Specified!<br />
GOTO end</p>
<p>:one<br />
start mstsc /v: %1<br />
goto end</p>
<p>:two<br />
start mstsc /v: %1<br />
start mstsc /v: %2<br />
goto end</p>
<p>:three<br />
start mstsc /v: %1<br />
start mstsc /v: %2<br />
start mstsc /v: %3<br />
goto end</p>
<p>:four<br />
start mstsc /v: %1<br />
start mstsc /v: %2<br />
start mstsc /v: %3<br />
start mstsc /v: %4<br />
goto end</p>
<p>:five<br />
start mstsc /v: %1<br />
start mstsc /v: %2<br />
start mstsc /v: %3<br />
start mstsc /v: %4<br />
start mstsc /v: %5<br />
goto end</p>
<p>:six<br />
start mstsc /v: %1<br />
start mstsc /v: %2<br />
start mstsc /v: %3<br />
start mstsc /v: %4<br />
start mstsc /v: %5<br />
start mstsc /v: %6<br />
goto end</p>
<p>:seven<br />
start mstsc /v: %1<br />
start mstsc /v: %2<br />
start mstsc /v: %3<br />
start mstsc /v: %4<br />
start mstsc /v: %5<br />
start mstsc /v: %6<br />
start mstsc /v: %7<br />
goto end</p>
<p>:eight<br />
start mstsc /v: %1<br />
start mstsc /v: %2<br />
start mstsc /v: %3<br />
start mstsc /v: %4<br />
start mstsc /v: %5<br />
start mstsc /v: %6<br />
start mstsc /v: %7<br />
start mstsc /v: %8<br />
goto end</p>
<p>:nine<br />
start mstsc /v: %1<br />
start mstsc /v: %2<br />
start mstsc /v: %3<br />
start mstsc /v: %4<br />
start mstsc /v: %5<br />
start mstsc /v: %6<br />
start mstsc /v: %7<br />
start mstsc /v: %8<br />
start mstsc /v: %9<br />
goto end</p>
<p>:end<br />
exit</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.integrii.net/?feed=rss2&amp;p=14</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
