Created
January 29, 2024 20:39
-
-
Save 404Wolf/6be9a85fdd078faf3cd456cac12598e7 to your computer and use it in GitHub Desktop.
setupRdp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import psutil | |
import logging | |
from time import sleep | |
logging.basicConfig(filename='rdp.log', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') | |
logging.info("Program started") | |
killed = False | |
for process in psutil.process_iter(['pid', 'name']): | |
if "mstsc" in process.info['name'].lower(): | |
process.terminate() | |
killed = True | |
logging.info("Terminated mstsc.exe") | |
break | |
if killed: | |
sleep(1) | |
subprocess.run("mstsc /v:100.87.45.107 /f /edit default.rdp") | |
logging.info("RDP session started") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment