Announcement

Collapse
No announcement yet.

Get system inventory (Python)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get system inventory (Python)

    You can query system information with below script:

    import subprocess;
    process=subprocess.Popen(('systeminfo.exe | find /V /I "hotfix" | find /V "KB" '),shell=True,stdout=subprocess.PIPE);
    for line in iter(process.stdout.readline,''):
    print line.rstrip();


    An example output would be:

    Click image for larger version

Name:	Screenshot_3.png
Views:	1
Size:	68.1 KB
ID:	4341
    Last edited by Ilker; 08-18-2016, 03:20 AM.

  • #2
    Hi All,

    Just was working on this one at the moment, it requires a tab before the last line otherwise it errors

    File "<string>", line 4 print line.rstrip(); ^ IndentationError: expected an indented block Does this forum support code blocks? this may retain some of the special formatting required by python (I don't know a lot about it yet)

    Comment


    • #3
      As dougaust says, the last line needs to be indented.

      Like so:

      Code:
      import subprocess;
      process=subprocess.Popen(('systeminfo.exe | find /V /I "hotfix" | find /V "KB" '),shell=True,stdout=subprocess.PIPE);
      for line in iter(process.stdout.readline,''):
             print line.rstrip();

      Comment

      Working...
      X