标题: 网上看到的用批处理建立lnk快捷方式
[打印本页]
作者: kidzgy
时间: 2010-6-15 09:58
标题: 网上看到的用批处理建立lnk快捷方式
Sub bat
echo create_shortcut
start wscript -e:vbs "%~f0"
Exit Sub
End Sub
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Dim WshShell,pa
Set WshShell = WScript.CreateObject("WScript.Shell")
Pa = WshShell.CurrentDirectory
set oShellLink = WshShell.CreateShortcut(strDesktop & "\火炬之光.lnk")
oShellLink.TargetPath = pa & "\开始游戏.exe"
oShellLink.WindowStyle = 2
oShellLink.IconLocation = pa & "\开始游戏.exe, 0"
oShellLink.WorkingDirectory = pa
oShellLink.Save
真的很强大.我搞不懂SUB本来就不是可以运行的命令,可是少了它却不行了!
作者: Hanyeguxing
时间: 2010-6-15 11:43
批处理时:
Sub bat,批处理中因为不存在Sub,输出错误显示并跳过,在vbs中定义sub过程的name为bat
start wscript -e:vbs "%~f0",把整个批处理重新按vbs运行
Exit Sub,在vbs中从sub 过程中退出,在批处理中,只使用Exit,退出批处理
批处理也可以写成:
more +3<%~fs0>$.vbs
cscript //nologo $.vbs&del $.vbs
Exit
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Dim WshShell,pa
Set WshShell = WScript.CreateObject("WScript.Shell")
Pa = WshShell.CurrentDirectory
set oShellLink = WshShell.CreateShortcut(strDesktop & "\火炬之光.lnk")
oShellLink.TargetPath = pa & "\开始游戏.exe"
oShellLink.WindowStyle = 2
oShellLink.IconLocation = pa & "\开始游戏.exe, 0"
oShellLink.WorkingDirectory = pa
oShellLink.Save
vbs:
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Dim WshShell,pa
Set WshShell = WScript.CreateObject("WScript.Shell")
Pa = WshShell.CurrentDirectory
set oShellLink = WshShell.CreateShortcut(strDesktop & "\火炬之光.lnk")
oShellLink.TargetPath = pa & "\开始游戏.exe"
oShellLink.WindowStyle = 2
oShellLink.IconLocation = pa & "\开始游戏.exe, 0"
oShellLink.WorkingDirectory = pa
oShellLink.Save
[
Last edited by Hanyeguxing on 2010-6-15 at 12:01 ]
作者: kidzgy
时间: 2010-6-15 18:30
这样用BAT建立快捷方式比建立*.url就好得多了。
也用不着ECHO来输出VBS来建立快捷方式了。
以前我以为没办法直接调用VBS来建立快捷方式,因为换行的代码太多了。
作者: HAT
时间: 2010-6-15 20:03
标题: Re 3 楼
也可以在BAT里面调用mshat来创建.lnk,不一定要生成临时的VBS。
.url就更简单了,echo几下就行了,更用不着VBS。
作者: kidzgy
时间: 2010-6-15 21:56
url本来是个网址的形式的,根本不具有lnk快捷方式所具有的性质.所以要建立桌面图标尽量还是要lnk的好.
我想知道怎么调用mshat来建立lnk呢?能举个例子吗?
作者: sun2052
时间: 2010-6-16 12:20
@echo off
set str=%*
call set str=%%str:%1=%%
mshta.exe VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\%~n1.lnk""):b.TargetPath=""%~1"":b.Arguments=""%str%"":b.WorkingDirectory=""%~dp1"":b.Save:close")
::Arguments 目标程序参数
::Description 快捷方式备注
::FullName 返回快捷方式完整路径
::Hotkey 快捷方式快捷键
::IconLocation 快捷方式图标,不设则使用默认图标
::TargetPath 目标
::WindowStyle 窗口启动状态
::WorkingDirectory 起始位置
作者: Hanyeguxing
时间: 2010-6-16 13:28
Quote: |
Originally posted by kidzgy at 2010-6-15 21:56:
url本来是个网址的形式的,根本不具有lnk快捷方式所具有的性质.所以要建立桌面图标尽量还是要lnk的好.
我想知道怎么调用mshat来建立lnk呢?能举个例子吗? |
|
url和和lnk本身不同,所以不存在谁比谁好的问题