這裏是一個批處理腳本,可以拖放任何文件與Notepad.exe
打開它,如果傳遞的參數是一個文件夾,它會與Explorer.exe
@echo off
Title Drag and drop a file to open with Notepad
Mode con cols=60 lines=3
IF [%1] EQU [] Goto:Error
CD /D "%~1">nul 2>&1 && Goto:Explorer_Folder || Goto :OpenFile
Exit /b
::**********************************************************
:OpenFile <File>
Start "Drag and Drop" "%windir%\system32\Notepad.exe" "%~1"
Exit /b
::**********************************************************
:Explorer_Folder <Folder>
Explorer "%~1"
Exit /b
::**********************************************************
:Error
Color 0C & echo(
ECHO You must drag and drop a file on this batch program
Timeout /T 5 /NoBreak >nul
Exit /b
::**********************************************************
打開要訪問拖動文件的例子並放在一個批處理文件中,將其稱爲['%1'](http://ss64.com/nt/syntax-args.html)(另請參閱'call/?'獲取更多信息);你可以在你的批處理文件中寫入''D:\ path \ to \ your \ program.exe「」%〜1「'用'program.exe'打開文件... – aschipfl