Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a batch file(lunch.bat) to run which has command to run another batch file(main.bat). I copyied this two files in my pendrive. I know my pendrive's drive latter in my computer,that's why i can configure 1st batch file(lunch.bat) to run another batch on my computer. But when i copy this two files in my pendrive and insert it to another computer, 1st batch file can't run another batch file. So this is a problem for me. Can anybody help me to get current directory command like c++(GetCurrentDirectory) function to run batch from any computer and from any drive?

share|improve this question

marked as duplicate by Ƭᴇcʜιᴇ007, TFM, Scott, Dave M, Dennis Apr 1 '13 at 21:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

From Raymond Chen

The easy way is to use the %CD% pseudo-variable. It expands to the current working directory.

.. do stuff ..
chdir /d %OLDDIR% &rem restore current directory
share|improve this answer

Batch command cd typed in without any parameters will return current working directory.

share|improve this answer

Put this code in the lunch.bat file:

call %~dp0main.bat

This starts the main.bat from the same drive & folder as the lunch.bat, wherever it is.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .