- 检.lnk是否有效(拖).bat
- 2>1/* ::
- @echo off
- ::【检测:被拖文件,是文件夹 还是 文件(【文件夹】到:A,【文件】就提示)】
- echo.
- dir/ad "%~1" >nul 2>nul&&goto :A||echo 这是文件(文件夹才行)
- pause>nul 2>nul&exit/b
- :A
- echo.%~1(目录路径)(回车打开)
- echo.
- set "目录路径=%~1"
- dir /b "%目录路径%\*.lnk"|cscript /nologo /e:jscript "%~f0" "%目录路径%"
- pause>nul 2>nul
- start "" "%~1"
- exit/b */
- v=WSH.arguments, s=WSH.stdin, n=0
- sF=WSH.CreateObject('Scripting.FileSystemObject')
- ws=WSH.createObject('Shell.Application'), d=ws.NameSpace(v(0))
- while (!s.atendofstream) {
- kF=s.readline(), di = d.ParseName(kF), lnk = di.GetLink
- if (!sF.fileExists(lnk.path) && !sF.folderExists(lnk.path)) n++,WSH.echo('无效的 * .lnk :'+kF)
- }
- if (n==0) WSH.echo(v(0)+' 【*.lnk都有效】')
- WSH.quit()
- ==================================
- 运行的.bat
- 2>1/* ::
- @echo off
- echo.
- echo.
- echo.目录:延时3秒的(回车打开目录)
- echo.
- set "目录路径=D:\PE整理碎片(很好)\修改PE\启动\延时3秒的"
- dir /b "%目录路径%\*.lnk"|cscript /nologo /e:jscript "%~f0" "%目录路径%"
- pause>nul 2>nul
- start "" "D:\PE整理碎片(很好)\修改PE\启动\延时3秒的"
- exit/b */
- v=WSH.arguments, s=WSH.stdin, n=0
- sF=WSH.CreateObject('Scripting.FileSystemObject')
- ws=WSH.createObject('Shell.Application'), d=ws.NameSpace(v(0))
- while (!s.atendofstream) {
- kF=s.readline(), di = d.ParseName(kF), lnk = di.GetLink
- if (!sF.fileExists(lnk.path) && !sF.folderExists(lnk.path)) n++,WSH.echo('无效的 * .lnk :'+kF)
- }
- if (n==0) WSH.echo(v(0)+' 【*.lnk都有效】')
- WSH.quit()
复制代码
以下代码存为 test.bat 运行,检测快捷方式的有效性是基于其目标路径的真伪...- 2>1/* ::
- @echo off &dir /b "D:\579\*.lnk"|cscript /nologo /e:jscript "%~f0" "D:\579"
- pause&exit/b */
- v=WSH.arguments, s=WSH.stdin, n=0
- sF=WSH.CreateObject('Scripting.FileSystemObject')
- ws=WSH.createObject('Shell.Application'), d=ws.NameSpace(v(0))
- while (!s.atendofstream) {
- kF=s.readline(), di = d.ParseName(kF), lnk = di.GetLink
- if (!sF.fileExists(lnk.path) && !sF.folderExists(lnk.path)) n++,WSH.echo('发现无效或系统内置快捷方式》'+kF)
- }
- if (n==0) WSH.echo(v(0)+' 目录中未发现可疑的快捷方式')
- WSH.quit()
复制代码