fine batch file execution path in runtime

Posted on 2006-04-21
Last Modified: 2012-05-05
I'd like to make a batch(DOS) file and during the runtime of the batch file how I can find out its execution path.
Assuming that I don't know where the batch file resides in the client mashine. So I have to find out where the execution path of the batch file. The code should be within the batch file.
Question by:3qline
    LVL 5

    Expert Comment


    @echo %0

    (%0 being what you need)

    I.e., when running from the current directory,  it will show  test.bat  (i've created a test.bat on my Desktop, containing the line above), and when ran from a directory above,  it shows  Desktop\test.bat

    Or do you need the full path to the batch, like  C:\Documents .... .. .\test.bat ?
    LVL 4

    Accepted Solution

    If you want the path for where the batch file is use

    echo %CD%


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    This video teaches viewers about errors in exception handling.
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now