利用桌面“創(chuàng)建桌面快捷方式.bat"為Nessus_start.bat創(chuàng)建以nessus_favicon.ico為圖標(biāo)的快捷方式
具體如下:
chcp 936
REM 設(shè)置936編碼防止某些中文路徑導(dǎo)致批處理失效
@echo off
setlocal enabledelayedexpansion
mode con cols=94 lines=30&color 0a&title 創(chuàng)建Nessus一鍵啟動(dòng)腳本快捷方式
echo.
echo [+] 獲得當(dāng)前路徑:%~dp0
set path=%~dp0Nessus_start.bat
echo.
if exist %path% (
echo [+] 發(fā)現(xiàn)Nessus一鍵啟動(dòng)腳本Nessus_start.bat
echo.
echo [+] 啟動(dòng)腳本路徑:
echo.
echo [+] %path%
echo.
goto :creat
) else (
echo [-] 注意,未發(fā)現(xiàn)啟動(dòng)腳本Nessus_start.bat煤率,請(qǐng)注意是否改名,程序退出...
echo.
pause
exit
)
:creat
echo [+] 開(kāi)始創(chuàng)建快捷方式...
echo.
rem 設(shè)置程序的完整路徑(必要)
set Program=%path%
rem 設(shè)置快捷方式名字(必要)
set LinkName=Nessus
rem 程序工作路徑
set WorkDir=%~dp0
rem 設(shè)置快捷方式說(shuō)明
set Desc=Nessus漢化版一鍵啟動(dòng)
rem 設(shè)置快捷方式圖標(biāo)
set icon=%~dp0/nessus_favicon.ico
if not defined WorkDir call:GetWorkDir "%Program%"
(echo Set WshShell=CreateObject("WScript.Shell"^)
echo strDesKtop=WshShell.SpecialFolders("DesKtop"^)
echo Set oShellLink=WshShell.CreateShortcut(strDesKtop^&"\%LinkName%.lnk"^)
echo oShellLink.TargetPath="%Program%"
echo oShellLink.WorkingDirectory="%WorkDir%"
echo oShellLink.WindowStyle=1
echo oShellLink.Description="%Desc%"
echo oShellLink.IconLocation="%icon%"
echo oShellLink.Save)>makelnk.vbs
echo [+] 桌面快捷方式創(chuàng)建成功!!
echo.
makelnk.vbs
del /f /q makelnk.vbs
pause
goto :eof
:GetWorkDir
set WorkDir=%~dp1
set WorkDir=%WorkDir:~,-1%
pause
goto :eof
其中有關(guān)Nessus_start.bat和nessus_favicon.ico可以自由替換為各種可以直接通過(guò)命令行打開(kāi)的文件夾晌砾,可執(zhí)行程序等
效果如下