<?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>devtrends.com &#187; Batch Files</title>
	<atom:link href="http://www.devtrends.com/index.php/tag/batch-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devtrends.com</link>
	<description>developing trends in information technology</description>
	<lastBuildDate>Tue, 06 Sep 2011 19:27:42 +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>Deploying Applications with the Possibility of a Slow Connection (Robocopy)</title>
		<link>http://www.devtrends.com/index.php/deploying-applications-with-the-possibility-of-a-slow-connection/</link>
		<comments>http://www.devtrends.com/index.php/deploying-applications-with-the-possibility-of-a-slow-connection/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 19:43:49 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Batch Files]]></category>
		<category><![CDATA[Microsoft O/S]]></category>
		<category><![CDATA[zFeatured]]></category>
		<category><![CDATA[robocopy]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=523</guid>
		<description><![CDATA[Regardless of which software deployment suite you use in your organization, there is no way to avoid transferring the majority of the installation files to the local machine, whether that...]]></description>
			<content:encoded><![CDATA[<p>Regardless of which software deployment suite you use in your organization, there is no way to avoid transferring the majority of the installation files to the local machine, whether that is a file copy or a load into memory / temporary location. For small application deployments, running them directly from a share location on a server isn’t necessarily a bad idea, even if the user is connected remotely. However, on the other side of the spectrum, installing Microsoft Office from a server share, while connected remotely, is a bad idea.</p>
<p>So what is the solution? How about staging the files on the local hard drive prior to starting the installation? Your first thought might be a batch file or command script that uses xcopy – at least that was my first thought. However, xcopy assumes that your connection will not drop and that it is fairly fast. What happens when the user is remote and while copying the files the user disconnects from the Internet and Virtual Private Network (VPN)? The file copy process has to start over…</p>
<p>With robocopy, a Microsoft product, you can configure it to copy with resume capabilities. In addition, if you show the installation process to your users (different discussion), each file in the copy process displays its current transferred status (0-100%).</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2010/02/robocopy1.jpg"><img class="alignnone size-medium wp-image-524" title="robocopy1" src="http://www.devtrends.com/wp-content/uploads/2010/02/robocopy1-300x151.jpg" alt="" width="300" height="151" /></a></p>
<p><strong>Getting RoboCopy</strong></p>
<p>Robocopy is available for free from Microsoft as part of the Microsoft Windows Server 2003 <a href="http://go.microsoft.com/fwlink/?LinkId=72969" target="_blank">Resource Kit Tools</a>. The command line options are somewhat daunting, something you’d expect to see from the “grep &#8211;help” command in Linux. In this article we only use a small amount of the power that is Robocopy. For those that dislike command line tools, but still need the functionality of Robocopy, have a look at the GUI tools available for Robocopy.</p>
<ul>
<li><a href="http://technet.microsoft.com/en-us/magazine/2006.11.utilityspotlight.aspx" target="_blank">Utility Spotlight Robocopy GUI</a></li>
<li><a href="http://technet.microsoft.com/en-us/magazine/2009.04.utilityspotlight.aspx" target="_blank">Utility Spotlight RichCopy</a></li>
</ul>
<p><strong>Simple Deployment Script (Adobe Reader)</strong></p>
<p>Below is an example for deploying Adobe Reader to clients utilizing the Robocopy tool.</p>
<pre style="padding-left: 30px;">@ECHO OFF</pre>
<pre style="padding-left: 30px;">rem Create log folder, just in case it does not exist
md C:\installer
md C:\installer\logs
md C:\installer\AdobeReader9.3.0</pre>
<pre style="padding-left: 30px;">rem Bring down the files to the local drive
"\\installer\dist$\robocopy.exe" "\\installer\dist$\AdobeReader" "c:\installer\AdobeReader9.3.0" *.* /E /Z</pre>
<pre style="padding-left: 30px;">rem begin installation
msiexec.exe /i c:\installer\AdobeReader9.3.0\AcroRead.msi TRANSFORMS=c:\installer\AdobeReader9.3.0\AcroRead.mst /qn /l*v C:\installer\logs\AdobeReader9.3.0.log</pre>
<p><strong>Robocopy Command Line Options</strong></p>
<pre>C:\&gt;robocopy /?

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010
-------------------------------------------------------------------------------

  Started : Fri Feb 05 10:30:35 2010

              Usage :: ROBOCOPY source destination [file [file]...] [options]

             source :: Source Directory (drive:\path or \\server\share\path).
        destination :: Destination Dir  (drive:\path or \\server\share\path).
               file :: File(s) to copy  (names/wildcards: default is "*.*").

::
:: Copy options :
::
                 /S :: copy Subdirectories, but not empty ones.
                 /E :: copy subdirectories, including Empty ones.
             /LEV:n :: only copy the top n LEVels of the source directory tree.

                 /Z :: copy files in restartable mode.
                 /B :: copy files in Backup mode.
                /ZB :: use restartable mode; if access denied use Backup mode.

  /COPY:copyflag[s] :: what to COPY (default is /COPY:DAT).
                       (copyflags : D=Data, A=Attributes, T=Timestamps).
                       (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

               /SEC :: copy files with SECurity (equivalent to /COPY:DATS).
           /COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
            /NOCOPY :: COPY NO file info (useful with /PURGE).

             /PURGE :: delete dest files/dirs that no longer exist in source.
               /MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).

               /MOV :: MOVe files (delete from source after copying).
              /MOVE :: MOVE files AND dirs (delete from source after copying).

       /A+:[RASHNT] :: add the given Attributes to copied files.
       /A-:[RASHNT] :: remove the given Attributes from copied files.

            /CREATE :: CREATE directory tree and zero-length files only.
               /FAT :: create destination files using 8.3 FAT file names only.
               /FFT :: assume FAT File Times (2-second granularity).
               /256 :: turn off very long path (&gt; 256 characters) support.

             /MON:n :: MONitor source; run again when more than n changes seen.
             /MOT:m :: MOnitor source; run again in m minutes Time, if changed.

      /RH:hhmm-hhmm :: Run Hours - times when new copies may be started.
                /PF :: check run hours on a Per File (not per pass) basis.

             /IPG:n :: Inter-Packet Gap (ms), to free bandwidth on slow lines.

::
:: File Selection Options :
::
                 /A :: copy only files with the Archive attribute set.
                 /M :: copy only files with the Archive attribute and reset it.
    /IA:[RASHCNETO] :: Include only files with any of the given Attributes set.
    /XA:[RASHCNETO] :: eXclude files with any of the given Attributes set.

 /XF file [file]... :: eXclude Files matching given names/paths/wildcards.
 /XD dirs [dirs]... :: eXclude Directories matching given names/paths.

                /XC :: eXclude Changed files.
                /XN :: eXclude Newer files.
                /XO :: eXclude Older files.
                /XX :: eXclude eXtra files and directories.
                /XL :: eXclude Lonely files and directories.
                /IS :: Include Same files.
                /IT :: Include Tweaked files.

             /MAX:n :: MAXimum file size - exclude files bigger than n bytes.
             /MIN:n :: MINimum file size - exclude files smaller than n bytes.

          /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
          /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
          /MAXLAD:n :: MAXimum Last Access Date - exclude files unused since n.
          /MINLAD:n :: MINimum Last Access Date - exclude files used since n.
                       (If n &lt; 1900 then n = n days, else n = YYYYMMDD date).

                /XJ :: eXclude Junction points. (normally included by default).

::
:: Retry Options :
::
               /R:n :: number of Retries on failed copies: default 1 million.
               /W:n :: Wait time between retries: default is 30 seconds.

               /REG :: Save /R:n and /W:n in the Registry as default settings.

               /TBD :: wait for sharenames To Be Defined (retry error 67).

::
:: Logging Options :
::
                 /L :: List only - don't copy, timestamp or delete any files.
                 /X :: report all eXtra files, not just those selected.
                 /V :: produce Verbose output, showing skipped files.
                /TS :: include source file Time Stamps in the output.
                /FP :: include Full Pathname of files in the output.

                /NS :: No Size - don't log file sizes.
                /NC :: No Class - don't log file classes.
               /NFL :: No File List - don't log file names.
               /NDL :: No Directory List - don't log directory names.

                /NP :: No Progress - don't display % copied.
               /ETA :: show Estimated Time of Arrival of copied files.

          /LOG:file :: output status to LOG file (overwrite existing log).
         /LOG+:file :: output status to LOG file (append to existing log).

               /TEE :: output to console window, as well as the log file.

               /NJH :: No Job Header.
               /NJS :: No Job Summary.

::
:: Job Options :
::
       /JOB:jobname :: take parameters from the named JOB file.
      /SAVE:jobname :: SAVE parameters to the named job file
              /QUIT :: QUIT after processing command line (to view parameters).

              /NOSD :: NO Source Directory is specified.
              /NODD :: NO Destination Directory is specified.
                /IF :: Include the following Files.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/deploying-applications-with-the-possibility-of-a-slow-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Echo Without Carriage Return or Line Feed (CR LF)?</title>
		<link>http://www.devtrends.com/index.php/echo-without-carriage-return-or-line-feed-cr-lf/</link>
		<comments>http://www.devtrends.com/index.php/echo-without-carriage-return-or-line-feed-cr-lf/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 04:46:48 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Batch Files]]></category>
		<category><![CDATA[DOS]]></category>
		<category><![CDATA[crlf]]></category>
		<category><![CDATA[echo]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=397</guid>
		<description><![CDATA[Recently, I wanted to make a terminal application automatically use the current signed-in Windows user name as the terminal session user name. When I first started on the task, I...]]></description>
			<content:encoded><![CDATA[<p>Recently, I wanted to make a terminal application automatically use the current signed-in Windows user name as the terminal session user name. When I first started on the task, I thought this will be easy; what acclaimed terminal program with heavily definable session settings is not capable of such? Well shoot &#8211; I was mistaken. However, I have never given up on the impossible in the past, and quite frankly this task was definitely not impossible in comparison to other tasks or projects…</p>
<p>As a quick overview to help you understand the problem, each session configuration is kept in individual files located in the \scripts\ folder within the application folder. The session files were not a standard format, such as an INI or XML, and appeared as though the application developer(s) used some proprietary data component for saving session configuration to the hard drive. While reviewing the session files with <a href="http://www.ultraedit.com/" target="_blank">UltraEdit</a>, I noticed that the data values were in standard text format amongst a fog of extended ASCII characters.</p>
<p>Ah ha! Concatenation is the solution…will it be batch file or .NET application?</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2009/10/ilovedos.jpg"><img class="alignnone size-medium wp-image-400" title="ilovedos" src="http://www.devtrends.com/wp-content/uploads/2009/10/ilovedos-300x151.jpg" alt="ilovedos" width="300" height="151" /></a></p>
<p><strong>Gluing the Pieces Together</strong></p>
<p>Runner up, the batch file. I took the session configuration file and cut it right down the middle (where the user name value was), saving one half as session.p1 and the other half as session.p2. The next trick was to glue these files back together with the current Windows user name in between. I grew up using DOS so I thought that this would be easy; I could just echo %USERNAME% to a file, such as:</p>
<pre style="padding-left: 30px;">echo %USERNAME% &gt; session.nam</pre>
<p>Unfortunately, the echo command puts a CR/LF at the end of the file, even though %USERNAME% contains no such characters. Logic would state that since echo is typically used for screen output, it assumes that you want a line feed after your statement. Well, a line feed is going to break my batch file concatenation solution; I can’t have line feeds in a proprietary configuration file!</p>
<p><strong>Solution</strong></p>
<p>After much research, I pieced together a batch file line that echo’s a statement without line feeds! This is a golden nugget for anyone that is trying to solve this problem and it worked quite well in my batch file concatenation solution!</p>
<pre style="padding-left: 30px;">for %%a in (%USERNAME%) do (
echo/|set /p ="%%a"
) &gt; session.nam</pre>
<p>Obviously, you can replace %USERNAME% with any environment variable or text that you want – no quotes required.</p>
<p>Remember that where there is a will to do so, there is a way to accomplish any task.</p>
<p>Aaron Gilbert</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/echo-without-carriage-return-or-line-feed-cr-lf/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

