Created
January 24, 2020 23:47
-
-
Save spenkk/3f4f12270416d2eff68822da8d3037cd to your computer and use it in GitHub Desktop.
Restart process if it's not running
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 psutil | |
import os | |
import time | |
while True: | |
time.sleep(15) | |
def checkIfProcessRunning(processName): | |
#Iterate over the all the running process | |
for proc in psutil.process_iter(): | |
try: | |
# Check if process name contains the given name string. | |
if processName.lower() in proc.name().lower(): | |
return True | |
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): | |
pass | |
return False; | |
if checkIfProcessRunning('vulnserver'): | |
print('[*] VulnServer is running') | |
else: | |
print('[-] VulnServver is not running! Starting it now.') | |
os.system("start /b C:\\vulnserver.exe") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment