Skip to content

Commit

Permalink
feat: build exes + move source code
Browse files Browse the repository at this point in the history
  • Loading branch information
wdhdev committed Jun 9, 2023
1 parent 8dfeb75 commit b4d7a73
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build

on:
push:
branches: [main]
paths:
- "cmd/**"
- "setup/**"

workflow_dispatch:

jobs:
executables:
name: Executables
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
- name: Remove Files
run: |
rm cmd.exe
rm setup.exe
- name: Build cmd.exe
run: |
cd cmd
pyinstaller --onefile --icon "../images/logo.ico" --distpath=../ cmd.py
- name: Build setup.exe
run: |
cd setup
pyinstaller --onefile --icon "../images/logo.ico" --distpath=../ setup.py
- name: Commit
run: |
ls
git config --global user.email "[email protected]"
git config --global user.name "WDH-Bot"
git add cmd.exe
git add setup.exe
git commit -m "chore: build executables"
git push
Binary file removed cmd.exe
Binary file not shown.
52 changes: 52 additions & 0 deletions cmd/cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import sys

URL = sys.argv[1]

if URL.startswith("cmd://") and URL.replace("cmd://", "") == "" or not URL.startswith("cmd://") or URL.startswith("cmd:///"):
print("No command was specified.\n")
os.system("pause")
sys.exit()

commands = URL.split("//")
command_tmp = commands[1]
t22 = command_tmp[len(command_tmp) - 1]

if t22 == "/":
command_tmp2 = command_tmp[:-1]
else:
command_tmp2 = command_tmp

command = (
command_tmp2
.replace("%20", " ")
.replace("%5C", "\\")
.replace("%7C", "|")
.replace("-/", "-")
.replace("%25", "%")
)

print(""" ____ _ _____ _
/ ___|___ _ __ ___ _ __ ___ __ _ _ __ __| | | ____|_ _____ ___ _ _| |_ ___ _ __
| | / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` | | _| \ \/ / _ \/ __| | | | __/ _ \| '__|
| |__| (_) | | | | | | | | | | | (_| | | | | (_| | | |___ > < __/ (__| |_| | || (_) | |
\____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_| |_____/_/\_\___|\___|\__,_|\__\___/|_|
""")

print("Command:", command)

while True:
confirm = input("\nExecute command? [y/N]\n>> ")
start = confirm.lower()

if start == "y" or start == "yes":
print()
os.system("cmd /c " + command)

print("\nOperation completed.\n")
os.system("pause")
sys.exit()
else:
print("\nOperation cancelled.\n")
os.system("pause")
sys.exit()
Binary file added images/logo.ico
Binary file not shown.
Binary file removed setup.exe
Binary file not shown.
63 changes: 63 additions & 0 deletions setup/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import ctypes
import os
import sys

# Request elevated permission
ctypes.windll.shell32.IsUserAnAdmin() or (
ctypes.windll.shell32.ShellExecuteW(
None, "runas", sys.executable, " ".join(sys.argv), None, 1
) > 32, exit())

if os.path.isfile("./cmd.exe"):
os.system("echo ✅ cmd.exe exists")
else:
os.system("echo ❌ cmd.exe does not exist")
print()

os.system("pause")
sys.exit()

if os.path.isfile("./register.reg"):
os.system("echo ✅ register.reg exists")
else:
os.system("echo ❌ register.reg does not exist")
print()

os.system("pause")
sys.exit()

print()

# Add registry values
os.system("echo ✏️ Adding required values to registry...")
os.system("regedit.exe /S register.reg >nul")
os.system("echo ✅ Added required values to the registry.")

print()

# Create C:\Protocols directory
if os.path.isdir("C:\Protocols"):
os.system("echo ✅ \"C:\Protocols\" exists")
else:
os.system("echo ❌ \"C:\Protocols\" does not exist")
print()

os.system("echo 📂 Creating directory \"C:\Protocols\"...")
os.mkdir("C:\Protocols")
os.system("echo ✅ Created directory \"C:\Protocols\".")

print()

# Copy cmd.exe
os.system("echo 📜 Copying \"cmd.exe\" to \"C:\Protocols\cmd.exe\"...")
os.system("xcopy \"cmd.exe\" \"C:\Protocols\" /E /C /H /R /K /O /Y >nul")
os.system("echo ✅ Copied \"cmd.exe\" to \"C:\Protocols\cmd.exe\".")

print()

os.system("echo ✅ The \"cmd://\" protocol has been registered.")

print()

os.system("pause")
sys.exit()

0 comments on commit b4d7a73

Please sign in to comment.