do we still have %~ in batch files in windows 10


  1. Posts : 213
    Windows 10 Pro
       #1

    do we still have %~ in batch files in windows 10


    Greetings
    I still write batch files like I always did since dos.
    In windows XP all kinds of %~ variables were added to the vocabulary.
    Do we still have those or were they replaced by other in windows 10?
    where do I find a list of batch file commands still used in windows 10?
    thank you
      My Computer


  2. Posts : 1,097
    Windows 10 Home x64 Version 1809 (OS Build 17763.437)
       #2
      My Computer


  3. Posts : 93
    Windows 10
       #3

    Hi,

    zivshosh said:
    In windows XP all kinds of %~ variables were added to the vocabulary.
    Do we still have those or were they replaced by other in windows 10?
    That syntax resembles either argument expansion or expansion of dynamic variables from the For loop. The way you’ve phrased your question though, “were added to the vocabulary”, makes it sound like it’s a variable in itself but it’s more of a syntactic feature primarily used to strip quotes from dynamic variables. “%~” has an extended meaning in a for loop however (see Bree’s answer). The command processor hasn’t been updated in years, but I can’t verify for you if “%~” had existed back then.

    zivshosh said:
    where do I find a list of batch file commands still used in windows 10?
    Typically in a shell language you don’t get the luxury of knowing what commands are available for use. You just have to know that a particular command exists to be able to use it. There are a couple of command lists online though. SS64, which I’ve linked to in this post twice already, has a really good one. Their documentation is actively kept up to date as well.
    Last edited by Pyprohly; 28 Feb 2017 at 08:51. Reason: Fixed awkward wording
      My Computer


  4. Posts : 1,097
    Windows 10 Home x64 Version 1809 (OS Build 17763.437)
       #4

    This isn't my thread, but thanks for that link anyway.
      My Computer


  5. Posts : 31,604
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #5

    Pyprohly said:
    ...the command processor hasn’t been touched much in years although I can’t verify if “%~” syntax existed back then.
    %~ is interesting, and proves there's always more to learn (well, it's new to me) and, yes, they work in Win10.

    Windows NT 4 introduced a set of new features for command line parameters...
    ...
    %~fn will return the fully qualified path of %n if %n is a valid file name or directory
    Batch files - Command line parameters

    The variables %0, %1, %2, %3, .... %9 have existed since DOS. They are the arguments used to call the batch file, %0 being the name of the batch file itself. For example, save the following as Tell_Me.bat then run it with a few parameters.

    Code:
    @echo off
    echo You called %~f0 with arguments %1, %2 and %3
    To use a FOR ... DO loop in a batch file you have to escape the '%' character by typing it twice, for example:
    Code:
    @echo off
    for %%X in (1,2,3,4,5) do echo %%X

    For a shell language, typically you don’t get to know what command are available for use. You must know that a command exists to be able to use it. There are a couple of lists online though, like SS64, which I’ve linked in this post twice already, it’s a really good one.
    This is the most recent A-Z list I know of on TechNet.
    Updated: November 23, 2015
    Applies To: Windows Server 2003, Windows Vista, Windows XP, Windows Server 2008, Windows 7, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2000, Windows Server 2012, Windows 8
    https://technet.microsoft.com/en-us/...(v=ws.11).aspx
    Last edited by Bree; 28 Feb 2017 at 08:22.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:39.
Find Us




Windows 10 Forums