批处理之家's Archiver

youxi01 发表于 2007-12-31 17:55

[转]批处理创建快捷方式

[align=left][code]
@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
[/code][/align]

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.