Comment In A Batch File

Posted on

Displaying Information in Batch FilesBy default, batch files display or echo every line inside them to the Command Prompt window as they run. For complex batch files, this can be very distracting, as page after page of commands and messages scroll. It's hard to read, and you may miss important error messages buried in the middle of the mess. Therefore, it's traditional to disable batch file echoing with the statement@echo offat the very beginning of the file. Echo off turns off the echoing feature, and the @ at the beginning of the command prevents the echo command itself from being echoed before it can work its magic. TIPWhen you're debugging a batch file, it can be helpful to leave echoing turned on so that you can see what commands are being run.

  1. Batch Script Comment

To turn echoing on temporarily, add rem so that the batch file's first line readsrem @echo offRem turns this line into a comment. You can remove it later when the batch file is working correctly.However, it's nice to have batch files tell you what's going on inside so that you'll know that something is actually happening. The echo command is great for this—it echoes whatever text follows the word echo, so you can throw helpful comments throughout the batch file like this:@echo offecho Starting to sort files.echo Sending results to the printer.echo Done. TIPSometimes it's nice to see exactly how a program is going to be run by a batch file, especially when the program's command line is constructed on-the-fly with environment variables and arguments. To do this, put @echo on just before the program's command line and @echo off just after it. This way, CMD will display the actual command line as it runs the program.You can also have echo commands display the environment variables and command-line arguments with which the program is working.

For example,echo Your user name is%username%will print Your user name is followed by the contents of the username environment variable. I'll show examples of this kind of informational message throughout the chapter.

In a previous tip, I showed you how to at once.That batch file works great if you want the same applications to always open at once.But, what if you have a number of applications that you use frequently, and only want to choose from a list, a certain combination of applications to open at the same time?For example, you have a book report due and you need to research the material on the Internet. In this case you want to open Microsoft Word and Firefox.Or, it's time to pay the bills, and you need to open Notepad, Calculator and Microsoft Excel.To do this we can create a batch file with a list of applications.

When you run the batch file, a menu will appear that will accept user input from the command line and open the applications that you choosen (as shown in above screen shot). Hi any one who can help me withI am looking to open this as one of the options in the.bat file.The locatio of the file isC:Program FilesFS ProductsDLH Virtual Groups Custom ACARSkACARS – DLH Virtual.exeThe below listed is not working to open the file@echo offcls:startecho.echo 1. DLH ACARSecho 2. Calculatorecho 3. Microsoft Wordecho 4. Microsoft Excelecho 5.

Comment

Internet Explorerecho 6. Firefoxecho info. To exit type 7 and enterecho.echo.set /p x=Pick:IF '%x%' '%x%' GOTO Item%x%:Item1start /MIN /D C:Program Files'FS Products'DLH Virtual Groups Custom ACARS' 'kACARS – DLH Virtual.exe'GOTO Start. As per suggestion I m done same. List are showing, But while choose the number some error comes ' This command or syntax is incorrect.'

Here I am sending my syntax, please check & rectified any doing any wrong.@echo offtitle Wings:startclsecho.echo Select Options:echo ————–echo.echo 1. Notepadecho 2.

File

Batch Script Comment

Calculatorecho.echo.set /p var=Pick:IF '%var%'var' GOTO Item%var%:Item1start /MIN /D%windir%system32notepad.exeGOTO Start:Item2start /MIN /D%windir%system32calc.exeGOTO Startexit.