오래되었지만 같은 질문을 갖고 코드 예를 필요로하는 사람을 돕기 위해 답을 게시하고 싶습니다. pip install pywin32
와
첫째, 다운로드 pywin32 또는이 sourceforge 바이너리 또는 pywin32 wheel 파일 pip install
을 다운로드합니다.
import win32com.client
import pythoncom
import os
# pythoncom.CoInitialize() # remove the '#' at the beginning of the line if running in a thread.
desktop = r'C:\Users\Public\Desktop' # path to where you want to put the .lnk
path = os.path.join(desktop, 'NameOfShortcut.lnk')
target = r'C:\path\to\target\file.exe'
icon = r'C:\path\to\icon\resource.ico' # not needed, but nice
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.IconLocation = icon
shortcut.WindowStyle = 7 # 7 - Minimized, 3 - Maximized, 1 - Normal
shortcut.save()
내가 디버그 콘솔과 GUI가있을 때 나는 WindowStyle
를 사용하고, 나는 콘솔이 모든 시간을 팝업 싶지 않아요. 나는 위안을받지 않은 프로그램으로 시도하지 않았습니다.
희망이 도움이됩니다.