簡體   English   中英

當前目錄的批處理腳本問題

[英]Batch script issue with the current directory

我使用了一個批處理文件,其中我按如下所示設置絕對路徑變量

代碼段(批處理文件:brk_validation.bat)

SET ABS_PATH=%~dp0

echo  Completed the Validation of files in %ABS_PATH%

在命令提示符下運行批處理程序:

D:\Files>brk_validation.bat .

輸出:

Completed the Validation of files in D:\Files\

問題:

我將批處理文件放在另一個目錄中,然后通過提供其完整路徑來運行bat文件,如下所示:

 D:\Files>D:\Work\brk_validation.bat .

輸出:

Completed the Validation of files in D:\Work\

預期產量:

Completed the Validation of files in D:\Files\

我想要文件存在的當前目錄路徑,即上述示例的D:\\ Files。

因此,任何幫助表示贊賞。 謝謝 !!

對於當前目錄;

SET ABS_PATH=%cd%

應為SET ABS_PATH=%~dp1%0變量是批處理文件本身的文件名。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM