Change exchange_export.py adcontroller_export.py
rds_export.py
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user