Return File Name in Batch

2

Is it possible to return the name of a file / program for a bat? Type by dragging it to the bat or executed by the bat, it returns the name.

    
asked by anonymous 12.09.2017 / 23:27

1 answer

4

Yes, this is a simple example, it takes the parameter "set arg1 =% 1" and then shows the value "echo% arg1%".

or

It takes the path of the file you dragged "set arg1 =% 1" and then shows the path "echo% arg1%".

echo off
set arg1=%1
echo %arg1%
pause

Let's suppose you drag a txt, and want to open it in notepad for example:

echo off
set arg1=%1
start notepad %arg1%
    
13.09.2017 / 01:14