利用批处理(bat)快速启动工具

最近浏览器主页总是被劫持再加上桌面快捷方式越来越多,又苦于没找到是哪个软件在作祟。于是想出自己写一个批处理文件来启动程序

先来张成品图

成品图

开始

:method
@echo off
rem 启动软件
cd /D "软件的路径"
start 软件.exe

上面method这个函数就是具体打开哪一个程序,下面是主界面
你可以使用系统的choice函数,或者直接使用自定义函数。如果再给你的批处理文件配置一个环境变量 ps:如果觉得配置环境变量麻烦的话直接copy一份放到system32目录下,然后直接用win+r启动就可以让你摆脱鼠标啦~ 效率杠杠的

@echo off
TITLE 一键启动 by Airmour
mode con lines=30 cols=75
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
:main
cls
color 3f
echo.                                          
echo.                       Quickly Launcher                       ___/\
echo.                                                              \o.O/
echo.                                                              (___)
echo.                                                               U   
echo.---------------------------------------------------------------------------
echo.请选择使用: 
echo.
echo. A. Android Studio          B. BingDict                C. Chrome
echo. D. Dism++                                             F. FireFox
echo. G. Genymotion              H. 火绒                    I. Intellij IDEA
echo. J                          K                          L
echo. M                          N                          O
echo. P. PhotoShop               Q. QQ                      R
echo. S                          T. TeamViewer              U
echo. V. VMware                  W                          X
echo. Y. Evernote                Z                          1. Eclipse--ADT
echo. 2. Eclipse--EE             3. Eclipse                 4                  
echo.                                                                   E. 退出 
echo.---------------------------------------------------------------------------

choice /c abcdefghijklmnopqrstuvwxyz1234567 /n /m "请输入相应索引:"

if %errorlevel%==1 goto androidStudio
if %errorlevel%==2 goto bingDict
if %errorlevel%==3 goto chrome
if %errorlevel%==4 goto dism
if %errorlevel%==5 goto end
if %errorlevel%==6 goto f
if %errorlevel%==7 goto Genymotion
if %errorlevel%==8 goto huoRong
if %errorlevel%==9 goto IDEA
cls
goto main

简单解释一下choice函数/c 后面的字母表示按键对应的errorlevel的等级,
比如第一个字母对应的errorlevel的等级就是1 以此类推。

更多窗口的颜色,让你的批处理与众不同

颜色属性由两个十六进制数字指定 
第一个为背景,
第二个则为前景
每个数字可以为以下任何值之一:

   0 = 黑色       8 = 灰色
   1 = 蓝色       9 = 淡蓝色
   2 = 绿色       A = 淡绿色
   3 = 湖蓝色     B = 淡浅绿色
   4 = 红色       C = 淡红色
   5 = 紫色       D = 淡紫色
   6 = 黄色       E = 淡黄色
   7 = 白色       F = 亮白色

全部代码


@echo off
TITLE 一键启动 by Airmour
mode con lines=30 cols=75
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
:main
cls
color 3f
echo.                                          
echo.                       Quickly Launcher                       ___/\
echo.                                                              \o.O/
echo.                                                              (___)
echo.                                                               U   
echo.---------------------------------------------------------------------------
echo.请选择使用: 
echo.
echo. A. Android Studio          B. BingDict                C. Chrome
echo. D. Dism++                                             F. FireFox
echo. G. Genymotion              H. 火绒                    I. Intellij IDEA
echo. J                          K                          L
echo. M                          N                          O
echo. P. PhotoShop               Q. QQ                      R
echo. S                          T. TeamViewer              U
echo. V. VMware                  W                          X
echo. Y. Evernote                Z                          1. Eclipse--ADT
echo. 2. Eclipse--EE             3. Eclipse                 4                  
echo.                                                                   E. 退出 
echo.---------------------------------------------------------------------------

choice /c abcdefghijklmnopqrstuvwxyz1234567 /n /m "请输入相应索引:"

if %errorlevel%==1 goto androidStudio
if %errorlevel%==2 goto bingDict
if %errorlevel%==3 goto chrome
if %errorlevel%==4 goto dism
if %errorlevel%==5 goto end
if %errorlevel%==6 goto f
if %errorlevel%==7 goto Genymotion
if %errorlevel%==8 goto huoRong
if %errorlevel%==9 goto IDEA
if %errorlevel%==10 goto j
if %errorlevel%==11 goto k
if %errorlevel%==12 goto l
if %errorlevel%==13 goto m
if %errorlevel%==14 goto n
if %errorlevel%==15 goto o
if %errorlevel%==16 goto photoShop
if %errorlevel%==17 goto qq
if %errorlevel%==18 goto r
if %errorlevel%==19 goto s
if %errorlevel%==20 goto teamView
if %errorlevel%==21 goto u
if %errorlevel%==22 goto VMware
if %errorlevel%==23 goto w
if %errorlevel%==24 goto x
if %errorlevel%==25 goto everNote
if %errorlevel%==26 goto z
if %errorlevel%==27 goto 1
if %errorlevel%==28 goto 2
if %errorlevel%==29 goto 3
if %errorlevel%==30 goto 4
cls
goto main

:androidStudio
cls
color 3f
rem 启动AndroidStudio
cd /D "D:\Android\Android Studio\bin"
start studio.exe
goto end

:teamView
cls
color 3f
rem 启动TeamView
cd /D "D:\SoftWare\TeamViewer"
start TeamViewer.exe
goto end

:Genymotion
cls
color 3f
rem 启动Genymotion
cd /D "D:\SoftWare\Genymotion"
start genymotion.exe
goto end

:photoShop
cls
color 3f
rem 启动PhotoShop
cd /D "D:\SoftWare\PhotoShop\Adobe Photoshop CS6"
start Photoshop.exe
goto end

:bingDict
cls
color 3f
rem 启动必应词典
cd /D "D:\SoftWare\Bing Dictionary"
start BingDict.exe
goto end

:dism
cls
color 3f
rem 启动Dism
cd /D "D:\SoftWare\Dism++"
start Dism++x64.exe
goto end


:IDEA
cls 
color 3f 
rem 启动IDEA
cd /D "D:\SoftWare\IntelliJ IDEA\bin"
start idea.exe
goto end

:huoRong
cls 
color 3f 
rem 启动火绒
cd /D "D:\SoftWare\Huorong\Huorong\Sysdiag\bin"
start HipsMain.exe
goto end

:everNote
cls
color 3f
rem 启动印象笔记
cd /D "D:\SoftWare\Evernote"
start Evernote.exe
goto end

:ADT
cls
color 3f
rem 启动ADT
cd /D "D:\Android\adt-bundle-windows-x86_64_20140101\eclipse"
start eclipse.exe
goto end

:fireFox
cls
color 3f
rem 启动火狐浏览器
cd /D "D:\SoftWare\Firefox"
start firefox.exe
goto end

:chrome
cls
color 3f
rem 启动Chrome
cd /D "C:\Program Files (x86)\Google\Chrome\Application"
start chrome.exe
goto end


:java-ee
cls
color 3f
rem 启动 Eclipse-EE
cd /D "D:\eclipse-ee"
start eclipse.exe
goto end


:java
cls
color 3f
rem 启动 Eclipse
cd /D "D:\eclipse"
start eclipse.exe
goto end

:sqlite
cls
color 3f
rem 启动 Eclipse
cd /D "D:\SoftWare\SQLite"
start SQLiteExpertPers64.exe
goto end

:qq
cls
color 3f
rem 启动 QQ
cd /D "D:\SoftWare\QQLite\Bin"
start QQScLauncher.exe
goto end

:VMware
cls
color 3f
rem 启动 VMware
cd /D "D:\SoftWare\VMware"
start vmware.exe
goto end

:end
#结束程序
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 个人学习批处理的初衷来源于实际工作;在某个迭代版本有个BS(安卓手游模拟器)大需求,从而在测试过程中就重复涉及到...
    Luckykailiu阅读 4,779评论 0 11
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,933评论 18 139
  • dos 批处理 一:windows的命令行模式(win+R)在里面写CMD就可以进入windows的命令行模式了二...
    chenchao981阅读 777评论 0 6
  • 从三月份找实习到现在,面了一些公司,挂了不少,但最终还是拿到小米、百度、阿里、京东、新浪、CVTE、乐视家的研发岗...
    时芥蓝阅读 42,366评论 11 349
  • 《智养》P121-154 梅子著 信笺&书签: 1.玩具是孩子的第一本教科书 玩具不仅可以增加孩子的生活情趣、丰...
    玲玲A阅读 252评论 0 0