I was recently asked to inventory approx 200 client computers of what programs they had installed, the specifications (cpu/ram/hdd) etc. So I was being lazy as most IT-techs are and wrote a script that I later on implemented into their usual login script.
It creates a simple .txt-file on a pre-mapped network drive and appends new batch runs into the same file.
After a successfull inventory run, the script creates a empty file (flag.txt) in the global var %appdata% where the current logged in user allways has write access. And the next time the script runs, it will check if the file flag.txt exists and exit if it does.
As I wrote, this script can be used together with a login script.
start \\servername\full_unc_path\inventory.bat
@echo off
title Inventory Script
REM Made by Niklas Jumlin - Copyright 2010
REM This script may NOT be redistributed without the permission of the author
:: GLOBAL VARS
@for /f "Tokens=1" %%i in ('time /t') do @set tm=%%i
@for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do @set dt=%%i%%j%%k%%l
@set tm=%tm::=.%
@set dtt=%dt%_%tm%
@set computer=%computername%
@set computer=%computer:~0,4%
:: SPECIFY WHERE TO SAVE THE INVENTORY LOG
set target=\\server.domain.local\netlogon\inventory\%computername%-%username%.txt
echo "%target%"
echo. > %target%
:: EXIT IF IT IS A SERVER AND/OR IF SCRIPT HAS ALLREADY BEEN EXECUTED
if /i %computer% == site exit
if exist "%appdata%\flag_inv_%computername%.txt" exit
:: START INVENTORING
color b0
mode 52,3
cls
echo.
echo Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo ------------ START OF %computername% --------------- >> %target%
echo. >> %target%
echo Date and time of run: %dtt% >> %target%
echo. >> %target%
echo ACTIVE USER: %username% >> %target%
echo PROFILE PATH: %userprofile% >> %target%
echo APP DATA: %appdata% >> %target%
echo. >> %target%
systeminfo >> %target%
cls
echo.
echo Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo. >> %target%
wmic /append:%target% Desktop Get Name
cls
echo.
echo Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo. >> %target%
echo INSTALLED APPLICATIONS: >> %target%
echo. >> %target%
wmic /append:%target% product get name,version
cls
echo.
echo Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo. >> %target%
echo SHARED NETWORK RESOURCES: >> %target%
echo. >> %target%
net share >> %target%
cls
echo.
echo Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo. >> %target%
echo ------------ END OF %computername% ----------------- >> %target%
echo. >> %target%
echo. >> "%appdata%\flag_inv_%computername%.txt"
@exit