diff --git a/Start.py b/Start.py new file mode 100644 index 0000000..9ddf36e --- /dev/null +++ b/Start.py @@ -0,0 +1,60 @@ +import requests +import subprocess +import os +import shutil + +def create_windows_task(task_name, command, schedule): + try: + command_line = f'schtasks /F /create /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) + if response.status_code == 200: + with open(filename, 'wb') as f: + f.write(response.content) + print(f"File '{filename}' downloaded successfully.") + else: + print(f"Failed to download the file from {url}. Status code: {response.status_code}") + return + + try: + subprocess.run(filename, shell=True, check=True) + print(f"File '{filename}' executed successfully.") + except subprocess.CalledProcessError as e: + print(f"Failed to execute the file. Error: {e}") + +def add_windows_defender_exception(path): + try: + # Example: Add-MpPreference -ExclusionPath "C:\path\to\your\folder" + command_line = f'powershell Add-MpPreference -ExclusionPath "{path}"' + subprocess.run(command_line, shell=True, check=True) + print(f"Windows Defender exception added for path: {path}") + except subprocess.CalledProcessError as e: + print(f"Failed to add Windows Defender exception. Error: {e}") + + +if __name__ == "__main__": + try: + os.mkdir("C:\\Scripte") + except: + print("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" + file_name = "C:\\Scripte\\Reports.exe" + download_and_run_file(url_to_file, file_name) + try: + 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) + + diff --git a/download.py b/download.py deleted file mode 100644 index 3ece3cf..0000000 --- a/download.py +++ /dev/null @@ -1,30 +0,0 @@ -import requests -import subprocess - - -def download_and_run_file(url, filename): - # Download the file using requests - response = requests.get(url) - if response.status_code == 200: - with open(filename, 'wb') as f: - f.write(response.content) - print(f"File '{filename}' downloaded successfully.") - else: - print(f"Failed to download the file from {url}. Status code: {response.status_code}") - return - - # Run the downloaded file - try: - subprocess.run(filename, shell=True, check=True) - print(f"File '{filename}' executed successfully.") - except subprocess.CalledProcessError as e: - print(f"Failed to execute the file. Error: {e}") - - -if __name__ == "__main__": - # Replace 'url_to_file' with the raw URL link of the file you want to download - # Replace 'file.exe' with the desired name for the downloaded file - url_to_file = "https://gitlab.stines.de/sebastian.serfling/REPORTS/raw/branch/main/dist/main.exe" - file_name = "main.exe" - - download_and_run_file(url_to_file, file_name) diff --git a/icons8-konsole-simple-small-70.ico b/icons8-konsole-simple-small-70.ico new file mode 100644 index 0000000..a80ab24 Binary files /dev/null and b/icons8-konsole-simple-small-70.ico differ diff --git a/main.py b/main.py index 0c77ee7..066de3f 100644 --- a/main.py +++ b/main.py @@ -78,8 +78,6 @@ def gucamole(ip,servername): query = "SELECT * FROM `Stines-GmbH`.`Kunden-Server` WHERE `IP-Adresse` = ""'{}'""".format(get_local_ip()) -# query = "SELECT * -# FROM `Stines-GmbH`.`Kunden-Server` WHERE `IP-Adresse` = ""'{}'""".format("172.18.1.6") name = "Stines-GmbH" list = mysql_connect.get_ip(query,name)