Advertisement
Guest User

Python Inventory Project

a guest
Nov 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import subprocess
  2. import tempfile
  3. import os
  4.  
  5. Username = ""
  6. ComputerName = ""
  7. OperatingSystem = ""
  8. fd, TemporaryFile = tempfile.mkstemp()
  9.  
  10. try:
  11.     with os.fdopen(TemporaryFile, 'r+') as tmp:
  12.         subprocess.call(['whoami'], stdout = tmp)
  13.         subprocess.call(['systeminfo'], stdout = tmp)
  14.         #tmp.write(subprocess.run(["whoami"]))
  15.         #tmp.write(subprocess.run(["systeminfo"]))
  16.         #ComputerInformation = [line.rstrip('\n') for line in tmp]
  17.         ComputerInformation = tmp.readlines()
  18. finally:
  19.     os.remove(TemporaryFile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement