Go Back   TechArena Community > Software > Operating Systems
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 28-11-2010
Member
 
Join Date: Jul 2010
Posts: 101
How to work with if command and batch file

I am not going to cover the entire the theory and position into practice of batch files commencing the ground up. Several superior book on DOS (at present found in the Antiquities segment of your local library <g>), and numerous of the most excellent on Windows, determine to encompass a section on batch files. Basically position, a batch file is a plaintext file by means of a name ending in.BAT. In its simplest structure, it restrains a series of commands by means of the intention of might be executed commencing a command prompt (system prompt). The batch file basically auto executes them for you. (In actuality, AUTOEXEC.BAT is the most excellent known, and the majority widely utilized, batch file.) To accomplish a batch file, type its name at a command prompt, or accomplish a Windows shortcut by means of the intention of does the similar thing.
Reply With Quote
  #2  
Old 28-11-2010
Member
 
Join Date: Nov 2009
Posts: 1,416
Re: How to work with if command and batch file

The IF command in batch scripting is extremely comparable to the IF statement in additional programming languages. The IF command permits you to take a batch file in one of two methods. If the declaration being tested is TRUE execute the action on by means of the intention of line. If the statement is FALSE persist to the subsequently line. The TRUE achievement statement is then, fundamentally, ignored. A go to statement might perhaps be present on this line to send dispensation of the batch file to an additional location in the script. The IF command is enormous for testing three types of circumstances containing replaceable parameters, system ERRORLEVEL, and it be able to evaluate two strings. Remember by means of the intention of additional than a small number of IF commands be able to be issued to overcome an additional complex tribulations and generate a additional detailed algorithm.
Reply With Quote
  #3  
Old 28-11-2010
Member
 
Join Date: Nov 2009
Posts: 1,292
Re: How to work with if command and batch file

Where does one acquire a register of DOS surroundings variables. I have encompassed by no means found a comprehensive register; additional than a partial additional than lengthy register of existing environment variables be able to be gotten by typing SET at a command prompt. You be able to create them up as you go along, and allocate them as you aspiration (as long as you do not grab one by means of the intention of has a justifiable assigned value, such as, say, %windir%, the Windows directory name). Choose a name, populate it by means of the SET command by several means recognized to you (containing having one batch file run a procedure by means of the intention of contains setting one, and then an additional batch file utilizing it), then utilize it by placing the name between flanking % signs. Environment variables hang regarding until overwritten, or until a reboot.
Reply With Quote
  #4  
Old 28-11-2010
Member
 
Join Date: Nov 2009
Posts: 1,269
Re: How to work with if command and batch file

The ECHO command has additional than a diminutive number of dissimilar uses. MS DOS batch files utilize two echo 'modes'. The defaulting echo mode is ECHO ON. When ECHO is set to ON, each command in the batch file is displayed to the screen previous to it is run. Sometimes this information in sequence is not required, and be able to even be downright irritating for larger batch files. In this mode, the commands are not printed to the display prior to their implementation. As well as the echo modes, the ECHO command is utilized to print a communication to the user. Messages are displayed to the user by previous a line of text by means of ECHO. REM is the MS DOS batch file technique of provided by means of the intention of comments. The REM is supposed to be utilized at the top of each batch file to make available a description and illustration utilize. On the other hand, too numerous REM lines are not an illustration of superior programming style.
Reply With Quote
  #5  
Old 30-11-2010
Member
 
Join Date: Mar 2010
Posts: 567
Re: How to work with if command and batch file

The IF command is utilized in batch files to test whether a circumstance is met or not. This permits the batch file to execute a meticulous action merely if a scrupulous condition is met. There are additional than a small number of dissimilar variations of the IF command this test determine to return true if the file does exist. Subsequent to a program has completed accomplish in MS DOS it returns a value to the operating system indicating its accomplishment or failure. This importance is stored in the changeable ERRORLEVEL. By testing this changeable, a batch file is able to presume the result of the program by means of the intention of immediately finished working. The SHIFT command makes available considerable power to batch files. It permits a batch file to operate on an unidentified number of parameters. The SHIFT command is often utilized in situations where an operation requirements to be performed on several files or directories.
Reply With Quote
  #6  
Old 01-12-2010
Member
 
Join Date: Apr 2010
Posts: 258
Re: How to work with if command and batch file

The Batch files permit MS-DOS and Microsoft Windows users to generate lists of commands to run in succession formerly the batch file has been accomplish. For illustration, a batch file might be utilized to run frequently run commands, eliminating a series of files, shifting files, etc. An uncomplicated batch file does not necessitate several special programming skills and be able to be completed by users who encompass a fundamental understanding of MS-DOS commands. A superior illustration of a batch file for an important person who is additional familiar by means of Windows or the MacOS is to believe of a batch file as a shortcut in Windows or an icon on the MacOS. Much approximating a shortcut, batch files might be utilized to run one or additional commands and/or programs from side to side the command line. An additional illustration of a extremely well recognized batch file is the autoexec.bat, which is a straightforward boot file loaded every time the computer is loaded on MS-DOS and premature Windows computers.
Reply With Quote
Reply

  TechArena Community > Software > Operating Systems
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to work with if command and batch file"
Thread Thread Starter Forum Replies Last Post
FTP Upload batch file doesn't work properly in Task Scheduler supphavith09 Windows Server Help 1 09-02-2012 07:39 AM
stringtokenizer in batch file / dos command sayeed Software Development 2 14-10-2009 01:26 PM
How Sleep command work on Batch file in Windows afidelino Technology & Internet 3 08-07-2009 10:42 AM
Can We check the exit command in the batch file Dhruv Software Development 3 30-12-2008 11:56 PM
Fast User Switching via Command Line or Batch File? Woody45 Vista Help 1 18-03-2007 12:22 AM


All times are GMT +5.5. The time now is 06:37 PM.