Batch, create a shortcut to the file, more convenient it is to call vbs script. Combined for command, you can create a shortcut to batch multiple files. Use function Winrar software, can more easily create self-extracting install the software.
File encoding batch file to ANSI, or GB2312. Otherwise the Chinese will be garbled.
A single file to create a shortcut
If you use the Chrome 75 MyChrome green portability to D: \ programfiles \ Chrome75 folder, the executable file is MyChrome.exe. Create the following MyChrome.exe shortcut and send it to the desktop, creating "Google Browser" in the program group, including MyChrome.exe shortcuts.
@echo off
::如无:快捷文件以.lnk或.url结尾
setlocal EnableDelayedExpansion
cd Chrome75
set WrkDir=%~dp0
set "LinkName=谷歌浏览器.lnk"
set filname=mychrome.exe
set ThePath=%~dp0%mychrome.exe
mshta VBScript:Execute("Set Shell=CreateObject(""WScript.Shell""):Set Link=Shell.CreateShortcut(""!LinkName!""):Link.TargetPath=""!ThePath!"":Link.WorkingDirectory=""!WrkDir!"":Link.Save:close"^)
if exist "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\谷歌浏览器" (
del /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\谷歌浏览器"
) else (
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\谷歌浏览器"
)
copy /y 谷歌浏览器.lnk "%USERPROFILE%\Desktop\" >nul 2>nul
move /y *.lnk "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\谷歌浏览器\" >nul 2>nul
In the latter due to the self-extracting file, save the batch is named "Chrome self-extracting installation .bat", placed in the directory MyChome.exe located. Click Run will be able to meet the design requirements.
Batch, created directly MyChrome.exe shortcut "Google Browser .lnk" in the current directory. Next, create a program group of the Start menu. Copy the shortcut to the desktop, and then move the shortcut to the program group file folder.
You can also create a shortcut directly on the desktop, and then copy the shortcut to the file in the program group.
setlocal EnableDelayedExpansion
There must be, otherwise it will prompt ".lnk shortcut files ending or .url" error.
Simple way
If you just want to create a desktop shortcut MyChrome.exe, the easiest way is as follows (note that does not require setlocal EnableDelayedExpansion
):
@echo off
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\谷歌浏览器.lnk""):b.TargetPath=""%~dp0MyChrome.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")
Multiple batch files to create a shortcut
Assume that you want to create a shortcut of the file "Heroes magic awakening" in the. Claim:
- The desktop is the main program
h3era HD.exe
shortcut - Program Group "magic Awakening" contains shortcuts to the following files:
h3era HD.exe
h3era_34M HD.exe
h3era_43M HD.exe
Tools\Mod Manager\mmanager.exe
Tools\ERM&ERA帮助宝典v2.0 (测试).chm
HD3_Launcher.exe
Magic awakening folder D:\ProgramFiles\gs\Hero3_The_Magic_Awakens\
, which is h3era HD.exe
(or h3era.exe
/ Heroes3.exe
file) is located.
The following batch or txt files are saved in the magic of the awakening folder.
MagAwaken.txt
First create a txt file "MagAwaken.txt", reads as follows:
魔力觉醒:h3era HD.exe
魔力觉醒34M:h3era_34M HD.exe
魔力觉醒43M:h3era_43M HD.exe
MOD管理器:Tools\Mod Manager\mmanager.exe
ERM&ERA帮助宝典v2:Tools\ERM&ERA帮助宝典v2.0 (测试).chm
高清补丁:HD3_Launcher.exe
Batch MagAwaken.bat
Batch file MagAwaken.bat
, as follows:
@echo off
rem 快捷方式 by [email protected](开心鲨鱼@qq)
color 0a
title “英雄无敌WOG之魔力觉醒” 快捷方式 by [email protected](开心鲨鱼@qq)
cd Hero3_The_Magic_Awakens
set WrkDir=%~dp0
setlocal EnableDelayedExpansion
for /f "delims=: tokens=1,*" %%a in (MagAwaken.txt) do (
set LinkName=%%a.lnk
set filname=%%b
set ThePath=%~dp0%%b
mshta VBScript:Execute("Set Shell=CreateObject(""WScript.Shell""):Set Link=Shell.CreateShortcut(""!LinkName!""):Link.TargetPath=""!ThePath!"":Link.WorkingDirectory=""!WrkDir!"":Link.Save:close"^)
)
if exist "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\英雄无敌WOG之魔力觉醒" (
del /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\英雄无敌WOG之魔力觉醒"
) else (
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\英雄无敌WOG之魔力觉醒"
)
copy /y 魔力觉醒.lnk "%USERPROFILE%\Desktop\" >nul 2>nul
move /y *.lnk "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\英雄无敌WOG之魔力觉醒\" >nul 2>nul
Application in Winrar self-extracting file
How to make a self-extracting file with Winrar?
- Right folder and select "Add to archive ..."
- In the "Compression Options" "General" tab item, check the file "to create self-extracting compressed file format", then "compressed file name" at the extension exe
- If no special requirements or configuration, and click OK. Otherwise, see the next step
- Switch to the "Advanced" tab, click on the "self-extracting file option ..."
- "Advanced SFX options", click "Settings" tab, enter the program after extraction is completed to be run in batch or "unzip or run"
- Other Options tab, not be discussed.
The following self-extracting combine to make Chrome instructions.
- Make sure to start saving files
Chrome自解压安装.bat
inD:\programfiles\Chrome75
folders. - Into the
D:\programfiles\
folder, wherein the rightChrome75
folder, as shown in the above steps. - In the fifth step above, the input is provided
Chrome75\Chrome自解压安装.bat
to. - Get self-extracting file
D:\programfiles\Chrome75.exe
- Test: Double-click Chrome75.exe, point "Extract" (default "destination folder" is
D:\
), extract the files and getD:\Chrome75
, and generate the shortcuts and the program group.
Above Additional information:
- When extracting, Winrar will enter the specified "Destination Folder", the default here "destination folder" Yes
D:\
. - According to the compression settings, run the file specified. Here is a run
Chrome75\Chrome自解压安装.bat
. Note that the position is stillD:\
, did not enter theD:\Chrome75
folder. So batch, did not comment outcd Chrome75
(does not affect the results of the previous batch)