Ask Experts Questions for FREE Help !
Ask
    spa_m's Avatar
    spa_m Posts: 2, Reputation: 1
    New Member
     
    #1

    Mar 22, 2007, 06:16 AM
    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
    asterisk_man's Avatar
    asterisk_man Posts: 476, Reputation: 32
    Full Member
     
    #2

    Mar 22, 2007, 06:52 AM
    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!
    spa_m's Avatar
    spa_m Posts: 2, Reputation: 1
    New Member
     
    #3

    Mar 23, 2007, 12:13 AM
    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
    jaeope's Avatar
    jaeope Posts: 1, Reputation: 1
    New Member
     
    #4

    Jul 8, 2010, 10:29 PM
    Try %~dp0
    That will not include the name of the bat file.
    Hope it helps.
    Shaibaz93's Avatar
    Shaibaz93 Posts: 1, Reputation: 1
    New Member
     
    #5

    Jan 26, 2012, 11:43 PM
    http://appsbazar.blospot.com

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

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

How do I file for child abandonment and when can I file? [ 15 Answers ]

My daughters father has not seen her for over a year and he just left without telling me he was leaving. I do have a child support order and I have full custody of her. Im just afraid that he will try to take her away from me later in life and I don't want her to go through that because Im with a...

Baseball bat [ 4 Answers ]

I have a baseball bat that has the name Mark McGuire on it. I found it in a pile of stuff in an old house. Do you think it is worth anything or do you think it is just a kids' bat? Thanks for your help.

Do I have to file? [ 2 Answers ]

I only made 2,200 this year workig prt time. When doing my taxe I noticed that with my husbands icome plus this we would get less of a return. However if I do not include my income we will get much more? Do I really have to file?

The best email like The Bat! [ 4 Answers ]

Anybody help me find an email client as good as The Bat! I am using The Bat! Email client for years. I love its features, but now a days many of my email reciepient blocks my email because of possible spam from The Bat email client. I still fond of using it. So to cover all of my email...

If I file 1040NR, do I file state as nonresident? [ 1 Answers ]

The title says it all-I worked in several states but I am foreigner. Does that mean that I file state taxes as non-resident as well?


View more questions Search