Advertisement
DrAungWinHtut

ipconfig.py

Apr 30th, 2023
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import subprocess
  2. import os
  3.  
  4. # Define the command to run
  5. command = "ipconfig /all"
  6.  
  7. # Run the command using subprocess
  8. result = subprocess.run(command, capture_output=True, text=True, shell=True)
  9.  
  10.  
  11. # Check if the command executed successfully === 0 - success
  12. if result.returncode == 0:
  13.     print("Command executed successfully:")
  14.     print(result.stdout)
  15.     fname = "D:\\sand\\iplist.txt"
  16.     file = open(fname, 'w')
  17.     file.write(result.stdout)
  18.     file.close()
  19.     os.system(f'notepad {fname}')
  20. else:
  21.     print("Command execution failed:")
  22.     print(result.stderr)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement