• وبلاگ : پاي سيب
  • يادداشت : Cellular automaton
  • نظرات : 0 خصوصي ، 80 عمومي
  • ساعت ویکتوریا

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

    Commandline Arguements {%x}

    Variables can be inserted into a batch structure in the form of command line arguements. These are in the form %1, %2, etc. To populate the variables, type the desired values after the batch file name when executing it.


    DOS Environment Variable Names {%nn%}

    DOS environment variables also can be used as variables in batch files. For example:

    COPY %windir%\filename a:

    Where does one get a list of DOS environment variables? I have never found a comprehensive list; but a partial but lengthy list of existing environment variables can be gotten by typing SET at a command prompt.

    And here’s the really cool part! You can make them up as you go along, and assign them as you wish (as long as you don’t grab one that has a legitimate assigned value, such as, say, %windir%, the Windows directory name!). Pick a name, populate it with the SET command by any means known to you (including having one batch file run a process that includes setting one, and then another batch file using it), then use it by placing the name between flanking % signs. Environment variables remain until overwritten, or until a reboot. (If you set them in a DOS window, they will end when that session is closed.)

    If you precede an environment variable setting with the SETLOCAL command (on a line of its own), then environment variable changes are local to the batch file. They do not exist for any other process and they do not survive the completion of the batch file’s execution. You can turn this setting off by issuing an ENDLOCAL command later in the batch file.

    Silly example: To change the current logged drive to D:, do the following:

    SET GONEXT=D:
    %GONEXT%

    More practical example: You want to copy a file to the desktop of each user the next time they log into Windows. Each user logs into a different user profile, and the Desktop folder is in a unique location for each user. (The folder name will, of course, vary on non-English versions of Windows.) For a file called MYFILE.TXT, you can do this as follows on Windows 2000 or XP computers by using an environment variable %userprofile% which gives the path to the root of a given user’s profile:

    COPY MYFILE.TXT %userprofile%\Desktop


    START Command

    The START command can launch a Windows program either by specifying the program name (and its command-line parameters), or by specifying a data file name that is associated with a particular program (one that would automatically launch if you clicked on it in Windows).

    For example, if you have NOTEPAD.EXE associated with all TXT files, then you could open the file SOME.TXT in any of the following four ways:

    NOTEPAD SOME.TXT
    SOME.TXT
    START NOTEPAD.EXE SOME.TXT
    START SOME.TXT

    Why use one or the other? Well, sometimes you may have to use one particular form to get a result — depending, for example, on how the particular program is coded. Though the first form usually will work, you may want, for example, to write a more general batch file to open any particular program and associated file — without knowing what the requirements of all such files might be. You could, then, write a general batch file line such as START %1% %2%.

    One particular use of the START command is to launch the default browser and go directly to a URL, for example: START http://google.com

    You may use any of four command line parameters with the START command. These go after the word START, but before the program name:

    /minimized or /m
    /maximized
    or /max
    /restored
    or /r
    /wait
    or /w

    The first three determine the screen status in which the program opens. The last one forces the batch file to halt processing until the called program has finished executing. (This can be useful, for example, if you are loading multiple items in your windows Startup folder, and the nature of the programs require that one be finished before the next starts loading. Put them all in a single batch file, using the /wait parameter, and only put a shortcut to the batch file in the Startup folder.) Command line parameters of the START command can be combined in a single line. Example:

    START /max /wait NOTEPAD.EXE SOME.TXT