shotcut.bat
@echo off call :create_shortcut "Z:\port\d\7-Zip\" 7zFM.exe C:\Users\eu\Desktop\ 7z pause exit :create_shortcut set src_dir=%1% set src_file=%2% set dst_dir=%3% set dst_file=%4% echo "%src_dir%%src_file% => %dst_dir%%dst_file%" shotcut_func.vbs %src_dir% %src_file% %dst_dir% %dst_file% rem echo [InternetShortcut] >> %shortcut% rem echo URL="%source%" >> %shortcut% rem echo IconFile=%source% >> %shortcut% rem echo IconIndex=20 >> %shortcut% |
shotcut_func.vbs
src_dir = wscript.arguments(0) src_file = wscript.arguments(1) dst_dir = wscript.arguments(2) dst_file = wscript.arguments(3) Set oWS = WScript.CreateObject("WScript.Shell") sLinkFile = dst_dir + dst_file + ".lnk" Set oLink = oWS.CreateShortcut(sLinkFile) oLink.TargetPath = src_dir + src_file ' optional shortcut properties ' oLink.Arguments = "" ' oLink.IconLocation = src_dir + src_file + ", 2" ' oLink.WindowStyle = "1" oLink.WorkingDirectory = src_dir oLink.Save |
refresh_icons.bat
taskkill /f /im explorer.exe attrib -h -s -r "%userprofile%\AppData\Local\IconCache.db" del /f "%userprofile%\AppData\Local\IconCache.db" attrib /s /d -h -s -r "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_102.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1024.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db" echo y | reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v IconStreams echo y | reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v PastIconsStream start explorer |
refer to:
https://serverfault.com/questions/171775/create-a-windows-shortcut-through-a-batch-file-bat
https://wenwen.sogou.com/z/q813141367.htm
https://www.2cto.com/kf/201307/225348.html
https://zhuanlan.zhihu.com/p/72426926