把当前目录(包括子目录)中的所有exe文件创建LNK快捷方式到 "E:\快捷方式" 目录中
快捷方式文件有重名时,后创建的文件覆盖之前创建的文件。- @if (0)==(0) echo off
- set "strLnkDir=E:\快捷方式"
- md "%strLnkDir%" 2>nul
- pushd "%~dp0"
- dir /b /s /a-d *.exe | cscript //nologo //e:jscript "%~f0" "%strLnkDir%"
- pause & exit
- @end
- var strLnkDir = WScript.Arguments(0);
- var objShell = new ActiveXObject('WScript.Shell');
- while(!WScript.StdIn.AtEndOfStream){
- var strFile = WScript.StdIn.ReadLine();
- var strName = strFile.replace(/.+\\(.+)$/i, '$1');
- var strLnkName = strLnkDir + '\\' + strName + '.LNK';
- try {
- var objLnk = objShell.CreateShortCut(strLnkName);
- objLnk.TargetPath = strFile;
- objLnk.WorkingDirectory = strFile.replace(/(.+)\\.+$/, '$1');
- objLnk.Save();
- objLnk = null;
- } catch(e) {
- WScript.Echo(e.message);
- }
- }
代码保存为.bat 双击运行