Wednesday, July 21, 2010

DOS: SystemInfo

Problem Statement:
Using DOS command to get all the information pertaining to the sytem.

Solution:
Use of Dos coammnd: systeminfo.
Below is a typical output of systeminfo command on DOS prompt.


Using Perl Script to get OS Name:
use strict;
system("systeminfo find \"OS Name\" > C:\\temp\\temp.txt");
open(FH, "<", "C:\\temp\\temp.txt");
my $contents = ;
my @osInfo = split(':', $contents);
$osInfo[1] = s/\s\s+//g;
print $osInfo[1];

#This script would print the OS Name. Like it would print "Microsoft Windows 7 Utlimate" if run on Windows 7 - Ultimate Version of OS.

No comments: