加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

在Windows上创建桌面链接的脚本?

发布时间:2020-12-13 22:40:13 所属栏目:Windows 来源:网络整理
导读:参见英文答案 creating a shortcut for a exe from a batch file????????????????????????????????????9个 我考虑在Windows机器上创建桌面链接的简单脚本或例程.有没有办法用perl或cmd批处理? 就像我一样 call shortcut.bat C:putty.exe Putty 桌面上会出
参见英文答案 > creating a shortcut for a exe from a batch file????????????????????????????????????9个
我考虑在Windows机器上创建桌面链接的简单脚本或例程.有没有办法用perl或cmd批处理?

就像我一样

call shortcut.bat C:putty.exe Putty

桌面上会出现一个新的桌面链接.

解决方法

将其保存为shortcut.bat

@echo off

:: creates a temporary vbs script that drops a shortcut to the desktop
:: replace %1 with the path to your *.exe that you wish to shortcut
:: replace %userprofile%Desktop%2.lnk with the path and name of your shortcut
ECHO %userprofile%Desktop%2.lnk

:: CHECK FOR EXISTING myshortcut.vbs SCRIPT AND DELETE
cd %userprofile%Desktop
    if exist %userprofile%Desktopmyshortcut.vbs del %userprofile%Desktopmyshortcut.vbs

:: CREATE myshortcut.vbs FILE CONTAINING ALL COMMANDS for the vb script to create a shortcut of your file

FOR /F "tokens=1* delims=;" %%B IN ("Set oWS = WScript.CreateObject("WScript.Shell")") do echo %%B>>%userprofile%Desktopmyshortcut.vbs   
FOR /F "tokens=1* delims=;" %%B IN ("sLinkFile = "%userprofile%Desktop%2.lnk"") do echo %%B>>%userprofile%Desktopmyshortcut.vbs

FOR /F "tokens=1* delims=;" %%B IN ("Set oLink = oWS.Createshortcut(sLinkFile)") do echo %%B>>%userprofile%Desktopmyshortcut.vbs
FOR /F "tokens=1* delims=;" %%B IN ("   oLink.TargetPath = "%1"") do echo %%B>>%userprofile%Desktopmyshortcut.vbs
FOR /F "tokens=1* delims=;" %%B IN ("   '   oLink.Arguments = """) do echo %%B>>%userprofile%Desktopmyshortcut.vbs
FOR /F "tokens=1* delims=;" %%B IN ("   '   oLink.Description = """) do echo %%B>>%userprofile%Desktopmyshortcut.vbs
FOR /F "tokens=1* delims=;" %%B IN ("   '   oLink.HotKey = "ALT+CTRL+F"") do echo %%B>>%userprofile%Desktopmyshortcut.vbs
FOR /F "tokens=1* delims=;" %%B IN ("   '   oLink.IconLocation = "%1,2"") do echo %%B>>%userprofile%Desktopmyshortcut.vbs
FOR /F "tokens=1* delims=;" %%B IN ("   '   oLink.WindowStyle = "1"") do echo %%B>>%userprofile%Desktopmyshortcut.vbs
FOR /F "tokens=1* delims=;" %%B IN ("   '   oLink.WorkingDirectory = "%1"") do echo %%B>>%userprofile%Desktopmyshortcut.vbs
FOR /F "tokens=1* delims=;" %%B IN ("   oLink.Save") do echo %%B>>%userprofile%Desktopmyshortcut.vbs

:: EXECUTE myshortcut.vbs
CSCRIPT %userprofile%Desktopmyshortcut.vbs

:: Delete vbs script
del %userprofile%Desktopmyshortcut.vbs

exit

用它就像

call shortcut.bat C:PROGRA~2TeraTermttermpro.exe TeraTerm >nul

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读