View Full Version : How do I put comments in the autoexec.bat file?
Sid Alam
09-19-2002, 07:41 AM
How do I put comments in the autoexec.bat file?
classicsoftware
09-19-2002, 11:01 AM
Use the word REM before any comments line
Sample Autoexec.bat file
@ echo off
cls
files=50
buffers=40
REM set system path (this is a comment line)
path=c:\;c:\windows
Sid Alam
09-19-2002, 04:43 PM
@ echo off
cls
files=50
buffers=40
What does the above 4 lines do?
When I include them it gives me the following message on command prompt:
C:\WINDOWS>c:\autoexec.bat
Bad command or file name
Bad command or file name
File creation error
C:\WINDOWS>
Quesion:
I am using windows 98 to do some programming.
How can I make dos print out all the output of a command?
It doesn't print the top output?
The "dir" command in:
c:\windows>dir
because this directory has lots of files and folders it only prints the last few files to dos prompt.
sleddog
09-19-2002, 05:03 PM
Originally posted by Sid Alam
@ echo off
cls
files=50
buffers=40
What does the above 4 lines do?
When I include them it gives me the following message on command prompt:
C:\WINDOWS>c:\autoexec.bat
Bad command or file name
Bad command or file name
File creation error
Take them out. classicsoftware was only providing an example of how to use REM. You asked how to put comments in an autoexec.bat file. The answer is, start the comment line with REM. Example:
REM This is a comment in autoexec.bat
(Incidentally the files= and buffers= commands go in config.sys not autoexec.bat).
Quesion:
I am using windows 98 to do some programming.
How can I make dos print out all the output of a command?
It doesn't print the top output?
The "dir" command in:
c:\windows>dir
because this directory has lots of files and folders it only prints the last few files to dos prompt.
No, it prints it all. But a long directory listing scrolls off your screen, so you only see the final part.
To pause the directory display at the end of each screen-full of data, you add the /p (pause) switch to the dir command:
C:\WINDOWS>dir /p
Or pipe the command through MORE:
C:\WINDOWS>dir | more
classicsoftware
09-20-2002, 12:00 AM
Dear Sid:
I must apologize, the
Files=
buffers=
Go in a config.sys file.
What comments do you want to put in the autoexec.bat file?
The autoexec.bat file is pretty much obsolete in a windows environment.
The only thing it is really used for is if you have a DOS or 16 bit Windows program.
Please post back with waht you want to do with the autoexec.bat file
I will list a real autoexec.bat file from DOS computer.
DO NOT PUT THESE COMMANDS IN YOUR AUTOEXEC.BAT FILE THIS IS AN EXAMPLE ONLY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!
rem @loadhigh C:\DOS\SHARE.EXE /l:500 /f:5100
@ECHO OFF
PROMPT $p$g
PATH C:\WINDOWS;C:\DOS;c:\bat;c:\fox25;c:\wp60;C:\NU
SET TEMP=C:\TMP
SET WINTEMP=C:\TMP
LH /L:0;1,45456 /S C:\DOS\SMARTDRV.EXE /Q /X 256 256
rem LH /L:1,59072
C:\MOUSE\MOUSE > NUL
rem LOADHIGH C:\DOS\DOSKEY
call C:\LANTASTI\STARTNET.BAT
menu
Please note the three rem lines, they are ignored and NOT executed. You can also use them to stop certain commands from executing without deleting them entirely.
Also note the call command. If you execute a batch file from within a batch file the commands under the batch file will NOT execute unless you use the call command, it returns control to the caling program, in this case the autoexec.bat file.
Please let me know what you want to do with your autoexec.bat file
tommy
09-20-2002, 03:39 AM
The REM (or rem) is valid but you can also use one colon (:) to accomplish the same thing. Personally, I use 3 colons just to make it more obvious when reading.
The advantage with the colon is that you don't have to remember to leave a space after it.
sleddog
09-20-2002, 07:51 AM
Originally posted by classicsoftware
The autoexec.bat file is pretty much obsolete in a windows environment.
In an NT/2000/XP environment, yes. But it is still integral in a Windows 95/98/ME environment. Such things as the PATH and system environment variables are set in autoexec.bat. But you know that :)
Sid Alam
09-20-2002, 09:38 AM
Where do you set the "path" and "classpath" in Windows 2000 professional?
I also program in windows 2000
In windows 2000 I have been putting it also in autoexec.bat file!!
So I must be doing something wrong???
iisbob
09-20-2002, 03:56 PM
It's been awhile since i programmed an autoexec file-but it should be semi-colon (;)~not a single colon ( : ) in front of your comment { you should use double :: in batch files } to tell windows ( or dos ) to ignore the command line.
Here's a nice link to give you some info;
REM in DOS (http://www3.sympatico.ca/rhwatson/dos7/y-rem.html)
sleddog
09-20-2002, 05:31 PM
Originally posted by Sid Alam
Where do you set the "path" and "classpath" in Windows 2000 professional?
In Win 2000, right-click My Computer, select Properties, then select the Advanced tab. Then click the Evironmental Variables button.
Note that you may set system variables (apply to all users) or user variables (apply only to your login).
tommy
09-21-2002, 02:07 AM
IISBOB
Autoexec.bat is considered a batch file and thus should use the double colon (::) to comment out a line. The semi-colon (;) is used only in config.sys.
Tom
iisbob
09-21-2002, 03:17 PM
The semi-colon ( ; ) is used only in config.sys.
Not so sir; a semi-colon also works in a standard auotexec.bat ( or any batch ) file.Not just config.sys-the semi-colon is universal just as REM is for commenting out a line of code.
vBulletin v3.6.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.