|  | 
| 本帖最后由 pogua007 于 2016-6-18 16:23 编辑 
 我不知道mshta命令整合VBS详细用法,但是我估计会很累。我知道的整合方法是独立的VBS文件需方对你有用
 批处理部分
 
 复制代码set FileName=文件名.exe
setlocal enabledelayedexpansion
set /a xxx=0
for %%a in(C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
  if exist %%a:\ (
    for /f "delims=" %%b in ('dir /a-d /s /b "%%a:\*%FileName%" ') do (
      if /i "%%~nxb" equ "%FileName%" (
        set /a xxx+=1
        call linkexe.vbs %%b !xxx!
      )
    )
  )
)
 批处理向 linkexe.vbs传递两个参数,一个是包含路径的的文件名,一个是为了防止找到多个同名文件生成的快捷方式发生覆盖,只显示最后一个,在批处理中多传递给VBS一个序数。
 因为if 中的set xxx存在变量延时,打开了延迟开关,用“!”取代了"%"
 VBS部分,把vbs取名linkexe.vbs和批处理放在一起。
 
 复制代码dim fso, WorkingPath, linkfile, linkname, WorkingPath
linkfile=wscript.arguments(0)
linkname=wscript.arguments(1)
Set fso = CreateObject("Scripting.FileSystemObject")
WorkingPath = fso.GetParentFolderName(linkfile)
linkname = "\找到文件" & linkname & ".lnk" ''上次这里错了,忘了加扩展名了,这次编辑加上了
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & linkname)
oShellLink.TargetPath = linkfile
oShellLink.WorkingDirectory = WorkingPath
oShellLink.Save
 | 
 |