|
1 | 1 | """Creates a desktop shortcut that can run Auto Maple from anywhere."""
|
2 | 2 |
|
3 | 3 | import os
|
| 4 | +import git |
4 | 5 | import argparse
|
5 | 6 | import win32com.client as client
|
6 | 7 |
|
7 | 8 |
|
8 |
| -parser = argparse.ArgumentParser() |
9 |
| -parser.add_argument('--stay', action='store_true') |
10 |
| -args = parser.parse_args() |
| 9 | +def create_desktop_shortcut(): |
| 10 | + """Creates and saves a desktop shortcut using absolute paths""" |
| 11 | + print('\n[~] Creating a desktop shortcut for Auto Maple:') |
| 12 | + CWD = os.getcwd() |
| 13 | + TARGET = os.path.join(os.environ['WINDIR'], 'System32', 'cmd.exe') |
| 14 | + PATH = os.path.join(os.environ['USERPROFILE'], 'Desktop', 'Auto Maple.lnk') |
| 15 | + flag = "/c" |
| 16 | + if args.stay: |
| 17 | + flag = "/k" |
| 18 | + print(" - Leaving command prompt open after program finishes") |
11 | 19 |
|
12 |
| -# Create and save the shortcut using absolute paths |
13 |
| -print('[~] Creating a desktop shortcut for Auto Maple:') |
14 |
| -CWD = os.getcwd() |
15 |
| -TARGET = os.path.join(os.environ['WINDIR'], 'System32', 'cmd.exe') |
16 |
| -PATH = os.path.join(os.environ['USERPROFILE'], 'Desktop', 'Auto Maple.lnk') |
17 |
| -flag = "/c" |
18 |
| -if args.stay: |
19 |
| - flag = "/k" |
20 |
| - print(" ~ Leaving command prompt open after program finishes") |
| 20 | + shell = client.Dispatch('WScript.Shell') |
| 21 | + shortcut = shell.CreateShortCut(PATH) |
| 22 | + shortcut.Targetpath = TARGET |
| 23 | + shortcut.Arguments = flag + f' \"cd {CWD} & python main.py\"' |
| 24 | + shortcut.IconLocation = os.path.join(CWD, 'assets', 'icon.ico') |
| 25 | + shortcut.save() |
21 | 26 |
|
22 |
| -shell = client.Dispatch('WScript.Shell') |
23 |
| -shortcut = shell.CreateShortCut(PATH) |
24 |
| -shortcut.Targetpath = TARGET |
25 |
| -shortcut.Arguments = flag + f' \"cd {CWD} & python main.py\"' |
26 |
| -shortcut.IconLocation = os.path.join(CWD, 'assets', 'icon.ico') |
27 |
| -shortcut.save() |
| 27 | + # Enable "run as administrator" |
| 28 | + with open(PATH, 'rb') as lnk: |
| 29 | + arr = bytearray(lnk.read()) |
28 | 30 |
|
29 |
| -# Enable "run as administrator" |
30 |
| -with open(PATH, 'rb') as lnk: |
31 |
| - arr = bytearray(lnk.read()) |
| 31 | + arr[0x15] = arr[0x15] | 0x20 # Set the 6th bit of 21st byte to 1 |
32 | 32 |
|
33 |
| -arr[0x15] = arr[0x15] | 0x20 # Set the 6th bit of 21st byte to 1 |
| 33 | + with open(PATH, 'wb') as lnk: |
| 34 | + lnk.write(arr) |
| 35 | + print(' - Enabled the "Run as Administrator" option') |
| 36 | + print(' ~ Successfully created Auto Maple shortcut') |
34 | 37 |
|
35 |
| -with open(PATH, 'wb') as lnk: |
36 |
| - lnk.write(arr) |
37 |
| - print(' ~ Enabled the "Run as Administrator" option') |
38 | 38 |
|
39 |
| -print('[~] Successfully created Auto Maple shortcut') |
| 39 | +def update_submodules(): |
| 40 | + print('\n[~] Updating submodules:') |
| 41 | + repo = git.Repo() |
| 42 | + repo.git.submodule('update', '--init', '--recursive') |
| 43 | + print(' ~ Finished updating submodules') |
| 44 | + |
| 45 | + |
| 46 | +if __name__ == '__main__': |
| 47 | + parser = argparse.ArgumentParser() |
| 48 | + parser.add_argument('--stay', action='store_true') |
| 49 | + args = parser.parse_args() |
| 50 | + |
| 51 | + create_desktop_shortcut() |
| 52 | + update_submodules() |
0 commit comments