Created
January 14, 2022 03:35
-
-
Save modz2014/3b66f402955c74b3d47142ec6d98f46c to your computer and use it in GitHub Desktop.
Downloading ad check if files exist and Running ProcDump
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 sys | |
import io | |
import subprocess | |
import psutil | |
import glob, os | |
import requests | |
import zipfile | |
from tqdm import tqdm | |
import os | |
from pathlib import Path | |
zipped_file = r'ProcDump.zip' | |
##for proc in psutil.process_iter(['exe']): | |
##if proc.info['exe'] and os.path.basename(proc.info['exe']).lower() == 'notepad': | |
##break | |
##else: | |
##subprocess.Popen([r'C:\C:\Windows\system32\notepad.exe']) | |
#### Checking for Download #### | |
if os.path.exists('ProcDump.zip'): | |
print("Already Download ProcDump.zip") | |
else: | |
###### DownLoading ProcDump from Microsoft ##### | |
url = "https://download.sysinternals.com/files/Procdump.zip" | |
filesize = int(requests.head(url).headers["Content-Length"]) | |
filename = os.path.basename(url) | |
dl_path = os.path.join(filename) | |
chunk_size = 1024 | |
with requests.get(url, stream=True) as r, open(dl_path, "wb") as f, tqdm( | |
unit="B", | |
unit_scale=True, | |
unit_divisor=1024, | |
total=filesize, | |
file=sys.stdout, | |
desc=filename | |
) as progress: | |
for chunk in r.iter_content(chunk_size=chunk_size): | |
datasize = f.write(chunk) | |
progress.update(datasize) | |
path = '' | |
archive = zipfile.ZipFile(f'{path}ProcDump.zip') | |
#### Chekcing if procdump exists #### | |
if os.path.exists('procdump.exe'): | |
print("Already Downloaded") | |
else: | |
###### Extracting ProcDump ##### | |
for file in archive.namelist(): | |
if file.startswith('procdump.exe'): | |
archive.extract(file, path) | |
subprocess.call('procdump.exe -ma Notepad') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment