<?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>Batch File</title>
	<atom:link href="http://www.batchfile.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.batchfile.org</link>
	<description>Everything You Need To Know About Batch Files</description>
	<lastBuildDate>Sun, 13 May 2012 01:45:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>List of FTP commands</title>
		<link>http://www.batchfile.org/list-of-ftp-commands/</link>
		<comments>http://www.batchfile.org/list-of-ftp-commands/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 17:22:50 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ftp command]]></category>
		<category><![CDATA[ftp command line]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=154</guid>
		<description><![CDATA[! Escape to the shell ? Print local help information append Append to a file ascii Set ASCII transfer type. Use this to transfer text files, such as .htm files. See www.superior-host.com/webhosting-guide/linux-files.html for an excellent discussion of when to use &#8230; <a href="http://www.batchfile.org/list-of-ftp-commands/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>!</strong> Escape to the shell<br />
<strong>?</strong> Print local help information<br />
<strong>append</strong> Append to a file<br />
<strong>ascii</strong> Set ASCII transfer type. Use this to transfer text files, such as .htm files. See www.superior-host.com/webhosting-guide/linux-files.html for an excellent discussion of when to use ascii mode and when to use binary mode.</p>
<p></p>
 <script type="text/javascript"><!--
google_ad_client = "ca-pub-1451989342110900";
/* HedgeFundSoftware Middle */
google_ad_slot = "7948440387";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<p></p>
<p><strong>bell</strong> Beep when command completed<br />
<strong>binary</strong> Set binary transfer type. Use this to transfer binary files such as .exe files and graphics (see also ascii).<br />
<strong>bye</strong> Terminate the FTP session and exit<br />
<strong>cd</strong> Change remote working directory ( use .. to go to parent)<br />
<strong>close</strong> Terminate FTP session<br />
<strong>delete</strong> Delete remote file<br />
<strong>debug</strong> Toggle debugging mode<br />
<strong>dir</strong> List the contents of the remote directory<br />
<strong>disconnect</strong> Terminate the FTP session<br />
<strong>get</strong> Receive file (see also mget)<br />
<strong>glob</strong> Toggle metacharacter expansion of local file names<br />
<strong>hash</strong> Toggle printing &#8216;#&#8217; for each buffer transferred<br />
<strong>help</strong> Prints list of commands<br />
<strong>lcd</strong> Change the local working directory<br />
<strong>literal</strong> Send an arbitrary FTP command<br />
<strong>ls</strong> List contents of remote directory<br />
<strong>mdelete</strong> Delete multiple files<br />
<strong>mdir</strong> List the contents of multiple remote directories<br />
<strong>mget</strong> Get multiple files (see also get)<br />
<strong>mkdir</strong> Make a directory on the remote machine<br />
<strong>mls</strong> List contents of multiple remote directories<br />
<strong>mput</strong> Send multiple files (see also put)<br />
<strong>open</strong> Connect to remote FTP<br />
<strong>prompt</strong> Force interactive prompting on multiple commands (this is a toggle)<br />
<strong>put</strong> Send one file (see also mput)<br />
<strong>pwd</strong> Print working directory on remote machine<br />
<strong>quit</strong> Terminate FTP session and exit<br />
<strong>quote</strong> Send an arbitrary FTP command. You can view a list of raw FTP commands on www.nsftools.com/tips/RawFTP.htm<br />
<strong>recv</strong> Receive file<br />
<strong>remotehelp</strong> Get help from remote server<br />
<strong>rename</strong> Rename a file<br />
<strong>rmdir</strong> Remove a directory on the remote machine<br />
<strong>send</strong> Send one file<br />
<strong>status</strong> Show current status<br />
<strong>trace</strong> Toggle packet tracing<br />
<strong>type</strong> Set file transfer type<br />
<strong>user </strong> Send new user information<br />
<strong>verbose</strong> Toggle verbose mode</p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/list-of-ftp-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference Between COPY and XCOPY</title>
		<link>http://www.batchfile.org/difference-between-copy-and-xcopy/</link>
		<comments>http://www.batchfile.org/difference-between-copy-and-xcopy/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 22:36:17 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[copy batch file]]></category>
		<category><![CDATA[copy vs xcopy]]></category>
		<category><![CDATA[copy vs xcopy batch file]]></category>
		<category><![CDATA[xcopy batch file]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=151</guid>
		<description><![CDATA[COPY does a shallow copy (doesn&#8217;t recurse into sub directories) while XCOPY has the option to do a recursive copy which will copy all files and sub folders within the target folder that you are copying. if you&#8217;re just copying &#8230; <a href="http://www.batchfile.org/difference-between-copy-and-xcopy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>COPY</strong> does a shallow copy (doesn&#8217;t recurse into sub directories) while <strong>XCOPY</strong> has the option to do a recursive copy which will copy all files and sub folders within the target folder that you are copying. if you&#8217;re just copying one single file, either one will suffice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/difference-between-copy-and-xcopy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Disaster Recovery Copy of Your Files in Real Time</title>
		<link>http://www.batchfile.org/create-a-disaster-recovery-copy-of-your-files-in-real-time/</link>
		<comments>http://www.batchfile.org/create-a-disaster-recovery-copy-of-your-files-in-real-time/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 17:57:19 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[backup batch file]]></category>
		<category><![CDATA[backup windows scheduled task]]></category>
		<category><![CDATA[batch file backup]]></category>
		<category><![CDATA[xcopy backup]]></category>
		<category><![CDATA[xcopy batch file]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=149</guid>
		<description><![CDATA[1) Create a batch file with the following code: xcopy /d /s /y &#8220;\\networkPC\e$\foldertobackup&#8221; &#8220;E:\BackupFolder&#8221; 2) Create Windows Scheduled Task 3) Point Windows Scheduled Task to the batch file created in Step 1 4) Make Windows Scheduled Task to run &#8230; <a href="http://www.batchfile.org/create-a-disaster-recovery-copy-of-your-files-in-real-time/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1) Create a batch file with the following code:</p>
<p>xcopy /d /s /y &#8220;\\networkPC\e$\foldertobackup&#8221; &#8220;E:\BackupFolder&#8221;</p>
<p>2) Create Windows Scheduled Task</p>
<p>3) Point Windows Scheduled Task to the batch file created in Step 1</p>
<p>4) Make Windows Scheduled Task to run &#8220;Daily&#8221; starting from 5 am in the morning (before start of the working day)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/create-a-disaster-recovery-copy-of-your-files-in-real-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scheduled Windows (PC) Restart Using DOS command (shutdown.exe)</title>
		<link>http://www.batchfile.org/scheduled-windows-pc-restart-using-dos-command-shutdownexe/</link>
		<comments>http://www.batchfile.org/scheduled-windows-pc-restart-using-dos-command-shutdownexe/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 22:36:51 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[batch file restart pc]]></category>
		<category><![CDATA[scheduled PC restart]]></category>
		<category><![CDATA[shutdown batch file]]></category>
		<category><![CDATA[shutdown.exe]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=144</guid>
		<description><![CDATA[1.Create a batch file “restart.bat” with the following code shutdown -r -t 60 -c &#8220;Rebooting computer&#8221; 2.Create a scheduled task that would execute restart.bat]]></description>
			<content:encoded><![CDATA[<p><span style="color: #1f497d;">1.Create a batch file “restart.bat” with the following code</span> <span style="color: #1f497d;">shutdown -r -t 60 -c &#8220;Rebooting computer&#8221; </span><br />
<span style="color: #1f497d;">2.</span><span style="color: #1f497d;">Create a scheduled task that would execute restart.bat</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/scheduled-windows-pc-restart-using-dos-command-shutdownexe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to execute a &#8220;batch file&#8221; using SQL Server 2005?</title>
		<link>http://www.batchfile.org/how-to-execute-a-batch-file-using-sql-server-2005/</link>
		<comments>http://www.batchfile.org/how-to-execute-a-batch-file-using-sql-server-2005/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 17:03:15 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CmdExec job]]></category>
		<category><![CDATA[xp_cmdshell]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=139</guid>
		<description><![CDATA[One method is with a SQL Server agent CmdExec job step. Another is via xp_cmdshell. If you choose to use xp_cmdshell, be sure you fully understand the security implications and don&#8217;t grant direct execute permissions on the proc. How to: &#8230; <a href="http://www.batchfile.org/how-to-execute-a-batch-file-using-sql-server-2005/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One method is with a SQL Server agent <strong>CmdExec job step</strong>. Another is via <strong>xp_cmdshell</strong>. If you choose to use xp_cmdshell, be sure you fully understand the security implications and don&#8217;t grant direct execute permissions on the proc.</p>
<p><strong>How to: Create a CmdExec Job Step</strong></p>
<p>By default, only members of the <strong>sysadmin</strong> fixed server role can create CmdExec job steps. These job steps run under the context of the SQL Server Agent service account unless the <strong>sysadmin</strong> user creates a proxy account. Users who are not members of the <strong>sysadmin</strong> role can create CmdExec job steps if they have access to a CmdExec proxy account.</p>
<ol>
<li>In <strong>Object Explorer,</strong> connect to an instance of the SQL Server Database Engine, and then expand that instance.</li>
<li>Expand <strong>SQL Server Agent</strong>, create a new job or right-click an existing job, and then click <strong>Properties</strong>.For more information about creating a job.</li>
<li>In the <strong>Job Properties</strong> dialog, click the <strong>Steps</strong> page, and then click <strong>New</strong>.</li>
<li>In the <strong>New Job Step</strong> dialog, type a job <strong>Step name</strong>.</li>
<li>In the <strong>Type</strong> list, choose <strong>Operating system (CmdExec)</strong>.</li>
<li>In <strong>Run as</strong> list, select the proxy account with the credentials that the job will use. By default, CmdExec job steps run under the context of the SQL Server Agent service account.</li>
<li>In the <strong>Process exit code of a successful command</strong> box, enter a value from 0 to 999999.</li>
<li>In the <strong>Command</strong> box, enter the operating system command or executable program.</li>
<li>Click the <strong>Advanced</strong> page to set job step options, such as: what action to take if the job step succeeds or fails, how many times SQL Server Agent should try to execute the job step, and the file where SQL Server Agent can write the job step output. Only members of the <strong>sysadmin</strong> fixed server role can write job step output to an operating system file.</li>
</ol>
<p><strong>What is XP_CMDSHELL</strong></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">&#8220;xp_cmdshell&#8221; is an <span style="color: #ff0000;"><strong>extended stored procedure</strong></span> provided by Microsoft and stored in the master database. This procedure allows you to <span style="color: #0000ff;">issue operating system commands directly to the Windows command shell via T-SQL</span> code. If needed the output of these commands will be returned to the calling routine.</span></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Only users in </span></span><strong><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">sysadmin role </span></span></strong><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">can</span></span><strong><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"> </span></span></strong><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">execute xp_cmdshell stored procedures</span></span><strong><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">.</span></span></strong></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">If a login executing this extended stored procedure is a member of the sysadmin role then the submitted command will run under the security context associated with the SQL Server Service account in which it runs.</span></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><strong><span style="color: #ff0000;">By default XP_CMDSHELL is turned off in SQL Server 2005</span></strong></span></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><strong><span style="color: #0000ff;">TO ENABLE XP_CMDSHELL run this code:</span></strong></span></span></p>
<p><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="color: #0000ff;">EXECUTE sp_configure &#8216;show advanced options&#8217;, 1<br />
RECONFIGURE WITH OVERRIDE<br />
GO<br />
EXECUTE sp_configure &#8216;xp_cmdshell&#8217;, &#8217;1&#8242;<br />
RECONFIGURE WITH OVERRIDE<br />
GO<br />
EXECUTE sp_configure &#8216;show advanced options&#8217;, 0<br />
RECONFIGURE WITH OVERRIDE<br />
GO<br />
</span></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/how-to-execute-a-batch-file-using-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start .EXE, .BAT or .COM file from batch file</title>
		<link>http://www.batchfile.org/start-exe-bat-or-com-file-from-batch-file/</link>
		<comments>http://www.batchfile.org/start-exe-bat-or-com-file-from-batch-file/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 17:33:29 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=137</guid>
		<description><![CDATA[If you want the start command to run the MENU.EXE file that&#8217;s located in say the root directory of drive C:, you would type: start c:\menu.exe If you want the start command to run the MENU.BAT file that&#8217;s also located &#8230; <a href="http://www.batchfile.org/start-exe-bat-or-com-file-from-batch-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you want the start command to run the MENU.EXE file that&#8217;s located in say the root directory of drive C:, you would type:</p>
<p><span style="color: #0000ff;">start c:\menu.exe</span></p>
<p>If you want the start command to run the MENU.BAT file that&#8217;s also located in the root directory of drive C:, you would type:</p>
<p><span style="color: #0000ff;"> start c:\menu.bat</span></p>
<p>If you had a MENU.EXE, MENU.BAT and a MENU.COM all located in the same directory and you didn&#8217;t specify which one you wanted to run, like so:</p>
<p><span style="color: #0000ff;"> start c:\menu</span></p>
<p>DOS would start the MENU.COM file. If MENU.COM didn&#8217;t exist it would start the MENU.EXE file. If MENU.EXE didn&#8217;t exist it would start the MENU.BAT file. In other words, if you don&#8217;t specify which one you want to run, DOS looks for .COM files first, then .EXE then .BAT. To keep it from doing this, simply specify which one you want DOS to run, i.e.,</p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/start-exe-bat-or-com-file-from-batch-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DOS/Batch Commands/Functions Descriptions</title>
		<link>http://www.batchfile.org/dosbatch-commandsfunctions-descriptions/</link>
		<comments>http://www.batchfile.org/dosbatch-commandsfunctions-descriptions/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 15:01:39 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[DOS Functions]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=132</guid>
		<description><![CDATA[DEL and ERASE In Windows NT, the DEL and ERASE commands are much more powerful than they are in other versions of MS-DOS and Windows. Although the basic syntax remains the same, Windows NT offers several switches that allow DEL &#8230; <a href="http://www.batchfile.org/dosbatch-commandsfunctions-descriptions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>DEL and ERASE</strong></p>
<p>In Windows NT, the DEL and ERASE commands are much more powerful than they are in other versions of MS-DOS and Windows. Although the basic syntax remains the same, Windows NT offers several switches that allow DEL to behave like the DELTREE command. Using the appropriate switches, it&#8217;s also possible to delete files with specified attributes. You can even make the deletion process confirm a delete, or make the deletion process invisible. You can find out all of the details by typing del /? at the command prompt.</p>
<p><strong>COLOR</strong></p>
<p>Tired of that boring black and gray command prompt? You can use the COLOR command to make your batch files look more like professional programs. To do so, simply use the COLOR command followed by two hexadecimal numbers. For example, the command COLOR 17 makes the screen blue with white writing. You can choose from 16 colors, each of which can be used in the foreground or the background. To see a list of available colors and their corresponding numbers, type color /? at the command prompt.<br />
<strong></strong></p>
<p><strong>CD and CHDIR</strong></p>
<p>Windows NT contains enhanced versions of the CD and the CHDIR commands. Although both commands employ the usual syntax, two enhancements are worth mentioning. First, you can add the \D parameter to change drives as well as directories. This parameter could save you a few lines in a batch file. For example, the command:</p>
<p><strong>CD /D E:\DATA </strong></p>
<p>does the same thing as the following set of commands:</p>
<p><strong>E:<br />
CD\DATA</strong></p>
<p>The commands have also been modified to enable extra support for directory names that contain spaces. For example, in the past, if you wanted to change to the \My Documents directory, you had to type cd &#8220;\My Documents.&#8221; With the enhanced commands, it&#8217;s now possible to enter the command without the quotation marks.</p>
<p><strong>MD and MKDIR</strong></p>
<p><strong></strong>The MD and MKDIR commands have been enhanced to save you a lot of work. Now, you can create large directory structures with a single command. For example, now you can type a command such as:</p>
<p><span style="color: #0000ff;">MD \DATA1\DATA2\DATA3\DATA4</span></p>
<p>In the past, you had to create the DATA1, DATA2, and DATA3 directories manually before you could create the DATA4 directory. The command we just typed creates them all at once. For example, the command:</p>
<p><span style="color: #0000ff;">MD \DATA1\DATA2\DATA3\DATA4 </span></p>
<p>takes the place of the following lines:</p>
<p><span style="color: #0000ff;">CD\MD DATA1<br />
CD DATA1<br />
MD DATA2<br />
CD DATA2<br />
MD DATA3<br />
CD DATA3<br />
MD DATA4<br />
CD\</span></p>
<p><strong>PROMPT</strong></p>
<p>You&#8217;re probably already familiar with the PROMPT command and some of its attributes. For example, the command PROMPT $P$G displays the drive letter and the current path as the prompt. This command has become standard in recent years. However, Windows NT provides additional attributes that let you display things like the current time, the Windows NT version number, or—more importantly—the full network path. You can learn more about the PROMPT command by typing prompt /? at the command prompt.</p>
<p><strong>PUSHD and POPD</strong></p>
<p><strong></strong>The PUSHD and POPD commands work together. PUSHD captures the name of the current directory. You can also add the name of a directory that you would like to change to. For example, the command PUSHD \DATA1 will switch you to the DATA1 directory (but remember the name of the directory you&#8217;re currently in). To automatically return to this directory, simply type POPD.</p>
<p><strong>SET</strong></p>
<p><strong></strong>You&#8217;re probably already familiar with the SET command, which you use to assign a particular value to an environment variable. For example, the command:</p>
<p><span style="color: #0000ff;">SET TEMP=C:\TEMP </span></p>
<p>would assign the value C:\TEMP to the variable TEMP. In Windows NT, the SET command has been greatly enhanced to let you perform such actions as combining strings or separating parts of a string. For example, it&#8217;s now possible to take a string, strip off the first five characters, and copy the next seven characters to another variable. Although space doesn&#8217;t permit us to discuss all of the intricacies of the SET command in this article, you can find out more about it by typing set /? at the command prompt.</p>
<p><strong>SETLOCAL and ENDLOCAL</strong></p>
<p><strong></strong>The SETLOCAL and ENDLOCAL commands are used together. When you use the SETLOCAL command within a batch file, any environment changes you make after that point are local to the batch file. For example, if you used the SETLOCAL command followed by the:</p>
<p><span style="color: #0000ff;">SET TEMP=C:\TEMP</span></p>
<p>command, the batch file would recognize the TEMP variable as containing the string C:\TEMP. However, if you were to run a different batch file or open a different MS-DOS Window, the TEMP variable wouldn&#8217;t contain this string. To prevent future environment variable changes from being local, you can use the ENDLOCAL command.</p>
<p><strong>IF</strong></p>
<p>The IF command works similarly to the way that it does in MS-DOS or in other versions of Windows. You can still compare error levels and strings and check to see if a filename exists. The NOT parameter also still works. However, where the new and improved IF command really shines is in the added enhancements. For example, when comparing strings, you can now test to see if they&#8217;re equal, not equal, less than, less than or equal to, greater than, or greater than or equal to. There&#8217;s even a switch you can use to make the comparison case sensitive or case insensitive. Furthermore, IF now includes a DEFINED command that returns a TRUE value if an environment variable has already been defined. As you can see, the added capabilities of the IF command can greatly enhance your batch files. If you want to know more about the IF command, type if /? at the command prompt.</p>
<p><strong>FOR</strong></p>
<p><strong></strong>The FOR command still supports the same parameters that it always has, enabling you to test for and act on the presence of a string in a group of files. However, Windows NT contains several enhancements to this command. For example, you can now work with directories or directory trees instead of just files. You can also work with counters. For example, if you wanted to test for even numbers between 16 and 128, you could use the FOR command to do so. There are even some advanced commands for parsing files and filtering out or changing data. You can read all about these enhancements by typing for /? at the command prompt.</p>
<p><strong>CALL</strong></p>
<p><strong></strong>The CALL command allows your current batch file to pass information to and execute another batch file. The CALL command now supports several labels that you can use to pass specific information such as a drive letter, a path name, file names and extensions, and other information. You can read all about the CALL command by typing call /? at the command prompt.</p>
<p><strong>SHIFT</strong></p>
<p><strong></strong>The SHIFT command changes the position of arguments within a batch file. You can even specify the position to which you want to begin shifting the arguments. For example, typing SHIFT /2 begins shifting positions after the second argument. You can shift values in the first (%0) through ninth (%8) positions.</p>
<p><strong>GOTO</strong></p>
<p><strong></strong>If you&#8217;ve ever written a batch file that had several different sections that could execute depending on the value of a variable, you&#8217;re probably familiar with the GOTO command. However, in the past, it&#8217;s always been necessary to create a label at the bottom of the file and add a statement to each section to go to this label. Doing so prevents other sections of the file from running when they aren&#8217;t supposed to. Figure D shows an example of such a file. Notice how each section of the batch file ends by calling the END section. The END section doesn&#8217;t actually contain any instructions, but we still had to include it so our batch file would execute properly. However, Windows NT allows you to call a label called EOF without actually creating an EOF section. When the command interpreter reaches such a statement, it ends the batch file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/dosbatch-commandsfunctions-descriptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run a specified program only on certain days at boot time.</title>
		<link>http://www.batchfile.org/run-a-specified-program-only-on-certain-days-at-boot-time/</link>
		<comments>http://www.batchfile.org/run-a-specified-program-only-on-certain-days-at-boot-time/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:36:09 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Batch File Examples]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=128</guid>
		<description><![CDATA[This demo makes use of two tricks: It reads a custom INI file, and it puts the current day into the environment. @echo off :: This batch file allows you to run programs on certain days. :: Have this TODAY.BAT &#8230; <a href="http://www.batchfile.org/run-a-specified-program-only-on-certain-days-at-boot-time/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This demo makes use of two tricks: It reads a custom INI file, and it puts the current day into the environment.</p>
<p><span style="color: #0000ff;">@echo off<br />
:: This batch file allows you to run programs on certain days.<br />
:: Have this TODAY.BAT program CALLed from your AUTOEXEC.BAT.<br />
:: TODAY.BAT will read entries in a TODAY.INI file you must make.<br />
:: The entries in the TODAY.INI should look like this:<br />
:: 10-12-1999=DeleteOldDocs.bat<br />
:: 10-13-1999=Scandisk.bat<br />
:: 10-14-1999=PrintReports.bat</span></p>
<p><span style="color: #0000ff;">:: Put the date into the DATE environment variable<br />
:: Response to DATE command should be like<br />
:: Current date is Sun 10-12-1997<br />
:: Enter new date (mm-dd-yy):<br />
@echo.|date|find /i &#8220;current&#8221;&gt;#urrent.bat<br />
@echo set date=%%4&gt;current.bat<br />
call #urrent.bat<br />
del ?urrent.bat</span></p>
<p><span style="color: #0000ff;">:: Put the command for today into TODAYSCOMMAND variable<br />
:: Assumes existence of TODAY.INI in current directory<br />
find &#8220;%date%=&#8221; today.ini | sort /r | date | find &#8220;=&#8221; &gt; en#er.bat<br />
@echo set todayscommand=%%5&gt; enter.bat<br />
call en#er.bat<br />
del en?er.bat &gt; nul</span></p>
<p><span style="color: #0000ff;">:: Cleanup &#8211; delete DATE variable and INI entry (so it only runs once)<br />
type today.ini|find /v &#8220;%date%&#8221;&gt;today.ini<br />
set date=</span></p>
<p><span style="color: #0000ff;">:: Run today&#8217;s command<br />
call %todayscommand%<br />
set todayscommand=</span></p>
<p><span style="color: #0000ff;">:: _____________________________________________________<br />
:: If the command for the day requires user input, for<br />
:: example, you have to hit enter or answer yes or no,<br />
:: you should run a separate batch file instead of<br />
:: running the command directly. Assume you want to run<br />
:: CHKDSK with the /F option to fix errors. If it finds<br />
:: errors, it will ask you to type &#8220;y&#8221; or &#8220;n&#8221;.  You can<br />
:: create a batch file which will do this for you:<br />
:: ECHO Y|CHKDSK /F<br />
:: If all you need is to press &#8220;Enter&#8221;, you can do this:<br />
:: ECHO.|CHKDSK /F<br />
:: If you need to press &#8220;y&#8221;, AND THEN HIT &#8220;Enter&#8221;, it<br />
:: gets more complicated. You have to create what is<br />
:: generally called a &#8220;script&#8221; containing the exact<br />
:: keystrokes you need to press. You can create it<br />
:: ahead of time, or as needed like this:<br />
:: ECHO Y&gt;SCRIPT.TXT<br />
:: ECHO.&gt;&gt;SCRIPT.TXT<br />
:: TYPE SCRIPT.TXT|CHKDSK /F<br />
:: Notice the first line had only one &#8220;&gt;&#8221;, but the<br />
:: second line had two &#8220;&gt;&gt;&#8221;. Just one will cause<br />
:: the SCRIPT.TXT to be created new (if it already<br />
:: exists, it will be erased to start over fresh).<br />
:: The two &gt;&gt; will cause things to be appended to<br />
:: the existing SCRIPT.TXT</span></p>
<p>Have your batch file send the desired answer..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/run-a-specified-program-only-on-certain-days-at-boot-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Have your batch file to anser &#8220;Do you really want to do this?&#8221; prompt.</title>
		<link>http://www.batchfile.org/have-your-batch-file-to-anser-do-you-really-want-to-do-this-prompt/</link>
		<comments>http://www.batchfile.org/have-your-batch-file-to-anser-do-you-really-want-to-do-this-prompt/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:33:19 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Batch File Examples]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=125</guid>
		<description><![CDATA[If you find yourself trying to automate the deletion of files, the formatting of floppies, or do anything else REALLY INTERESTING, you&#8217;re going to hit a spot where everything stops and you get asked &#8220;Are you sure?&#8221;. Sometimes you can &#8230; <a href="http://www.batchfile.org/have-your-batch-file-to-anser-do-you-really-want-to-do-this-prompt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you find yourself trying to automate the deletion of files, the formatting of floppies, or do anything else REALLY INTERESTING, you&#8217;re going to hit a spot where everything stops and you get asked &#8220;Are you sure?&#8221;. Sometimes you can pass a &#8220;/y&#8221; on the command line (like the COPY command) to override this, but that&#8217;s the exception. <span style="color: #0000ff;"><strong>Often, you can simply ECHO the key you&#8217;ll need to press into the command.</strong></span> As an example, suppose you want to run CHKDSK with the /F option to fix errors. If it finds errors, it will ask you to type &#8220;y&#8221; or &#8220;n&#8221;.  You can create a batch file which will do this for you:</p>
<p>&#8212;&#8212;&#8212;&#8212;<br />
<span style="color: #0000ff;">ECHO Y|CHKDSK /F </span><br />
&#8212;&#8212;&#8212;&#8212;</p>
<p>If all you needed to do was to <span style="color: #0000ff;"><strong>press &#8220;Enter&#8221;</strong></span>, you could do this:</p>
<p>&#8212;&#8212;&#8212;&#8212;<br />
<span style="color: #0000ff;">ECHO.|CHKDSK /F </span><br />
&#8212;&#8212;&#8212;&#8212;</p>
<p>If you need to press &#8220;y&#8221;, AND THEN HIT &#8220;Enter&#8221;, it gets more complicated. You have to create what is generally called a &#8220;script&#8221; containing the exact keystrokes you need to press. You can create it  ahead of time, or as needed like this:</p>
<p>&#8212;&#8212;&#8212;&#8212;<br />
<span style="color: #0000ff;">ECHO Y&gt;SCRIPT.TXT<br />
ECHO.&gt;&gt;SCRIPT.TXT<br />
TYPE SCRIPT.TXT|CHKDSK /F </span><br />
&#8212;&#8212;&#8212;&#8212;</p>
<p>I use CHKDSK above because it is harmless as an example, not because it works. If I told people how to format their hard drives, some people would type in the code to test it. CHKDSK hasn&#8217;t been a usable command since Windows 95. The technique is correct though!</p>
<p>Use the &#8220;pipe&#8221; character &#8220;|&#8221; (the vertical bar) to send the output from a command into the input of another command.</p>
<p>For example:<br />
<span style="color: #0000ff;">type test.txt | program.exe</span></p>
<p>That would send the output of the &#8220;type&#8221; command into the input of the &#8220;program.exe&#8221; command. The &#8220;type&#8221; command in this case would be putting out the contents of the file &#8220;test.txt&#8221;. The &#8220;program.exe&#8221; would (in theory) accept that as it&#8217;s input instead of accepting input from the keyboard.</p>
<p>Use <strong>redirection characters</strong> <span style="color: #ff0000;">&#8220;&gt;&#8221; </span>and<span style="color: #ff0000;"> &#8220;&lt;&#8221;</span> to <span style="color: #ff0000;">send output between files and programs</span>. Notice the difference? The <strong><span style="text-decoration: underline;"><span style="color: #ff0000;">pipe</span></span> <span style="color: #ff0000;">sends stuff between two PROGRAMS</span></strong>. <span style="color: #0000ff;"><strong><span style="text-decoration: underline;">Redirection</span> is between a program and a FILE</strong></span>. The redirection arrow lets you know what direction the data is flowing.</p>
<p>For example:<br />
<span style="color: #0000ff;">program.exe &gt; test.txt</span></p>
<p>would take the output of &#8220;program.exe&#8221; and put it in the file &#8220;test.txt&#8221; INSTEAD of displaying it on the screen. The data flows out of the program &#8220;program.exe&#8221; and into the file &#8220;test.txt&#8221;. On the other hand:</p>
<p><span style="color: #0000ff;">program.exe &lt; test.txt</span></p>
<p>Would cause &#8220;program.exe&#8221; to use &#8220;test.txt&#8221; as it&#8217;s input INSTEAD of taking input from the keyboard. The dat flows out of the file &#8220;test.txt&#8221; into the program &#8220;program.exe&#8221;.</p>
<p>So these two lines are <span style="color: #ff0000;">different ways of doing the same thing</span>:</p>
<p><span style="color: #0000ff;">type test.txt | program.exe</span></p>
<p><span style="color: #0000ff;">program.exe &lt; test.txt</span></p>
<p>The both end up &#8220;program.exe&#8221; to use the data in &#8220;test.txt&#8221; for input instead of using the keyboard.</p>
<p>The difference between<span style="color: #ff0000;"><strong> &#8220;&gt;&#8221; </strong></span>and <span style="color: #ff0000;"><strong>&#8220;&gt;&gt;&#8221;</strong></span> is that <span style="color: #0000ff;"><strong>&#8220;&gt;&#8221; normally creates a new file</strong></span>, replacing what was there, while <span style="color: #ff0000;"><strong>&#8220;&gt;&gt;&#8221; just adds to the end of the file</strong></span> (If the file doesn&#8217;t already exist, it will be created).</p>
<p>You can even use redirection in non-intuitive order and it still works. For example, these two lines do the same thing:</p>
<p><span style="color: #0000ff;">program.exe &gt; test.txt<br />
&gt; test.txt program.exe</span></p>
<p>Looks cute, but it&#8217;s confusing, huh? Stick with the normal way.</p>
<p>So now you know enough to try redirecting or piping into the program that stops in DOS and asks questions.</p>
<p>HOWEVER &#8212; Sometimes programs will clear the keyboard buffer before they ask for user input. This has the effect of ignoring everything you pipe or redirect into the program! If that&#8217;s the case, you have to fall back to using a separate keyboard sinulator program to type the needed keys in.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/have-your-batch-file-to-anser-do-you-really-want-to-do-this-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get user input from batch file</title>
		<link>http://www.batchfile.org/get-user-input-from-batch-file/</link>
		<comments>http://www.batchfile.org/get-user-input-from-batch-file/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:22:45 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Batch File Examples]]></category>

		<guid isPermaLink="false">http://www.batchfile.org/?p=122</guid>
		<description><![CDATA[Sure, you&#8217;ve done it, but can you do it without having to hit a Ctrl-Z, without ANSI, without a debug script, and without a separate &#8220;set&#8221; file? rem&#160; This batch file gets a character or word of user input and &#8230; <a href="http://www.batchfile.org/get-user-input-from-batch-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sure, you&#8217;ve done it, but can you do it without having to hit a Ctrl-Z, without ANSI, without a debug script, and without a separate &#8220;set&#8221; file?</p>
<p><span mce_style="color: #0000ff;" id="" style="color: rgb(0, 0, 255);">rem&nbsp; This batch file gets a character or word of user input and<br />
rem&nbsp; returns it in the environment variable VALUE. Two tricks are<br />
rem&nbsp; used to accomplish this:<br />
rem<br />
rem&nbsp; (1) The FC (File Compare) command is used to compare two standard<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; devices &#8212; NUL (nothing) and CON (the console). The /LB1 option<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is used to insure only one line is compared, and the /N numbers<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; that output line with a &#8220;1:&#8221;, making it easier for us to find.<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FC will output immediately after the user hits &#8220;Enter&#8221; (because<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of the /LB1), and will give us a total of 7 lines of output.<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Of these 7 lines, the one starting with &#8220;1:&#8221; is the one we want.<br />
rem<br />
rem&nbsp; (2) The DATE command is used only because it always returns the<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; phrase &#8220;Enter new date (mm-dd-yy): &#8221; followed by whatever was<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; piped into it. Why is this format important?&nbsp; Obviously, it<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; has nothing to do with setting the date!&nbsp; Well, we will be<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; piping it into a batch file and running it. When that batch<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file runs, it will try to execute the first word (Enter) as if<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it were a valid command, and pass everything else as arguments.<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Since we have created a valid (batch file) command called ENTER,<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this will actually work! We just have to make sure that ENTER.BAT<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is set up to handle the arguments that will be passed to it!</span></p>
<p><span style="color: rgb(0, 0, 255);" mce_style="color: #0000ff;">echo This is a test. Please enter &#8220;y&#8221; or &#8220;n&#8221;<br />
fc con nul /lb1 /n | date | find &#8220;1:&#8221; &gt; en#er.bat<br />
echo set value=%%5&gt; enter.bat<br />
call en#er.bat<br />
del en?er.bat &gt; nul<br />
if &#8220;%value%&#8221;==&#8221;n&#8221; echo You entered &#8220;n&#8221;<br />
if &#8220;%value%&#8221;==&#8221;y&#8221; echo You entered &#8220;y&#8221;<br />
set value=</span></p>
<p><span mce_style="color: #0000ff;" id="" style="color: rgb(0, 0, 255);">rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; See PC Magazine V14N12 June 27, 1995 page 248 for further<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; information. The PC Magazine article suggests using a<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; permanent ENTER.BAT which can accept a line<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of user input (complete with spaces between words!).<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; My version is meant to be inserted into any batch file<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and will create a simple one-line temporary ENTER.BAT in<br />
rem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the default directory and on the fly as needed.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.batchfile.org/get-user-input-from-batch-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

