To create a standalone executable without external dependencies, you can use a programming language like Python. Here is a Python script that performs the required operations and can be compiled into an executable using tools like PyInstaller or PyInstaller GUI.
import re
import win32net
import win32com.client
import datetime
def get_computer_info():
cn = win32net.Connection('.', '')
details = {}
details['Manufacturer'] = cn.GetInfo(win32net.INET_INFO_KEYS_ALL)[1].lower()
details['Model'] = cn.GetInfo(win32net.INET_INFO_KEYS_ALL)[5].lower()
details['Serial Number'] = cn.GetInfo(win32net.INET_INFO_KEYS_ALL)[12]
details['Processor'] = cn.GetInfo(win32net.INET_INFO_KEYS_ALL)[3]
details['Memory'] = cn.GetInfo(win32net.INFO_COMPUTER_SYSTEM)[1] // (1024 * 1024)
details['Disks'] = {}
for key in cn.EnumSubKeys(r'C:\')[:3]:
disk_size = win32com.client.GetSizeInfo(
cn.EnumSubKeys(r'C:\' + key)[0], 1
).FreeSpace // (1024 * 1024)
details['Disks'][key] = disk_size
return details
def set_computer_info(details):
cn = win32net.Connection('.', '')
for attr, value in details.items():
if attr in ['Manufacturer', 'Model', 'Serial Number']:
cn.SetInfo(win32net.INET_INFO_KEYS_ALL, 1, value)
elif attr in ['Processor']:
cn.SetInfo(win32net.INET_INFO_KEYS_ALL, 3, value)
elif attr in ['Memory']:
cn.SetInfo(win32net.INET_INFO_KEYS_ALL, 1)[:-2], value
elif attr in ['Disks']:
for disk_type, disk_size in details['Disks'].items():
cn.SetInfo(w2_disp=None, w2_path=disk_type, w2_info=str(disk_size), w2_help=None)
elif attr in ['User Name']:
cn.SetInfo(win32net.INET_INFO_KEYS_ALL, 13)
elif attr in ['Date and Time']:
cn.SetInfo(win32net.INET_INFO_KEYS_ALL, 16)
def main():
details = get_computer_info()
set_computer_info(details)
if __name__ == '__main__':
main()
To compile the script into a standalone executable, you can use PyInstaller or PyInstaller GUI. These tools will package the script along with its dependencies to create an executable file.
As for the estimated compiled standalone executable size, it will vary depending on the language you choose. Here's an estimate for each option:
- Python (compiled with PyInstaller): The size will depend on the size of the Python interpreter and the dependencies, but it can be around 10-20 MB.
- C#: The size will be larger, typically around 20-40 MB, depending on the framework and dependencies used.
- Java: The size can be around 20-30 MB, depending on the dependencies and the compiled code size.
Remember to install the necessary tools and dependencies before compiling the script.