0

I have a python file, which is... supposed to be an app. I found out that if I put a shortcut of it in the

"C:\Users\xxxxxxxxx\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools"

section, that I would be able to put it in the application list, and the system would detect is as an app. The python file will be a game kind of thing, and if others install it, it would be better if there was just another python file that creates the shortcut in the destination.
But.
I do not know how to do this with python.
I tried this:

import win32com.client
import getpass
from time import sleep
user = getpass.getuser()
import pythoncom
import os
# pythoncom.CoInitialize() # remove the '#' at the beginning of the line if 
running in a thread.
desktop = r'C:/Users/' + user + '/AppData/Roaming/Microsoft/Windows/Start 
Menu/Programs/System Tools' # path to where you want to put the .lnk
path = os.path.join(desktop, 'Skulk.lnk')
target = r'C:/Users/' + user + '/main.py'

shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WindowStyle = 7  # 7 - Minimized, 3 - Maximized, 1 - Normal
shortcut.save()
print("Success!")
sleep(3)

If it is, could you please tell me how to do it?

Any help would be greatly appreciated.

0 Answers0