Testing for DOSKEY macro in a batch file
Results 1 to 4 of 4

Thread: Testing for DOSKEY macro in a batch file

  1. #1
    Join Date
    Jun 2001
    Location
    Jacksonville,Fl,USA
    Posts
    341

    Testing for DOSKEY macro in a batch file

    Hi folks;

    Is there some way I can test for the existance of a DOSKEY macro within a batch file? Foe example:

    if exist DOSKEY MACRO goto Menu

    I know that line is no good, but wonder if there's a way.

    Related to that question, is there any harm in simply redefineing a macro that already exists? For example:

    :: Some batch file
    @echo off
    DOSKEY MacroName=function

    Suppose that batch file gets run several times, the MacroName macro will get defined every time. Is this any kind of problem?

    Thanks all, Dex

  2. #2
    Join Date
    Feb 2000
    Location
    26.03°N 80.14°W
    Posts
    9,410
    You could do something like this:
    Code:
    @echo off
    :CheckIt
    doskey/macros|find/i "dira=dir/a/o/p"
    if errorlevel 0 if not errorlevel 1 goto End
    :SetIt
    doskey dira=dir/a/o/p
    goto CheckIt
    :End
    (In other words, it'll only setup a doskey macro named DIRA if it isn't already defined).

    But, this isn't really necessary. Whenever you create a doskey macro that has the same name as one already defined, it simply overwrites the old one.

    More info here: http://www.vfrazee.com/ms-dos/6.22/help/doskey.htm
    Vernon Frazee, Microsoft MVP (Windows - Shell/User)

    Defenses Up!
    Tip: When prompted for a password, give an incorrect one first. A phishing site will accept it; a legitimate one won't.


    Inside Spyware: A Guide to Finding, Removing and Preventing Online Pests


    If you don't keep up with security fixes, your computer|network won't be yours for long.

  3. #3
    Join Date
    Jun 2001
    Location
    Jacksonville,Fl,USA
    Posts
    341
    Thanks Vernon, thats what I was looking for.

    Dex

  4. #4
    Join Date
    Feb 2000
    Location
    26.03°N 80.14°W
    Posts
    9,410
    You're Welcome.
    Vernon Frazee, Microsoft MVP (Windows - Shell/User)

    Defenses Up!
    Tip: When prompted for a password, give an incorrect one first. A phishing site will accept it; a legitimate one won't.


    Inside Spyware: A Guide to Finding, Removing and Preventing Online Pests


    If you don't keep up with security fixes, your computer|network won't be yours for long.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •