<p>System read-only variable <code>%CD%</code> keeps the path of the caller of the batch, not the fichier batch location.</p>
<p>Vous pouvez get the name of the script batch itself as typed by the user with <code>%0</code> (e.g. <code>scripts\mybatch.bat</code>). <a href="http://ss64.com/nt/syntax-args.html">Parameter extensions</a> can be applied to this so <code>%dp0</code> will return the Drive and Path to the script batch (e.g. <code>W:\scripts</code>) and <code>%f0</code> will return the full pathname (e.g. <code>W:\scripts\mybatch.cmd</code>).</p>
<p>Vous pouvez refer to other files in the same folder as the script batch by using this syntax:</p>
<pre><code class="lang-auto">CALL %0..\SecondBatch.cmd
</code></pre>
<p>This can even be used in a subroutine, <code>Echo %0</code> will give the call label but, <code>echo "%nx0"</code> will give you the filename of the script batch.</p>
<p>When the <code>%0</code> variable is expanded, the result is enclosed in quotation marks.</p>
<p><a href="http://ss64.com/nt/syntax-args.html">More on batch parameters</a>.</p>