From eea9c87f0d291101ab6b934d4414973080f633ed Mon Sep 17 00:00:00 2001 From: Sebastian Serfling Date: Tue, 25 Jul 2023 17:50:41 +0200 Subject: [PATCH] Change exchange_export.py adcontroller_export.py rds_export.py --- Start.py | 60 +++++++++++++++++++++++++++++ download.py | 30 --------------- icons8-konsole-simple-small-70.ico | Bin 0 -> 20502 bytes main.py | 2 - 4 files changed, 60 insertions(+), 32 deletions(-) create mode 100644 Start.py delete mode 100644 download.py create mode 100644 icons8-konsole-simple-small-70.ico 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 0000000000000000000000000000000000000000..a80ab24d3be75e9039f240dbf613cd9b83bac79d GIT binary patch literal 20502 zcmeHOyN(n`6s?6|Ww4EGBvLE{l0U$Yz`!Jkh=2fW5aI_MII)Fg327&`EkT5dxEUW{ zi_GRO2!Dp9l|bT^Y{mo&>wB6m^`X=~eP?zSrkbkNow|MNoa#DfYG&ur6T*u9ojx7x z_OlSqhHxl^@VSMR!tWMU-TLciLO8hpb=YBP#ew2LaiBO*94HPH2ZrpxrzY-8i&L4$ z7q)(A*=ajr6Wq1fve+I-K+8WC-&oAkt{Ca1#Zdf6bwJxsGa7Sgz<#9uTyT10@1Vky z_sEyWrgfjgn{Qh@`O9iwSsckczP9z>u}JsKIji-x-weRKXLkHSA1R}8?2YFZtn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