The idea is to show how simple they are and to intrigue readers to look further into the subject. Even more powerful batch files can be constructed with the addition of simple decision making and methods of doing the same thing many times. Branching with "If" and "Goto" are discussed next ; using "For" to do repetitive tasks is considered on a third page. Batch files are discussed in many books on Windows, at numerous Web sites and at this Microsoft site.
Even if you do not want to write them, there are many already available for your use. This page at a sister site lists a number of sources.
Batch Files Scripts in Windows. By Vic Laurie. Batch files or scripts are small easy-to-write text files that carry out a series of commands. They can be simple enough that even the average home computer user can take advantage of them. What is a batch file? These are simple text files containing some lines with commands that get executed in sequence, one after the other. Files of this type are recognized and executed through an interface sometimes called a shell provided by a system file called the command interpreter.
In the following discussion it is assumed that the Introductory page and the page on Commands have been read.
Back to top Next: Branching and looping. To write your own batch file, all you need is an ordinary text editor. But you do need to know common system commands and understand how they work in batch files. Here are the most important commands to learn:. For a complete list of the most important commands, see our comprehensive article on batch commands. An easy introduction to the art of creating batch files is to write a simple script that creates multiple directories on a selected disk on your computer.
To save these batch instructions or the script, click File and choose Save As Specify the save location and enter a name for the script with the extension.
After you create and save the batch file, you have two options to run it: Either run the script in the familiar Windows Explorer environment or open Command Prompt and run it using a command-line command. The first option is simpler and easier for beginners because all you have to do is go to the directory where the batch file is located and double-click to run it.
If a batch script contains commands that require administrator privileges to execute, you have to run the script as an administrator. You can customize a batch script at any time , for example if you want to add or remove commands or modify directories. To do this, simply go to the folder containing the command line script and right-click it.
Then choose Edit :. With the above step-by-step guide, you can create a wide variety of batch files with an unlimited number of different commands. However, scripts that you can use more frequently are definitely more useful in the long run.
The following example shows how useful batch files can be for creating regular back-ups of any directory:. The three parameters at the end have the following effect:. The above backup program allows you to copy the source files from the source folder to the destination folder. Rasdial The rasdial command is used to start or end a network connection for a Microsoft client.
Rcp The rcp command is used to copy files between a Windows computer and a system running the rshd daemon. Rd The rd command is the shorthand version of the rmdir command. Recover The recover command is used to recover readable data from a bad or defective disk. Reg The reg command is used to manage the Windows Registry from the command line. The reg command can perform common registry functions like adding registry keys, exporting the registry, etc.
Regini The regini command is used to set or change registry permissions and registry values from the command line. Relog The relog command is used to create new performance logs from data in existing performance logs. Rem The rem command is used to record comments or remarks in a batch or script file.
Ren The ren command is the shorthand version of the rename command. Rename The rename command is used to change the name of the individual file that you specify. Replace The replace command is used to replace one or more files with one or more other files. Reset The reset command, executed as reset session , is used to reset the session subsystem software and hardware to known initial values.
Rexec The rexec command is used to run commands on remote computers running the rexec daemon. Rmdir The rmdir command is used to delete an existing and completely empty folder. Route The route command is used to manipulate network routing tables. Rsh The rsh command is used to run commands on remote computers running the rsh daemon. Rsm The rsm command is used to manage media resources using Removable Storage. Runas The runas command is used to execute a program using another user's credentials.
Rwinsta The rwinsta command is the shorthand version of the reset session command. Sc The sc command is used to configure information about services. The sc command communicates with the Service Control Manager. Schtasks The schtasks command is used to schedule specified programs or commands to run a certain times. The schtasks command can be used to create, delete, query, change, run, and end scheduled tasks. Sdbinst The sdbinst command is used to deploy customized SDB database files.
Secedit The secedit command is used to configure and analyze system security by comparing the current security configuration to a template. Set The set command is used to enable or disable certain options in Command Prompt. Setlocal The setlocal command is used to start the localization of environment changes inside a batch or script file.
The setver command is not available in bit versions of Windows XP. Sfc The sfc command is used to verify and replace important Windows system files. Shift The shift command is used to change the position of replaceable parameters in a batch or script file. Shutdown The shutdown command can be used to shut down, restart, or log off the current system or a remote computer. Sort The sort command is used to read data from a specified input, sort that data, and return the results of that sort to the Command Prompt screen, a file, or another output device.
Start The start command is used to open a new command line window to run a specified program or command. The start command can also be used to start an application without creating a new window. Subst The subst command is used to associate a local path with a drive letter.
The subst command is a lot like the net use command except a local path is used instead of a shared network path. Systeminfo The systeminfo command is used to display basic Windows configuration information for the local or a remote computer.
Taskkill The taskkill command is used to terminate a running task. The taskkill command is the command line equivalent of ending a process in Task Manager in Windows. Telnet The telnet command is used to communicate with remote computers that use the Telnet protocol. Time The time command is used to show or change the current time. Title The title command is used to set the Command Prompt window title.
Tlntadmn The tlntadmn command is used to administer a local or remote computer running Telnet Server. Tracerpt The tracerpt command is used to process event trace logs or real-time data from instrumented event trace providers. Tracert The tracert command is used to show details about the path that a packet takes to a specified destination. Tree The tree command is used to graphically display the folder structure of a specified drive or path.
Tscon The tscon command is used to attach a user session to a Remote Desktop session. Tsdiscon The tsdiscon command is used to disconnect a Remote Desktop session. Tskill The tskill command is used to end the specified process. Tsshutdn The tsshutdn command is used to remotely shut down or restart a terminal server. Type The type command is used to display the information contained in a text file. Typeperf The typeperf command displays performance data in the Command Prompt window or writes the data to specified log file.
Unlodctr The unlodctr command removes Explain text and Performance counter names for a service or device driver from the Windows Registry. Ver The ver command is used to display the current Windows version. Verify The verify command is used to enable or disable the ability of Command Prompt to verify that files are written correctly to a disk. Vol The vol command shows the volume label and serial number of a specified disk, assuming this information exists.
Vssadmin The vssadmin command starts the Volume Shadow Copy Service administrative command line tool which displays current volume shadow copy backups and all installed shadow copy writers and providers. W32tm The w32tm command is used to diagnose issues with Windows Time. Xcopy The xcopy command can copy one or more files or directory trees from one location to another. Was this page helpful? Thanks for letting us know! Email Address Sign up There was an error. Please try again.
You're in! Thanks for signing up. There was an error. Tell us why! More from Lifewire. How to Open Command Prompt Windows 10, 8, 7, etc. How to Open an Elevated Command Prompt. Your Privacy Rights. To change or withdraw your consent choices for Lifewire.
At any time, you can update your settings through the "EU Privacy" link at the bottom of any page. These choices will be signaled globally to our partners and will not affect browsing data. We and our partners process data to: Actively scan device characteristics for identification. I Accept Show Purposes. The append command can be used by programs to open files in another directory as if they were located in the current directory.
The arp command is used to display or change entries in the ARP cache. The assoc command is used to display or change the file type associated with a particular file extension. The at command is used to schedule commands and other programs to run at a specific date and time. The atmadm command is used to display information related to asynchronous transfer mode ATM connections on the system.
Ross Ridge Marcus Leon Marcus Leon Add a comment. Active Oldest Votes. Nick Fortescue Nick Fortescue Namely: It doesn't restrict the user to entering a valid value The user has to press enter You have to check for casing differences e.
James Messinger James Messinger 3, 2 2 gold badges 23 23 silver badges 15 15 bronze badges. At least, my machines have it and I'm pretty certain I didn't put it there myself. You are correct aphoria, mine has choice. The link to the DOS 6. While I can't say this test system is "typical", my tests were sufficiently thorough such that this answer seems not viable in some scenarios.
Snake Snake 21 1 1 bronze badge.
0コメント