1
A
回答
0
兩種方式;
call :label python.exe
:label
call %~dp$PATH:1
或者,如果你有where
可用...
for /f %f in ('where python.exe') do %f
(您可能需要使用雙百分比[%%]在批處理文件進行此操作。)
如果有在路徑上多於一個可執行文件,你想要類似...
set target=
for /f %f in ('where python.exe') do (
set target=%f
)
call %target%
+0
不,這是bat文件的路徑,我的意思是如何獲得命令程序的完整路徑....作爲一個字符串 –
1
test.bat
@for %%i in (python.exe) do @set py=%%~$PATH:i
@echo %py%
@for %%i in (%py%) do @set py=%%~dpi
@echo py's directory is %py%
ONELINE蝙蝠whereis ==
where.bat
@for %%i in (%*) do @if not "%%~$PATH:i"=="" (echo %%~$PATH:i) else echo %%i
where ls.exe where.bat python.exe
D:\Program Files\Git\usr\bin\ls.exe
E:\sourceCode\shell\where.bat
C:\Python27\python.exe
相關問題
- 1. 如何在linux中獲得程序的完整路徑?
- 2. 如何在windows中獲取java應用程序的完整路徑
- 3. 在python中,我如何獲得「。」的完整路徑名?
- 4. 如何獲得MVC ActionLink在JQuery中的完整路徑
- 5. 要獲得powershell.exe的完整路徑
- 6. 獲取Windows服務的完整路徑
- 7. 如何獲得一個窗口的完整路徑,在Windows資源管理器
- 8. 如何獲得Gradle中外部依賴的完整路徑?
- 9. 如何獲得完整的路徑URL中phalconphp
- 10. 如何獲得JSP中fileupload的完整路徑?
- 11. 如何從通配符中獲得完整路徑?
- 12. 如何獲得完整的URL與當前路徑中水豚
- 13. 如何獲得在控制器MVC1完整的URL路徑
- 14. 如何獲得本地文件在Firefox的完整路徑3
- 15. 如何獲取程序集的完整文件路徑?
- 16. 如何獲取完整的目錄應用程序路徑?
- 17. 如何獲取ASP.NET應用程序的完整虛擬路徑
- 18. 在Windows 7中使用C++獲取已安裝程序的完整路徑
- 19. 如何從t:inputFileUpload獲取完整路徑?
- 20. 如何獲取StreamWriter的完整路徑
- 21. 如何從完整的路徑得到絕對路徑
- 22. 在WPF treeview中獲取完整路徑?
- 23. 如何完整路徑
- 24. 如何獲得下載圖片的完整路徑?
- 25. 如何獲得UIImage的完整文件路徑
- 26. 如何獲得IVsProject的完整路徑名稱?
- 27. 如何獲得執行文件的完整路徑?
- 28. 如何獲得perl文件的確切完整路徑
- 29. 如何獲得任意ruby類的完整文件路徑?
- 30. 如何獲得完整的文件路徑
Perhpas你的意思是這樣==> [如何找到完整路徑批處理腳本的應用程序( http://stackoverflow.com/questions/1437457/how-do-i-find-full-path-to-an-application-in-a-batch-script) – Hackoo
_where_命令可以幫助你。 **在命令提示符下輸入/?**。接下來,您可以使用_for_循環獲取結果 – elzooilogico
呃,您發佈該評論而不是答案...不知道是否在同一時間我編輯了我的答案。 – TylerY86