Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PATH doesn't work within a DOS SHELL --- Why?
#41
Quote:That is really mysterious problem. What OS are you running? Perhaps this is a bug in the DOS Shell of such OS?
No, the same problem occurs in Windows XP and 2000 on 2 different PCs. Plus it also occurs on Nathan's machine.
*****
Reply
#42
Not a bug, it is a documented "feature" . See my previous post and Windows help about implicit ENDLOCAL.

Batch in W2000 and XP works differently than in DOS- W9x. It is much more powerful. Spanish readers can check the Batch tricks at my site. It's about all the strange things you needed to do in DOS-W9x batch to get the work done. ALL of that is now obsolete...

http://www.geocities.com/antonigual/batchtips.html
Antoni
Reply
#43
Quote:Edited:
I suppose Moneo has more than one DOS PROGRAM in his PC so changing config.nt and autoexec.nt is not the solution...

I still dont understand why wont that work? I tried editing the autoexec.bat on my system and it worked. Infact now i remember that a while ago when i installed allegro for DJGPP as well as while installing it for Mingw32 I had edited my autoexec.bat to set the environment variables.
Reply
#44
He means that he needs that path just for that application, so changing the startup files won't work for him.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#45
Quote:Not a bug, it is a documented "feature" . See my previous post and Windows help about implicit ENDLOCAL.

Batch in W2000 and XP works differently than in DOS- W9x. It is much more powerful. Spanish readers can check the Batch tricks at my site. It's about all the strange things you needed to do in DOS-W9x batch to get the work done. ALL of that is now obsolete...

http://www.geocities.com/antonigual/batchtips.html
You're right, Antoni, things have changed in the batchfile rules in Win2000 and WinXP.
For example, some of my QuickBasic programs generate and execute batchfiles. In order to delete these batchfiles when they're finished, I put a delete command to the batchfile name (DEL BATNAME) at the end of the batchfile but without a CRLF at the end of the record. It still works in Win2000 and WinXP, but it also displays an error message saying "The batch file cannot be found" on the screen which is very annoying especially for utility programs which I give to friends.

I haven't noticed any other differences, yet.
*****
Reply
#46
Batch command language has changed a lot, for good
You have:
-Several commands in a single line
-Conditional exec
-Subroutines
-timed commands (at)
-push and pop paths
-setlocal end local to make temporal environment changes
-a filename variable can be splitted in unit,path, name, extension with ~
-choice and deltree do not work anymore

-Extended for loop:
recurse directories
counting
file lines processing

You really should check your Win help!
Antoni
Reply
#47
Thanks, Antoni, very interesting. Next time I need to write a more robust batchfile, I'll look into these details.
*****
Reply
#48
You will never build a robust batch file. .. Big Grin
Unfortunately DOS-W9x and W2000-XP batch languages have a lot of incompatibilities!
Antoni
Reply
#49
Antoni,
Here's the specs for a utility program that I wrote in 1994 to insert into batchfiles to do things that you can't normally do in a batchfile, thus making them more "robust":
Code:
!BAT   Multiple Utility Program for Batch Files
-------------------------------------------------------

Usage: !BAT /OPTION [specs and switches for OPTION]
       Invoke !BAT program within a batchfile.

The following is a list of the available OPTIONS:
              
* BAK      - Copy specified file to a backup file.
           - Syntax: !BAT /BAK [d:][path][Filename[.ext]] [/EXT=]
           - Default file extension is BAK.
           - If /EXT= specified: provide max 3-letter file extension.
           - Example: Use in batchfile to call MSDOS EDIT program,
                      which gives you no backup file.

* CAPSOFF  - Sets Caps Lock OFF.
           - Syntax: !BAT /CAPSOFF
              
* CAPSON   - Sets Caps Lock ON.
           - Syntax: !BAT /CAPSON
              
* DISKSIZE - Determines the size of the specified drive.
           - Normal usage is to determine a diskette's size.
           - Syntax: !BAT /DISKSIZE d:
                     where d: is the drive.
           - Return Codes:
              * Errorlevel   0 = Disk size less than 360 KB.
              * Errorlevel   1 = Disk size is 360 KB.
              * Errorlevel   2 = Disk size is 730 KB.
              * Errorlevel   3 = Disk size is 1.2 MB.
              * Errorlevel   4 = Disk size is 1.4 MB.
              * Errorlevel   5 = Disk size is 2.8 MB.
              * Errorlevel   6 = Disk size is 2.9 MB or greater.
              * Errorlevel 255 = Have issued an error message.

DOSENGLISH - Tests language of DOS operating system,  returns:
               errorlevel = 0 if DOS is in English.
               errorlevel = 1 if DOS is NOT in English.
             - Syntax: !BAT /DOSENGLISH

* EXIST    - Tests existence of specified Spec, and returns:
             errorlevel = 0 if Spec exists.
             errorlevel = 1 if Spec does not exist.
           - Spec can be Drive and/or Path and/or Filename, w/wildcards.
           - Syntax: !BAT /EXIST [d:][path][FileSpec[.ext]] [/D] [/NZL]
           - /D means test if Spec exists as a directory or
             subdirectory only.
           - /NZL (Not Zero Length) means test a Spec OF A SINGLE
             FILENAME to see if it exists AND is not a zero length file.
           - (/D and /NZL are mutually exclusive)."
              
* KILLFILE - Kill (delete) single file regardless of attribute.
           - Syntax: !BAT /KILLFILE [d:][path]Filename[.ext]
              
* LOCKUP   - Locks the PC forcing power off/on.
           - Syntax: !BAT /LOCKUP
              
* MAKEDIR  - Purpose: to create a directory, testing for errors.
           - Syntax: !BAT /MAKEDIR [d:][path]DirectoryName
           - Scope:
             * DirectoryName is first validated (see below).
             * If DirectoryName already exists as a directory,
               then the program just exits.
             * However, if it exists as a file, then the conflicting
               file is renamed with a file-extension of .!!!.
               Then the desired directory is created. (Note: I had to
               make a choice here. Your batch file is creating a dir
               for its use, and a duplicate filename in the parent dir
               probably does not matter to a production batch file,
               and it certainly did not exist when you tested.)
             * If DirectoryName does not exist, it is created. This is
               the normal case.
             * Normal termination issues an errorlevel 0.
             * The following errors are detected, producing a corres-
               ponding error message on the screen with a pause, and
               an errorlevel 1 upon exit:
               - Invalid DirectoryName according to DOS rules.
               - Wildcards in DirectoryName.
               - Invalid, not ready, or write protected drive.
               - A parent directory, specified in [path] which
                 does not exist.
              
             * Hint: Substitute MD in your batch files with
                     !BAT /MAKEDIR followed by IF ERRORLEVEL 1.
              
* MSG      - Reformats and displays Message-Text, and waits for a key.
           - Syntax: !BAT /MSG Message-Text [/YESNO] [/KEYS=] [/color]
           - Optional Control Characters within Message-Text:
              ~  means toggle the alphabetic case, first upper to lower.
              \\ means end-of-line, go to next line of message.
           - If /YESNO specified:
              * Response key can only be Y,S, or N.
              * If response is Y or S, errorlevel=0. If N, errorlevel=1.
              * (S is to accomodate the Spanish affirmative SI.)
           - If /KEYS= specified:
              * Response is related to number of character keys
                that follow.
              * The errorlevel number is the position of each
                character key.
              * NOTE: /KEYS= will override /YESNO if also specified.
           - Colors can be specified for the prompt by appending
             a / and the name of one of the following colors:
             blue,green,cyan,red,magenta,brown,gray.
           - Example:
             !BAT /MSG M~ASTER FILE HAS BEEN UPDATED.\\~D~O YOU WANT TO
             GENERATE A BACKUP?/YESNO
             IF ERRORLEVEL 1 GOTO NOBACKUP
             GOTO YESBACKUP

             Above will produce a message screen with following text
             centered in a default red box:

                      Master file has been updated.
                      Do you want to generate a backup?

                                                   ...Press (Y/N)...

* NUMOFF   - Sets Num Lock OFF.
           - Syntax: !BAT /NUMOFF
              
* NUMON    - Sets Num Lock ON.
           - Syntax: !BAT /NUMON
              
* RETURN1  - Saves the current directory, so you can get back to it.
           - Syntax: !BAT /RETURN1
           - When you execute the RETURN1 it determines the current
             directory's drive and full path, and creates a batch file
             called !RETURN2.BAT into the root directory of drive c:,
             which, when executed, will put you back on the original
             drive and directory.
           - So, you issue !BAT /RETURN1 in your batch file at the
             point you want to save the current drive/directory,
             then later issue a CALL C:\!RETURN2 to restore it.

* SOUND    - Produces 1 of 10 different sound patterns.
           - Syntax: !BAT /SOUND [n]
                     where the optional n is the sound number 1-9,
                     and no number emits a standard beep.
              
* TESTDRIVE - Tests if the specified drive is ready.
            -  Syntax: !BAT /TESTDRIVE d: [/W]
                       where d: is the drive.
               /W option means also test if ready for writing;
               i.e., in the case of diskettes, not write protected.
            -  If drive is ready,     ERRORLEVEL 0 is returned.
            -  If drive is not ready, ERRORLEVEL 1 is returned.

* TESTLP   - Tests if the line printer is ready.
           - Syntax: !BAT /TESTLP [n]
             where the optional n is the LPT number 1-3. Default is 1.
             if line printer is ready,     ERRORLEVEL 0 is returned.
             if line printer is not ready, ERRORLEVEL 1 is returned.
              
* WARMBOOT - Performs a "warm" boot of the PC,
             as if the Ctrl-Alt-Del keys had been pressed.
           - Syntax: !BAT /WARMBOOT

* YESNO    - Prints a prompt and checks response char.
           - Syntax: !BAT /YESNO [prompt string][/KEYS=][/color]
           - The default prompt is : do you wish to continue (Y/N).
             If response is Y or S, errorlevel=0. If N, errorlevel=1.
             (S is to accomodate the Spanish affirmative SI.)
           - If only the prompt string is provided, the responses
             are Y or S, and N as above.
           - If prompt string and /KEYS=, the responses are related
             to the number of keys specified, with the errorlevel number
             equal to the relative position of each key.
           - Colors can be specified for the prompt by appending
             a / and the name of one of the following colors:
             blue,green,cyan,red,magenta,brown,gray.
           - Example:
             !BAT /YESNO WHICH PRINTER? (1/2/3)/KEYS=123/RED
             IF ERRORLEVEL 3 GOTO PRN3
             IF ERRORLEVEL 2 GOTO PRN2
             ...(logic for prn1)...
             ...(since keys were 123, you only get errorlevels 1-3)
*****
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)