Last active
January 1, 2016 07:39
-
-
Save vanpeerdevelopment/8113259 to your computer and use it in GitHub Desktop.
This gist shows the usage of batch parameters in a bat file and shows how to extract extra information about its location or its parameters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET BAT_FILE = %0 | |
SET FIRST_ARG = %1 | |
SET SECOND_ARG = %2 | |
SET FIRST_ARG_WITHOUT_QUOTES = %~1 | |
SET BAT_DRIVE = %~d0 | |
SET BAT_PATH = %~p0 | |
SET BAT_FOLDER = %~dp0 | |
REM Suppose batch-parameters is located in C:\BatFolder\ | |
REM When executing batch-parameters.bat "C:\First" "D:\Second" | |
REM the above variables will be set as follows | |
SET BAT_FILE = batch-parameters.bat | |
SET FIRST_ARG = "C:\First" | |
SET SECOND_ARG = "D:\Second" | |
SET FIRST_ARG_WITHOUT_QUOTES = C:\First | |
SET BAT_DRIVE = C: | |
SET BAT_PATH = \BatFolder\ | |
SET BAT_FOLDER = C:\BatFolder\ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment