Newbi Help with Batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
millwalll
Posts: 2
Joined: 10 May 2012 03:08

Newbi Help with Batch file

#1 Post by millwalll » 10 May 2012 03:49

Hi all,

I am pretty new to batch files and have been given a task by my company where I think having handy batch file would same me a lot of time. I have tried to google for batch files that already acheive this and tried putting my own together hacking different batch files togehter.

What I would like is batch file that will provide me with the following information:

Username
Make/Model of computer
CPU
RAM
Disk Size
OS version
All software installed with version
Serial number of machine
Serial number of any mointors attached to machine

Providing all this would be amazing but as much info as I can get would also help lots.

So far I have this

Code: Select all

echo List of softwares > software_list.txt
echo ================= >>software_list.txt

echo Username = %username% >>software_list.txt
wmic bios get serialnumber >>software_list.txt

reg export HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall temp1.txt
find "DisplayName" temp1.txt| find /V "ParentDisplayName" > temp2.txt
for /f "tokens=2,3 delims==" %%a in (temp2.txt) do (echo %%a >> software_list.txt)

del temp1.txt temp2.txt


Any help or advice would be great I would not mind getting rid of all the update info.

thanks in advance!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Newbi Help with Batch file

#2 Post by foxidrive » 10 May 2012 05:25

Google this and look in the help for command line options. Maybe it will provide what you want.

System Information for Windows
Freeware Version
Gabriel Topala

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Newbi Help with Batch file

#3 Post by Squashman » 10 May 2012 05:37

Open up a cmd prompt and type: systeminfo
That will get you a few of the things you want.

millwalll
Posts: 2
Joined: 10 May 2012 03:08

Re: Newbi Help with Batch file

#4 Post by millwalll » 10 May 2012 06:24

ok thanks will look into it

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Newbi Help with Batch file

#5 Post by abc0502 » 10 May 2012 06:36

Here is a code but i couldn't get the serial numbers, And the hdd size i get it two numbers it's always the first
This will get the info on the screen and log it to a file in ur desktop

Code: Select all

@ECHO OFF
CLS
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a" )

Set "log=%userprofile%\desktop\installedprogs.txt"
if exist "%log%" del /q %log%
CALL :C 0a "=====================================" &echo:
CALL :C e0 "Gathering Information ...please wait " &echo:
CALL :C 0a "=====================================" &echo:

CALL :C 0c "User Name " &call :C 0f "%username%" &echo:
echo. User Name = %username% >> "%log%"
echo. >> "%log%"
echo.

CALL :C 0c "Make-Model of Computer" &echo:
echo.Make-Model of Computer = >> "%log%"
For /f "tokens=*" %%a in ('set ^|find "PROCESSOR"') DO CALL :C 0f "%%a"&echo: &echo.%%a >>%log%
echo. >>"%log%"
echo.

For /f "tokens=10" %%b in ('wmic cpu list brief') do set cpu=%%b
CALL :C 0c "CPU Speed " &call :C 0f "%cpu%" &echo:
echo.CPU Speed = %cpu% >> "%log%"
echo. >> "%log%"
echo.

For /f "tokens=2 delims==" %%c in ('wmic COMPUTERSYSTEM list full ^|find "TotalPhysicalMemory"') do set mem=%%c
CALL :C 0c "Memory Total Size " &call :C 0f "%mem%" &echo:
echo.Memory Total Size = %mem% >> "%log%"
echo. >> "%log%"
echo.

For /f "Tokens=*" %%d in ('wmic DISKDRIVE get size') do (
CALL :C 0c "HDD Size  " &echo:
CALL :C 0f "%%d"
echo.HDD Size = %%d >> "%log%"
)
echo. >> "%log%"
echo.

For /f "tokens=*" %%e in ('ver ^|find "Microsoft"') do set ver=%%e
CALL :C 0c "OS Version " &call :C 0f "%ver%"
echo.OS Version = %ver% >> "%log%"
echo. >> "%log%"
echo.
echo.

For /f "tokens=2 delims==" %%f in ('wmic baseboard list full ^|findstr "SerialNumber"') do set serial=%%f
CALL :C 0c "MotherBoard Serial Number " &call :C 0f "%serial%"
echo.MotherBoard Serial Number = %serial% >> "%log%"
echo. >> "%log%"
echo.
echo.
echo.
Call :C 0D "Gathering Information Completed."&echo:
Call :C 0e "All Data has been loged to your desktop"&echo:
Pause >nul

:C
echo off
cd %temp%
<nul set /p "=%DEL%" >> "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof

:eof
Exit
:: http://www.dostips.com/forum/

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Newbi Help with Batch file

#6 Post by Ed Dyreen » 10 May 2012 19:21

'
abc0502 wrote:Here is a code but i couldn't get the serial numbers
I couldn't get the wmic baseboard serialNumber either,
would be pleased to find out how to uniquely identify a system other than by using it's getMAC address.

shanmukhateja
Posts: 1
Joined: 11 May 2012 09:40

Re: Newbi Help with Batch file

#7 Post by shanmukhateja » 11 May 2012 09:42

open cmd
type sysinfo32>c:\log.txt
open c:\ n check if all the details r fit in or not
hope dis will help :D

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Newbi Help with Batch file

#8 Post by foxidrive » 11 May 2012 10:02

shanmukhateja wrote:open cmd
type sysinfo32>c:\log.txt


On my XP machine it doesn't seem to be on the path so I needed to use this - and also add the /report switch,

Code: Select all

"c:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe" /report log.txt



It can take a while too.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Newbi Help with Batch file

#9 Post by abc0502 » 11 May 2012 17:25

Ed Dyreen wrote:'
abc0502 wrote:Here is a code but i couldn't get the serial numbers
I couldn't get the wmic baseboard serialNumber either,
would be pleased to find out how to uniquely identify a system other than by using it's getMAC address.


There could be away to identify a pc we can use more than one command output to identify a system like
taking the Product from BASEBOARD, and Version from BIOS, and UUID from CSPRODUCT

if the whole three match that gave a positive ID and if not that gave a false ID
Also we can take more than this three so we can narrow Margin of error.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Newbi Help with Batch file

#10 Post by Ed Dyreen » 12 May 2012 16:39

abc0502 wrote:There could be away to identify a pc we can use more than one command output to identify a system like
taking the Product from BASEBOARD, and Version from BIOS, and UUID from CSPRODUCT
'
We have several mainboards that are the same product and use the same bios versions,
also for some reason UUID is always 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF' ??
getMAC will work perfectly unless the pc lacks a NIC.

But I won't deviate this topic any further, 8)

miskox
Posts: 656
Joined: 28 Jun 2010 03:46

Re: Newbi Help with Batch file

#11 Post by miskox » 14 May 2012 01:52

Maybe this could be useful to you:

BGinfo

http://technet.microsoft.com/en-us/sysi ... s/bb897557

Saso

Post Reply