Advertisement
Python253

get_sysinternals_suite

Mar 18th, 2024
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.63 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # Filename: get_sysinternals_suite.py
  3. # Version: 1.01
  4. # Author: Jeoi Reqi
  5.  
  6. """
  7. GET SYSINTERNALS SUITE:
  8.  
  9. - This script automates the download and extraction process for the Sysinternals Suite, a comprehensive package of advanced system utilities tailored for Windows OS.
  10.  
  11. - These utilities are developed by Sysinternals, a company now owned by Microsoft since they acquired Winternals and its assets on July 18, 2006 .
  12.  
  13. - They provide powerful tools for system administrators, IT professionals, and advanced users to manage, troubleshoot, diagnose, and optimize Windows-based systems.
  14.  
  15. Requirements:
  16. - Python 3.x
  17. - Internet connectivity
  18.  
  19. Usage:
  20. 1. Run the script using Python 3.
  21. 2. Ensure the download directory exists.
  22. 3. The script will download the Sysinternals Suite as a ZIP file to the specified download directory and extract it to the specified extraction directory.
  23. 4. The ZIP file will be removed after extraction.
  24.  
  25. Notes:
  26. - Internet connectivity is required to download the Sysinternals Suite.
  27. - Elevated administrator permissions might be needed to write to certain directories.
  28. """
  29.  
  30. import os
  31. import ssl
  32. import shutil
  33. import urllib.request
  34.  
  35. def download_sysinternals_suite(download_dir):
  36.     """
  37.    Download the Sysinternals Suite ZIP file.
  38.    
  39.    Args:
  40.        download_dir (str): The directory to save the downloaded ZIP file.
  41.    
  42.    Returns:
  43.        str: The path to the downloaded ZIP file.
  44.    """
  45.     # Ensure the download directory exists
  46.     if not os.path.exists(download_dir):
  47.         os.makedirs(download_dir)
  48.    
  49.     url = "https://download.sysinternals.com/files/SysinternalsSuite.zip"
  50.     download_path = os.path.join(download_dir, "SysinternalsSuite.zip")
  51.    
  52.     # Disable SSL certificate verification
  53.     ssl_context = ssl.create_default_context()
  54.     ssl_context.check_hostname = False
  55.     ssl_context.verify_mode = ssl.CERT_NONE
  56.    
  57.     # Download the ZIP file
  58.     with urllib.request.urlopen(url, context=ssl_context) as response, open(download_path, 'wb') as out_file:
  59.         shutil.copyfileobj(response, out_file)
  60.        
  61.     return download_path
  62.  
  63. # Function to extract SysInternals Suite (.zip) from path
  64. def extract_sysinternals_suite(zip_path, extract_dir):
  65.     """
  66.    Extract the Sysinternals Suite ZIP file.
  67.    
  68.    Args:
  69.        zip_path (str): The path to the ZIP file.
  70.        extract_dir (str): The directory to extract the contents to.
  71.    """
  72.     # Ensure the extraction directory exists
  73.     if not os.path.exists(extract_dir):
  74.         os.makedirs(extract_dir)
  75.    
  76.     # Extract the ZIP file
  77.     shutil.unpack_archive(zip_path, extract_dir)
  78.  
  79. def main():
  80.     """
  81.    Main function to download and extract the Sysinternals Suite.
  82.    """
  83.     # Directories
  84.     download_dir = "C:\\Temp"
  85.     extract_dir = "C:\\Sysinternals"
  86.  
  87.     # Download Sysinternals Suite
  88.     print("\n\nDownloading the Sysinternals Suite...")
  89.     zip_path = download_sysinternals_suite(download_dir)
  90.     print(f"The Sysinternals Suite ZIP file has been successfully downloaded to: {zip_path}!")
  91.  
  92.     # Extract Sysinternals Suite
  93.     print(f"\nExtracting the Sysinternals Suite ZIP file to: {extract_dir}...")
  94.     extract_sysinternals_suite(zip_path, extract_dir)
  95.     print(f"The Sysinternals Suite has been successfully extracted to: {extract_dir}!")
  96.  
  97.     # Remove the ZIP file
  98.     print("\nRemoving the .zip file from {zip_path}...")
  99.     os.remove(zip_path)
  100.     print("The Sysinternals Suite ZIP file has been removed!")
  101.    
  102.     # Goodbye!
  103.     print("\nThe program finished successfully.")
  104.     print("Goodbye!\n\n")
  105.  
  106. if __name__ == "__main__":
  107.     main()
  108.  
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement