命令行创建快捷方式的批处理脚本

摘要:
1、 例如,为记事本创建桌面快捷方式setpath=%WINDIR%记事本。exesetopath=“%USERPROFILE%桌面记事本.url”echo[InternetShortcut]>Rem在桌面上创建记事本快捷方式setoShellLink=WshShell。创建快捷方式(strDesktop&

    从网上搜集了一些“创建快捷方式”的批处理脚本,以供将来工作中参考:

一、示例为创建记事本的快捷方式到桌面

set path=%WINDIR%\notepad.exe
set topath="%USERPROFILE%\桌面\记事本.url"
echo [InternetShortcut] >> %topath%
echo URL="%path%" >> %topath%
echo IconIndex=0 >> %topath%
echo IconFile=%path% >> %topath%

二、利用批处理创建桌面快捷方式

goto :eof
Rem 以下为VbScript脚本
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop") :'特殊文件夹“桌面”
Rem 在桌面创建一个记事本快捷方式
set oShellLink = WshShell.CreateShortcut(strDesktop & "\记事本.lnk")
oShellLink.TargetPath = "notepad.exe" : '目标
oShellLink.WindowStyle = 3 :'参数1默认窗口激活,参数3最大化激活,参数7最小化
oShellLink.Hotkey = "Ctrl+Alt+e" : '快捷键
oShellLink.Ic : '图标
oShellLink.Description = "记事本快捷方式" : '备注
oShellLink.WorkingDirectory = strDesktop : '起始位置
oShellLink.Save : '创建保存快捷方式
Rem 在桌面创建一个 腾讯QQ 2007
set oShellLink = WshShell.CreateShortcut(strDesktop & "\腾讯QQ 2007 .lnk")
oShellLink.TargetPath = "D:\Tencent\QQ\QQ.exe" : '目标
oShellLink.WindowStyle = 3 :'参数1默认窗口激活,参数3最大化激活,参数7最小化
oShellLink.Hotkey = "Ctrl+Alt+q" : '快捷键
oShellLink.Ic : '图标
oShellLink.Description = "腾讯QQ 2007" : '备注
oShellLink.WorkingDirectory = strDesktop : '起始位置
oShellLink.Save : '创建保存快捷方式
Rem 在桌面创建一个“微软中国”的Url快捷方式
set oUrlLink = WshShell.CreateShortcut(strDesktop & "\百度搜索.url")
oUrlLink.TargetPath = "http://www.baidu.com/"
oUrlLink.Save

三、批处理桌面创建快捷方式

EXE型

S bat
echo off & cls
echo create_shortcut
start wscript -e:vbs "%~f0"
Exit S
End S

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\QQ.lnk")
oShellLink.TargetPath = "d:\QQ\QQ.exe"
oShellLink.WindowStyle = 3
oShellLink.Hotkey = "Ctrl+Alt+e"
oShellLink.IconLocation = "d:\QQ\QQ.exe, 0"
oShellLink.Description = "快捷方式"
oShellLink.WorkingDirectory = "d:\QQ"
oShellLink.Save

IP型

S bat
echo off & cls
echo create_shortcut
start wscript -e:vbs "%~f0"
Exit S
End S

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\学习天地.lnk")
oShellLink.TargetPath = "http://localhost:81"
oShellLink.WindowStyle = 3
oShellLink.Hotkey = "Ctrl+Alt+e"
oShellLink.IconLocation = "%SystemRoot%\system32\url.dll, 0"
oShellLink.Description = "快捷方式"
oShellLink.WorkingDirectory = "C:\Program Files\Internet Explorer"
oShellLink.Save

四、

set path=E:\other\QQ\qq.exe 
echo [InternetShortcut] >>QQ.url 
echo URL="%path%" >>QQ.url 
echo IconIndex=0 >>QQ.url 
echo IconFile=E:\other\QQ\qq.exe >>QQ.url 

五、在桌面上创建某网站的快捷方式

@echo off
set lnkdir="%USERPROFILE%\桌面"
echo [InternetShortcut] >%lnkdir%\冲浪奥运专题.url
echo [InternetShortcut] >%lnkdir%\冲浪奥运频道.url
echo URL="http://www.cctvolympics.com" >>%lnkdir%\冲浪奥运专题.url
echo URL="http://www.fm73.com/dianshi/001/cctv5.htm" >>%lnkdir%\冲浪奥运频道.url
exit

六、

先来看看小文的.
@echo off
for /f "delims=" %%i in ("%cd%") do (
echo [InternetShortcut] >>"%USERPROFILE%\桌面\r.url"
echo URL="%%i\blog_backup.exe" >>"%USERPROFILE%\桌面\r.url"
echo IconIndex=0 >>"%USERPROFILE%\桌面\r.url"
echo IconFile="%%i\blog_backup.exe" >>"%USERPROFILE%\桌面\r.url"
)

开始没仔细看.后来试了一下,原来是利用了file(本地文件传输协议),但有个缺点,ie会把文件加载到ie缓存文件夹中执行,所以当为需要多个文件才能执行的绿色文件创建快捷方式时,运行会出错.

在来看看我的那个(不是我写的,在知道上看到的,分析后改的)
又改了,可以将任意文件拖放到该文件上,即可自动创建快捷方式,不需更改代码.
这个代码应该是里利用winrar的自解压功能,具体也没研究出来,贴上用到的rar命令行参数说明

@echo off
for %%a in (%1) do (
echo Path=%%~dpa>test.txt
echo Silent=^2>>test.txt
echo Overwrite=^1>>test.txt
echo Shortcut=D, %%~nxa, "\", %%a, %%~na>>test.txt
start /wait winrar.exe a -r -ep1 -m1 -sfx -ztest.txt test.exe %0
start /wait test.exe
del test.*
)



   ::         -r      包含子文件夹,可以使用命令:
    ::        a,u,f,m,x,e,t,p,v,l,c,cf 和 s.

   ::         当使用命令 'a','u','f','m' 将处理在所有子目录中以及当前工作目
    ::        录的中的文件。

::          当使用命令 x,e,t,p,v,l,c,cf 或 s 将处理在子目录以及当前工
   ::         作目录中所有压缩文件。
  
  
  
   ::     -ep1    从文件名中删除底层目录。不存储在命令行中输入的路径。

     ::       例子:

      ::      tmp 目录中的所有文件和目录都将被添加到压缩文件'test'中,但是被压
     ::       缩文件名路径不包含'tmp\'

      ::      rar a -ep1 -r test tmp\*

     ::       这等价于下列命令:

     ::       cd tmp
      ::      rar a -r ..\test
      ::      cd ..
     
     
      ::-m1   最快      使用最快方式(低压缩)
     
     
     
   ::   -sfx[名称]
    ::        创建自解压压缩文件。如果建立新压缩文件时使用此开关,自解压文件(使
   ::         用 default.sfx 模块或在开关中指定)将被创建。在 Windows 版本中,
    ::        default.sfx 应该在 rar.exe 所在的目录中,在 Unix 中 - 在用户的 home
   ::         目录中。在/usr/lib 或 /usr/local/lib 中。

   ::         例子:

    ::        rar a -sfxwincon.sfx myinst

    ::        使用 wincon.sfx 自解压模块创建自解压(SFX)压缩文件。
   
   
   
   
::        -z[f]   从文件<f>中读取压缩文件注释。如果你需要指定注释文本文件的字符
::         集使用 -sc 开关。如果 <f> 没有指定, 注释从标准输入设备读取。

免责声明:文章转载自《命令行创建快捷方式的批处理脚本》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Linux 根目录所在分区被脏数据占满python png与jpg的相互转换下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

echarts柱状图多组数据配置

一共三组数据 var map4_data1=[320, 332, 301, 334, 390,360,320, 332, 301, 334, 390,360]; var map4_data2=[220, 182, 191, 234, 290,320,220, 182, 191, 234, 290,320]; var map4_data3=[150, 232...

Element-ui局部添加loading效果

项目:Vue+element-ui 在一个表格数据加载时,因为需要连接其它东西,所以后台接口返回数据需要较长时间,因此添加局部Loading效果,增加用户体验度, 最开始使用下面代码,直接放到<el-table>中,测试时遇到问题 element-loading-spinner="el-icon-loading" :element-loadin...

PyMySQL模块

  PyMySQL是Python操作数据库的模块,在Python3.x版本中用于连接MySQL服务器,即作为Python操作MySQL数据库对象的接口。 安装PyMySQL   pip3 install PyMySQL 导入PyMySQL   import pymysql 连接数据库   格式:conn = pymysql.connect(host=' '...

使用 vue3 的自定义指令给 element-plus 的 el-dialog 增加拖拽功能

element-plus 提供的 el-dialog 对话框功能非常强大,只是美中不足不能通过拖拽的方式改变位置,有点小遗憾,那么怎么办呢?我们可以通过 vue 的自定义指令来实现一个可以拖拽的对话框(el-dialog)。 拖拽演示 https://www.zhihu.com/zvideo/1380450791975731200 vue3 的自定义指令...

vue+elementui 中 @keyup 键盘上下左右移动聚焦

            <template>             <el-table :data="CreditUnclearOutlineList" border style=" 100%" ref="table"> <el-table-co...

php 做支付宝电脑网站和app支付

首先支付宝的文档真是看得头晕眼花,摸不着北的感觉,网上百度PHP支付宝一堆都是花里胡哨的,看得一脸懵逼。所以自己整理了一下,其实也没那么复杂直接上代码: php 电脑支付的方法: /** * 支付宝支付 *$order_sn 单号 $total_amount 价格 */ public function ali...