Change Create Windows Task to main.py

This commit is contained in:
2023-08-10 11:17:24 +02:00
parent d6f0875fee
commit e8d16fcd53
18 changed files with 415 additions and 404 deletions
+2 -13
View File
@@ -2,14 +2,8 @@ import requests
import subprocess
import os
import shutil
import random
def create_windows_task(task_name, command, schedule):
try:
command_line = f'schtasks /F /create /ru "SYSTEM" /tn "{task_name}" /tr "{command}" /sc {schedule}'
subprocess.run(command_line, shell=True, check=True)
print(f"Windows task '{task_name}' created successfully.")
except subprocess.CalledProcessError as e:
print(f"Failed to create Windows task. Error: {e}")
def download_and_run_file(url, filename):
response = requests.get(url)
@@ -41,7 +35,7 @@ if __name__ == "__main__":
try:
os.mkdir("C:\\Scripte")
except:
print("Exist")
print("Folder Exist")
path_to_exclude = "C:\\Scripte"
add_windows_defender_exception(path_to_exclude)
url_to_file = "https://gitlab.stines.de/sebastian.serfling/REPORTS/raw/branch/main/dist/main.exe"
@@ -51,10 +45,5 @@ if __name__ == "__main__":
shutil.move("Start.exe","C:\\Scripte\\Start.exe")
except:
print("File was moved!")
task_name = "Reports"
command_to_execute = "C:\\Scripte\\Start.exe"
schedule = "daily /st 23:30" # You can customize the schedule here
create_windows_task(task_name, command_to_execute, schedule)