BasicInfo

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
mischi
Posts: 12
Joined: 24 Dec 2010 02:31

BasicInfo

#1 Post by mischi » 24 Dec 2010 05:20

Hello all,

is there somebody who can tell me/write example how to get some basic information about computer via cmd to the txt file?
I need especially CPU info, memory and from ipconfig IP addresses of all my network cards.

I supposed that it will be very easy via findstr but I was totally wrong :)
if I'll do:
systeminfo | findstr "Processor"

the result will be
Processor(s): 1 Processor(s) Installed.

and this is not sufficient result :( there should be more info

maybe I should use msinfo32 instead of systeminfo but i guess it is more complicated
many thanks for any advice and merry christmas :P

rfpd
Posts: 78
Joined: 06 Jul 2009 16:19
Location: Lisbon, Portugal
Contact:

Re: BasicInfo

#2 Post by rfpd » 24 Dec 2010 05:45

Looll put just systeminfo that should do it.

Regards rfpd

mischi
Posts: 12
Joined: 24 Dec 2010 02:31

Re: BasicInfo

#3 Post by mischi » 24 Dec 2010 06:01

definitively, but I don't need all info from systeminfo only about CPU...

rfpd
Posts: 78
Joined: 06 Jul 2009 16:19
Location: Lisbon, Portugal
Contact:

Re: BasicInfo

#4 Post by rfpd » 24 Dec 2010 10:06

Code: Select all

@echo off
FOR /F "skip=1 tokens=*" %%A IN ('REG.exe query

"HKEY_LOCAL_MACHINE\Hardware\Description\System

\CentralProcessor\0" /v "ProcessorNameString"') DO set "CPU=%%A"
echo %CPU%
pause


The output will show Processnamestring Reg_sz and then your cpu info, sorry i couldn't remove the part befor CPU info.
I was 30 minutes doing this :lol:

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: BasicInfo

#5 Post by !k » 24 Dec 2010 10:21


rfpd
Posts: 78
Joined: 06 Jul 2009 16:19
Location: Lisbon, Portugal
Contact:

Re: BasicInfo

#6 Post by rfpd » 24 Dec 2010 11:38

that will not says cpu info that he wants, watch, what he whants it's what is circuled by red.
Image

mischi
Posts: 12
Joined: 24 Dec 2010 02:31

Re: BasicInfo

#7 Post by mischi » 24 Dec 2010 13:25

rfpd: thank you very much, it works :)

Honestly I should read for /? more carefully after that maybe I would know about this use ;)
Let's say that whole "command" is clear for me, only parameter /v I don't understand:(

Never mind thank you one more time for your help.

rfpd
Posts: 78
Joined: 06 Jul 2009 16:19
Location: Lisbon, Portugal
Contact:

Re: BasicInfo

#8 Post by rfpd » 24 Dec 2010 17:36

You are welcome my friend /v means the name of the value on the regestry, by the way merry christmas and a happy new year ;).

mischi
Posts: 12
Joined: 24 Dec 2010 02:31

Re: BasicInfo

#9 Post by mischi » 30 Dec 2010 08:00

hi guys, it's me again :)
I supposed that I will be able finish my bat file without help but I was totally wrong :P
Last informations what I need to collect via my script are IP addresses of all my network interfaces.

for example:

Network card 1: IP address
Network card 2: IP address
Network card 3: IP address

I had few ideas :) but everything failed because there are more NCs. Do you have any idea how to do it? For in combination with regedit can't be used like in the previous case since default route is always different!

many thanks for any idea.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: BasicInfo

#10 Post by aGerman » 30 Dec 2010 10:01

I think IPCONFIG /ALL should display this informations.

Regards
aGerman

ChickenSoup
Posts: 79
Joined: 13 Dec 2010 10:32

Re: BasicInfo

#11 Post by ChickenSoup » 30 Dec 2010 10:10

If you want just IP Addresses, Something like this:

Code: Select all

SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

set nicnum=1
for /f "tokens=2 delims=:" %%a in ('ipconfig /all^|find "IP Address"') do (
@echo Network Card !nicnum!:%%a
set /a nicnum+=1
)


Note: This probably does not account for a disconnected nic however.

ChickenSoup
Posts: 79
Joined: 13 Dec 2010 10:32

Re: BasicInfo

#12 Post by ChickenSoup » 30 Dec 2010 10:33

You may need it like this to account for both XP and 7. I do all my tests on Windows XP:

Code: Select all

SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

set mynum=1
REM.-- your code goes here
echo.Hello World
for /f "tokens=2 delims=:" %%a in ('ipconfig /all^|find /i "IP Address"') do (
@echo Network Card !mynum!:%%a
set /a mynum+=1
)
for /f "tokens=2 delims=:(" %%a in ('ipconfig /all^|find /i "IPv4 Address"') do (
@echo Network Card !mynum!:%%a
set /a mynum+=1
)

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

Re: BasicInfo

#13 Post by ghostmachine4 » 30 Dec 2010 18:54

ChickenSoup wrote:You may need it like this to account for both XP and 7. I do all my tests on Windows XP:

Code: Select all

SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

set mynum=1
REM.-- your code goes here
echo.Hello World
for /f "tokens=2 delims=:" %%a in ('ipconfig /all^|find /i "IP Address"') do (
@echo Network Card !mynum!:%%a
set /a mynum+=1
)
for /f "tokens=2 delims=:(" %%a in ('ipconfig /all^|find /i "IPv4 Address"') do (
@echo Network Card !mynum!:%%a
set /a mynum+=1
)


there's no need to call ipconfig 2 times. Do something to the find ( or rather use findstr) to make it search for those 2 patterns at the same time.

mischi
Posts: 12
Joined: 24 Dec 2010 02:31

Re: BasicInfo

#14 Post by mischi » 31 Dec 2010 02:23

ChickenSoup: thank you very much, i will take it to the office and test it, but on my home computer it is work exactly as I imagined it would.
ghostmachine4: I prefer leaving it like this, I will have to revise it a little and I more or less understand this record :P but I will try to follow your suggestion.

thanks one more time and Happy New Year 2011 :P

ChickenSoup
Posts: 79
Joined: 13 Dec 2010 10:32

Re: BasicInfo

#15 Post by ChickenSoup » 31 Dec 2010 18:51

ghostmachine4 wrote:there's no need to call ipconfig 2 times. Do something to the find ( or rather use findstr) to make it search for those 2 patterns at the same time.

ghostmachine4, I'm new to using findstr. Could you present an example of the better way to do it?

Post Reply