Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Other Programming (https://www.askmehelpdesk.com/forumdisplay.php?f=437)
-   -   How do I get the path of a .bat file inside the .bat file dynamically? (https://www.askmehelpdesk.com/showthread.php?t=74717)

  • Mar 22, 2007, 06:16 AM
    spa_m
    How do i get the path of a .bat file inside the .bat file dynamically?
    Hi...

    I have a .bat file (script) which I can place in any directory. How do I get the current directory path of this file inside this .bat file dynamically without initaly setting any variable? I know we can use "." or ".."etc.
    But i know there is some command which we can use in the .bat file which will return the path where this .bat file is currently placed, but i dont know which one that is...
    This command has a "~" symbol in it and i totally can't recollect what this command is.
    Once i have the path of the directory where this current .bat file is placed i can then use this path at a later stage for either going to the top directory or something like that using "." or "..". Using this particular command will make my .bat file (script file) very generic.
    Please do help me out

    Spa
  • Mar 22, 2007, 06:52 AM
    asterisk_man
    This is windows I assume.
    Look here for some good reference
    Batch File Command Reference for Windows 2000

    You can use %~f0 for the full path to the current script. Hope that helps!
  • Mar 23, 2007, 12:13 AM
    spa_m
    Hiiiiii
    Thanks this did help.
    It actually gives the complete path of the bat file i.e. including the name of the bat file
    I needed the path so I can further use this path and go to a required folder using "." or "..".
    The link you gave is also helping. Thanks again.
    A :) Spa
  • Jul 8, 2010, 10:29 PM
    jaeope
    Try %~dp0
    That will not include the name of the bat file.
    Hope it helps.
  • Jan 26, 2012, 11:43 PM
    Shaibaz93
    http://appsbazar.blospot.com

    Type this url in Google and watch all things which you really want.. .

  • All times are GMT -7. The time now is 11:56 PM.