Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import platform
- import winreg
- def get_system_information():
- system_info = {
- 'Operating System': platform.platform(),
- 'Python Version': sys.version,
- 'Desktop Directory': os.path.join(os.path.expanduser('~'), 'Desktop'),
- 'Desktop Icons': os.listdir(os.path.join(os.path.expanduser('~'), 'Desktop'))
- }
- known_folders = {
- 'Documents': '{FDD39AD0-238F-46AF-ADB4-6C85480369C7}',
- 'Downloads': '{374DE290-123F-4565-9164-39C4925E467B}',
- 'Music': '{4BD8D571-6D19-48D3-BE97-422220080E43}',
- 'Pictures': '{33E28130-4E1E-4676-835A-98395C3BC3BB}',
- 'Videos': '{18989B1D-99B5-455B-841C-AB7C74E4DDFC}'
- }
- for folder_name, folder_guid in known_folders.items():
- try:
- with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") as key:
- folder_path = winreg.QueryValueEx(key, folder_guid)[0]
- system_info[folder_name + ' Path'] = folder_path
- except FileNotFoundError:
- pass
- system_info['System Paths'] = {name: value for name, value in os.environ.items()}
- return system_info
- def write_system_information_to_files(system_info):
- folder = os.path.join(os.path.expanduser('~'), 'Desktop', 'autonomie', 'sys.inf')
- os.makedirs(folder, exist_ok=True)
- info_filepath = os.path.join(folder, 'system_info.txt')
- with open(info_filepath, 'w') as f:
- for key, value in system_info.items():
- f.write(f"{key}: {value}\n")
- paths_filepath = os.path.join(folder, 'system_paths.txt')
- with open(paths_filepath, 'w') as f:
- f.write("System Paths:\n")
- for path_name, path_value in system_info['System Paths'].items():
- f.write(f"{path_name}: {path_value}\n")
- print("System information has been written to:", info_filepath)
- print("System paths have been written to:", paths_filepath)
- if __name__ == "__main__":
- system_info = get_system_information()
- write_system_information_to_files(system_info)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement