YOGYUI

Windows Batch Script::배치 파일의 경로 얻기 본문

Software/Etc

Windows Batch Script::배치 파일의 경로 얻기

요겨 2021. 11. 12. 09:37
반응형

Get path of the batch script file

%~dp0 구문을 활용하면 된다

 

예를 위해 C:\Test\Test1.bat 파일을 생성한 뒤 다음과 같이 스크립트 작성

@echo off
set CUR_PATH=%~dp0
echo %CUR_PATH%

커맨드 라인 툴에서 실행해보자

c:\Test>test1.bat
c:\Test\

c:\>c:\Test\test1.bat
c:\Test\

배치 파일(test1.bat)이 존재하는 경로임을 알 수 있다

 

출처: https://stackoverflow.com/questions/3827567/how-to-get-the-path-of-the-batch-script-in-windows

 

반응형
Comments