• وبلاگ : پاي سيب
  • يادداشت : Cellular automaton
  • نظرات : 0 خصوصي ، 82 عمومي
  • چراغ جادو

    نام:
    ايميل:
    سايت:
       
    متن پيام :
    حداکثر 2000 حرف
    كد امنيتي:
      
      
     
    + DOS 

    يك مدتي هست خيلي ويرم گرفته ببينم چه طوري مي شه بچ فايل درست كرد ...

    Windows Vista has added the CHOICE command. This is pretty cool! It lets you build simple menus just from this one command. On a Windows Vista computer, open a command prompt and type CHOICE /? to see all the things you can do with it. At the present, this might not be so useful if yo uare writing batch files that also will be run on Windows XP computers, because the CHOICE command will not work on those computers — and the SET /P approach above still works in Vista.

    Here is an example of a batch file I recently wrote for my office. It uses many of the features discussed on this page, including menu creation. The problem to be solved was that (for reasons too tedious for the present article) users accessing our network remotely no longer had access to their browser Favorites. Additionally, it was useful (when swapping out computers) to migrate a user’s Favorites from the old computer to the new. Both of these could be solved by moving the Favorites (which are simply shortcut files) up onto a personal network drive (let’s call it P:) to which they always had access. I wanted to allow the user, with a single file that I could email them, to be able both to cache their Favorites on the network drive and to pull these back down to another computer. Here is a slightly edited version of the batch file.

    ECHO OFF
    CLS
    :MENU
    ECHO.
    ECHO ...............................................
    ECHO PRESS 1 or 2 to select your task, or 3 to EXIT.
    ECHO ...............................................
    ECHO.
    ECHO 1 - Export Favorites from COMPUTER to PERSONAL DRIVE (P:)
    ECHO 2 - Import Favorites from PERSONAL DRIVE (P:) to COMPUTER
    ECHO 3 - EXIT
    ECHO.
    SET /P M=Type 1, 2, or 3, then press ENTER:
    IF %M%==1 GOTO EXPORT
    IF %M%==2 GOTO IMPORT
    IF %M%==3 GOTO EOF
    :EXPORT
    XCOPY "%userprofile%"\Favorites\*.* P:\Favorites\ /S/Y
    GOTO MENU
    :IMPORT
    XCOPY P:\Favorites "%userprofile%"\Favorites\*.* /S
    GOTO MENU


    More Information on These Commands

    Each of these options (START, IF, GOTO, FOR, SET) is an actual DOS command. At a system prompt, type the command name followed by /? to get further help on these items.

    Note that there may be particular capabilities that show up in one version of Windows, but not in another. For example, though DOS per se may well be dead in Windows XP and Vista, the commandline functions people most often associate with DOS are not dead at all! (We just don’t call them “DOS commands” anymore; we call them “command prompt commands.” But they’re the same thing.) In some cases, these commands have been made more powerful in Windows XP. In particular, if Win XP Command Extensions are enabled, each of these four has very greatly enhanced capabilities (see Win XP Help & Support to learn about Command Extensions). Take advantage of the opportunity to explore each of them with the /? help flag.

    SOME EXAMPLES (that don’t even require Command Extensions): START has new flags that let you set the priority (/LOW, /NORMAL, /HIGH, etc.) of the application you are launching. IF has an ELSE option than greatly expands its power, but which requires a somewhat complicated syntax sometimes (which the /? help text covers reasonably well).

    Since these START, IF, GOTO, and FOR are actual OS commands, they can be used from a system prompt just like DIR, COPY, or any other DOS command. This means that they can be used outside of a batch file as well. There are small differences or issues that you can easily discover in use, and discussion of which would go beyond the purpose of the present page. For anyone comfortable working at a DOS system prompt, this should present no significant problem. Just remember: