Advertisement
veblush

ScanWinSxS

Nov 3rd, 2012
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. #/usr/bin/python2
  2.  
  3. import os
  4. import subprocess
  5.  
  6. def gethardlinks(path):
  7.     path_drive = os.path.splitdrive(path)[0]
  8.     fsutil_ret = subprocess.check_output([r"c:\Windows\System32\fsutil.exe", "hardlink", "list", path])
  9.     hardlinks = []
  10.     for line in fsutil_ret.split("\r\n"):
  11.         if len(line) > 0:
  12.             p = path_drive + line
  13.             if p != path:
  14.                 hardlinks.append(p)
  15.     return hardlinks
  16.  
  17. def scan_winsxs():
  18.     path = r"C:\Windows\winsxs"
  19.     for path, dirs, files in os.walk(path):
  20.         for file in files:
  21.             p = os.path.join(path, file)
  22.             filename = os.path.split(p)[1].lower()
  23.             fileext = os.path.splitext(p)[1][1:].lower()
  24.             filesize = os.path.getsize(p)
  25.             print "\t".join((p, filename, fileext, str(filesize), ";".join(gethardlinks(p))))
  26.  
  27. scan_winsxs()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement