标题: [转]批处理创建快捷方式 [打印本页]
作者: youxi01 时间: 2007-12-31 17:55 标题: [转]批处理创建快捷方式
- @echo off
- setlocal enabledelayedexpansion
- if exist tmp.vbs del tmp.vbs /q
- cls
- color 0a
- title 批处理创建快捷方式
- :enterFileName
- cls
- echo.
- set /p fileName= [请输入文件或者目录的全路径]:
- if /i "!fileName!"=="" goto :enterFileName
- if not exist "%filename%" cls & echo 你输入的目录或者文件名不存在,请重新输入 & pause & goto :enterFileName
- echo.
- for %%i in ("!fileName!") do set name=%%~ni
- set /p shortCutPath= [请输入将创建方式保存到的路径]:
- set shortCutPath="!shortCutPath!\!name!.lnk"
- echo Dim WshShell,Shortcut>>tmp.vbs
- echo Dim path,fso>>tmp.vbs
- echo path="%fileName%">>tmp.vbs
- echo Set fso=CreateObject("Scripting.FileSystemObject")>>tmp.vbs
- echo Set WshShell=WScript.CreateObject("WScript.Shell")>>tmp.vbs
- echo Set Shortcut=WshShell.CreateShortCut(%shortCutPath%)>>tmp.vbs
- echo Shortcut.TargetPath=path>>tmp.vbs
- echo Shortcut.Save>>tmp.vbs
- "%SystemRoot%\System32\WScript.exe" tmp.vbs
- ::del tmp.vbs /s /q
- cls
- if exist %shortCutPath% echo 快捷方式创建完毕... & pause>nul
- if not exist %shortCutPath% echo 快捷方式创建失败,请重新操作... & pause>nul
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |