本帖最后由 adan1 于 2016-12-6 17:03 编辑
回复 4# CommandBatCmd
我算是把它改好了- @echo off & setlocal EnableDelayedExpansion &
- set "pg=C:\a.exe" & set "LID=/L" & set "p=%~1" &
- if /i !p:~-4! neq .LNK ((start "" /i !pg! %1 !LID!)&echo exit
- ) else mshta VBScript:Execute("set wsh=CreateObject(""WScript.Shell""): set lnk=wsh.CreateShortcut(""%~1""): wsh.run ""!pg!"" &"" """"""& lnk.TargetPath &"""""" """"""& lnk.Arguments &"""""" ""& ""!LID!"": close")
复制代码 拖文件到批处理执行是完全正常的,而CMD中执行批处理是有部分不正常。- final.bat C:\Users\Adan\Desktop\TEST\1_2_3\notepad.exe
- final.bat "C:\Users\Adan\Desktop\TEST\1_2_3\notepad.exe"
- final.bat C:\Users\Adan\Desktop\TEST\1_2_3\notepad.exe.lnk
- final.bat "C:\Users\Adan\Desktop\TEST\1_2_3\notepad.exe.lnk"
- final.bat C:\Users\Adan\Desktop\TEST\1 2 3\notepad.exe <- 失效
- final.bat "C:\Users\Adan\Desktop\TEST\1 2 3\notepad.exe"
- final.bat C:\Users\Adan\Desktop\TEST\1 2 3\notepad.exe.lnk <- 失效
- final.bat "C:\Users\Adan\Desktop\TEST\1 2 3\notepad.exe.lnk"
复制代码
|