A lightweight Python script that logs key system information each time it's run. Ideal for portable USB usage or logging purposes.
- Logs the following:
- Current user path (
C:\Users\Username) - Device manufacturer and model
- Operating System name and version
- Timestamp (24-hour format with seconds)
- Current user path (
- Appends each entry to the log file without overwriting
- Includes error handling — logs any exceptions
- Works as a standalone script or as a
.exe
C:\Users\JohnDoe Dell Inc. Inspiron 5537 Windows 11 2025-07-22 14:08:56
If something goes wrong:
## ERROR: Couldn't collect data - \[error message]
Make sure Python 3.x is installed. Then install required modules:
pip install wmiThe script uses built-in modules:
getpass,platform, anddatetime, and one external module:wmi.
Run using:
python usb_logger_real.pyA file named device_log.txt will be created (or updated) in the same directory.
You can convert this script to an executable (no console window):
pyinstaller --onefile --noconsole usb_logger_real.pyIf you want it to run silently from a USB, you can use Samlogic USB Autorun Creator
- since bat to exe converted files are caught by virus guard this is the best method
Note: Autorun from USB is blocked on most modern Windows versions (since Windows 7). You can use USB AUTO RUN CREATEOR : https://usb-autorun-creator.en.softonic.com/
Example autorun.inf:
[autorun]
label=Kingston 32GB
icon=pen.ico
open=usb_logger.exeThis project is intended for educational and authorized usage only. Logging data from systems without user consent may be illegal.
Free to use and modify for personal or academic use.