[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 432
  • Last Modified:

fine batch file execution path in runtime

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.
0
3qline
Asked:
3qline
1 Solution
 
Dragon_KromeCommented:
try:


@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 ?
0
 
garreHCommented:
If you want the path for where the batch file is use

echo %CD%

garreh
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now