create_shortcut.py 676 B

12345678910111213141516171819202122232425
  1. import os
  2. import winshell
  3. from win32com.client import Dispatch
  4. def create_shortcut():
  5. # creates shortcut
  6. desktop = winshell.desktop()
  7. path = os.path.join(desktop, "Predespacho Regional.lnk")
  8. target = os.path.join(
  9. os.environ["LOCALAPPDATA"], "Merelec", "spr", "run.bat")
  10. wDir = desktop
  11. icon = os.path.join(os.environ["LOCALAPPDATA"],
  12. "Merelec", "spr", "app.ico")
  13. shell = Dispatch('WScript.Shell')
  14. shortcut = shell.CreateShortCut(path)
  15. shortcut.Targetpath = target
  16. shortcut.WorkingDirectory = wDir
  17. shortcut.IconLocation = icon
  18. shortcut.save()
  19. if __name__ == "__main__":
  20. create_shortcut()