Advertisement
alexusfree2

Создать ярлык.bat

Dec 16th, 2023 (edited)
1,722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Winbatch 2.15 KB | Source Code | 0 0
  1. @echo off
  2. ChCp 1251 >nul
  3. cd /d "%~dp0"
  4. call :SetupLinkTo
  5. for /f "eol=; tokens=2* delims=:, " %%a in ('type "%cd%\Launcher\launcher-settings.json"^|find "version"') do set version=%%a
  6. set version=%version:"=%
  7. rem call :LinkTest "%userprofile%\Desktop\Cities Skylines II.lnk" "%cd%\Cities 2.exe" "" "%cd%\Cities2.exe" "%cd%\test 2" "Cities: Skylines II %version%"
  8. LinkTo.vbs "%userprofile%\Desktop\Cities Skylines II.lnk" "%cd%\Cities2.exe" "" "%cd%\Cities2.exe" "%cd%\" "Cities: Skylines II (%version%)"
  9.  
  10. exit
  11. :SetupLinkTo
  12. set CreateLinkTo="%userprofile%\AppData\Local\Microsoft\WindowsApps\LinkTo.vbs"
  13. rem if not exist %CreateLinkTo% call :CreateLinkTo > %CreateLinkTo%
  14. call :CreateLinkTo > %CreateLinkTo%
  15. goto :EOF
  16. :LinkTest
  17. echo. CreateShortcut  %1
  18. echo. TargetPath      %2
  19. echo. Arguments       %3
  20. echo. IconLocation    %4
  21. echo. WorkingDir      %5
  22. echo. Description     %6
  23. pause
  24. goto :EOF
  25. :CreateLinkTo
  26. @echo off
  27. echo On Error resume next
  28. echo if WScript.Arguments.Count ^< 2 then
  29. echo     WScript.Echo "Command line:" ^& VbCrLf ^& "LnkTo.vbs CreateShortcut TargetPath Arguments IconLocation WorkingDirectory Description"
  30. echo     WScript.Quit 1
  31. echo end if
  32. echo Set oWS    = WScript.CreateObject^("WScript.Shell")
  33. echo Set oLink = oWS.CreateShortcut(Wscript.Arguments(0))
  34. echo oLink.TargetPath = Wscript.Arguments(1)
  35. echo if WScript.Arguments.Count ^> 2 Then oLink.Arguments = Wscript.Arguments(2)  ' Аргументы командной строки
  36. echo if WScript.Arguments.Count ^> 3 Then oLink.IconLocation = Wscript.Arguments(3)  ' Путь к файлу иконки для ярлыка
  37. echo if WScript.Arguments.Count ^> 4 Then oLink.WorkingDirectory = Wscript.Arguments(4)  ' Рабочая папка
  38. echo if WScript.Arguments.Count ^> 5 Then oLink.Description = Wscript.Arguments(5)  ' Комментарий
  39. rem  if WScript.Arguments.Count ^> 6 Then oLink.Hotkey = Wscript.Arguments(6)  ' Клавиши быстрого вызова "CTRL+SHIFT+F"
  40. rem  if WScript.Arguments.Count ^> 7 Then oLink.WindowStyle = Wscript.Arguments(7)  ' Стиль окна: 1-Обычное; 3-Развёрнутое; 7-Свёрнутое
  41. echo oLink.Save
  42. goto :EOF
Tags: bat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement