Skip to main content

systeminfo command

More
20 years 4 months ago #2175 by sahirh
Replied by sahirh on topic Re: systeminfo command
Following Neons very useful example, heres how you could shove something similar in a batchfile.

[code:1]
@echo off
echo [*] Collecting Relevant system information
echo Host Name : %computername% > %computername%.txt
systeminfo | find "OS" >> %computername%.txt
systeminfo | find "Domain" >> %computername%.txt
echo [*] Collecting Hotfix Information
echo. >> %computername%.txt
systeminfo | find "Hotfix(s)" >> %computername%.txt
[/code:1]

If anyone is interested, I don't mind kicking up a little perl script / c program that will read the data and tell you whether hotfixes are missing (of course this will have to be tallied against a standard count from somewhere..)

Sahir Hidayatullah.
Firewall.cx Staff - Associate Editor & Security Advisor
tftfotw.blogspot.com
More
20 years 4 months ago #2178 by Neon
Replied by Neon on topic Re: systeminfo command
That’s a nice batch file sahirh.... I might actually update my stuff to something that organized :wink:

Speaking of batch files, you know any site that’s good learning all those extra commands batch files support? Like the stuff %windir% %computername% using the > command to write to a file etc

I know some of them but I know I could know ALOT more...

Any sites that are available would be helpful :)
More
20 years 4 months ago #2183 by sahirh
Replied by sahirh on topic Re: systeminfo command
Actually most of that stuff was not batch file specific, its basic output redirection and piping, something you realise the power of when you use command line based operating systems long enough ;)

I'll just do a basic runthrough of some of the command :

> - this operator redirects the output of the command to a new file for example :
dir > directory.txt will output the directory contents to a file called directory.txt, overwriting any existing file with that name.

>> - same as above, but it appends or adds on the output to the end of an already existing file, if the file does not exist, it will create it.

| - this is the pipe symbol, basically you 'pipe' the output of the first command to the second command for example :
netstat | find "TCP" will run the netstat command, and chuck its output to the find command looking for the word '"TCP". This is a great way of chaining commands together, and in the *nix world is one of the most useful things you can find. The idea comes from plumbing -- literally connecting two things with a pipe. (Or so I have been led to believe, and in turn am leading you to believe ;) )

%whatever% - these are environment variables.. basically parameters set by the operating system.. for example %windir% on any windows machine will point to the directory windows is installed in.. whether thats c:\windows or d:\WINNT etc etc. You can use an environment variable anywhere you want. For a list, try typing 'set' at the command prompt.

Batch file specific :

%1, %2 etc - These refer to any parameters you pass to the batch file. For example , make a file called test.bat with this in it

[code:1]
type %1
[/code:1]

now from the command line when you type 'test file.txt' it will replace %1 everywhere in the batch file with 'file.txt'. If you pass another arguement, it will replace all %2s in the batch file with the arguement you passed. This is very useful for making your batch files interactive.

@ - putting an @ at the start of any command causes the command not to be displayed, only its output will be displayed. Very useful for making things look neat.

@echo off - echo off automatically turns command line echo off (basically the same as the above @ symbol) but if you set this at the start of a batch file, you wont need to keep typing @ before each command line ;)

Phew.. this shoulda been a post in itself... pity it'll get buried in the forums. Off the top of my head I can't think of any other useful stuff.. feel free to contribute your own nifty batch file nonsense.

Sahir Hidayatullah.
Firewall.cx Staff - Associate Editor & Security Advisor
tftfotw.blogspot.com
More
20 years 4 months ago #2191 by Neon
Replied by Neon on topic Re: systeminfo command
Ah that reminds me of the days when I was programming mIRC scripts, works exactly the same way I suppose...

Too bad I gave it up, it was a real challenge going through hundred lines of code finding a syntax error :)

But yeah it uses the %1 %2 variables and the | to split the commands.
I should of known they were similar :wink:
More
20 years 4 months ago #2192 by sahirh
Replied by sahirh on topic Re: systeminfo command
Aahh IRC scripting. I never really dug too deep into that, but it mustve been fun.

Off late I've returned to coding in a big way.. really brushing up on my C/C++ and am getting deeper into assembly. The way I see it, if you can understand things from the lowest level components, you'll see the bigger picture much clearer.

Same thing applies to networking. The guy who understands things at the bit level will understand better than the guy who deals with things at the packet level.

Its actually quite a fun challenge to setup tcpdump and force yourself to understand the hex without getting it prechewed and converted by a sniffer.

Sahir Hidayatullah.
Firewall.cx Staff - Associate Editor & Security Advisor
tftfotw.blogspot.com
More
20 years 3 months ago #2395 by naddyboy
Replied by naddyboy on topic Re: systeminfo command
thanx sahirh ... that was a very useful info

Syed
Time to create page: 0.149 seconds