windows - Batch file executed from context menu - different behaviour between 'open' and 'open with' -
i have issue depending whether created batch file (run on file via context menu - right click) results in different outcome.
if batch file selected default program (not desired setup) open file works fine. i.e. right-click>'open' or double-click
if batch file selectable 'open with' menu default program different (desired setup) batch file starts no outcome produced
the batch file simple, executes program requires 2 arguments - input file , destination folder:
@echo off "pcap generator.exe" %~dpnx1 %cd% del *.log /q
could kindly explain why behaviour differs? kindly correct batch file operate correctly in case batch file selectable right-click > 'open with' menu , not default program open file.
thanks in advance
most better be:
@echo off if not "%~1" == "" ( "pcap generator.exe" "%~f1" "%~dp1" del /q "%~dp1*.log" 2>nul )
a simple test made if batch file called without parameter.
%~dp1
references drive letter , path of first parameter passed batch file. string ends backslash.
the deletion of log files done in quiet mode suppressing error message in case of no log file in directory.
for details on used commands, open command prompt window , execute there:
call /?
... output explains%~dp1
,%~f1
.del /?
... output explains option/q
.
in general running command or console application parameter /?
in command prompt window results in getting command or console application output in 1 or more window pages.
there command help
listing windows standard commands if executed without parameter while running help
name of command help call
results in same output when running call /?
.
Comments
Post a Comment