For a Windows 7 environment without PowerShell, a Batch script is a suitable choice. The script I provided earlier should work on Windows 7.
To recap, here are the steps to create and execute the script on Windows 7:
- Create the Batch script: Save the following script as
system_info.bat on your flash drive.
@echo off
:: Get IPv4 address
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /c:"IPv4 Address"') do (
set "IPv4=%%a"
goto :next
)
:next
set "IPv4=%IPv4: =%"
:: Get PC Name
set "PCName=%COMPUTERNAME%"
:: Get Username
set "Username=%USERNAME%"
:: Get OS Version
for /f "tokens=4-7 delims=[.] " %%a in ('ver') do (
if "%%b" == "" (
set "OSVersion=%%a"
) else (
set "OSVersion=%%a.%%b.%%c"
)
)
echo IPv4 Address: %IPv4%
echo PC Name: %PCName%
echo Username: %Username%
echo OS Version: %OSVersion%
:: Pause to see the output
pause
- Create the
autorun.inf file: In the same directory as system_info.bat (the root of your flash drive), create a file named autorun.inf with the following content:
[AutoRun]
open=system_info.bat
However, keep in mind that Windows 7, by default, may still prompt the user to run the auto-play content or may be configured to disable auto-run for security reasons.
Enabling AutoRun on Windows 7
If AutoRun is disabled, you can check the settings:
- Open the Registry Editor (
regedit.exe).
- Navigate to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer.
- Look for the
NoDriveTypeAutoRun value. If it exists, its value might be set to disable AutoRun for removable drives.
To enable AutoRun for removable drives, you can set NoDriveTypeAutoRun to 0x91 (hexadecimal) or 145 (decimal), but be cautious as this involves modifying registry settings.
Alternative: Manual Execution
If AutoRun is not an option, users will need to manually execute system_info.bat by navigating to the flash drive and double-clicking the file.
Additional Tip
To make the output more visible or to save the output, you can modify the script to log the information to a file:
@echo off
:: ... (rest of the script remains the same)
echo IPv4 Address: %IPv4%
echo PC Name: %PCName%
echo Username: %Username%
echo OS Version: %OSVersion%
:: Log to a file
echo IPv4 Address: %IPv4% > "%~d0\system_info.log"
echo PC Name: %PCName% >> "%~d0\system_info.log"
echo Username: %Username% >> "%~d0\system_info.log"
echo OS Version: %OSVersion% >> "%~d0\system_info.log"
:: Pause to see the output
pause
This will save the output to system_info.log on the flash drive. The %~d0 refers to the drive letter of the script's location.