create_shortcut.py 736 B

1234567891011121314151617181920212223242526
  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 = os.path.join(
  11. os.environ["LOCALAPPDATA"], "Merelec", "spr")
  12. icon = os.path.join(os.environ["LOCALAPPDATA"],
  13. "Merelec", "spr", "app.ico")
  14. shell = Dispatch('WScript.Shell')
  15. shortcut = shell.CreateShortCut(path)
  16. shortcut.Targetpath = target
  17. shortcut.WorkingDirectory = wDir
  18. shortcut.IconLocation = icon
  19. shortcut.save()
  20. if __name__ == "__main__":
  21. create_shortcut()