Subversion Repositories camp_sysinfo_client_3

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
72 rodolico 1
#! perl 
2
 
3
# https://perlgems.blogspot.com/2012/06/retrieve-windows-system-information.html
4
# https://stackoverflow.com/questions/334686/how-can-i-detect-the-operating-system-in-perl
5
 
6
use Win32;
7
use Win32::SystemInfo;
8
use Win32::DriveInfo;
9
use Win32::IPConfig;
10
use strict;
11
use warnings;
12
 
13
print "OS Information\n";
14
my $computer=Win32::NodeName();
15
print "The computer name is $computer\n";
16
 
17
my $domain=Win32::DomainName();
18
print "The computer is a member of the $domain domain/workgroup\n";
19
 
20
my $OS=Win32::GetOSDisplayName();
21
print "The OS is $OS\n";
22
 
23
my $fs=Win32::FsType();
24
print "The filesytem is $fs\n";
25
 
26
my $user=Win32::LoginName();
27
print "The current user is $user\n";
28
 
29
my $admin=Win32::IsAdminUser();
30
if($admin!=0){
31
    print "$user is running this script as admin\n\n\n";
32
}
33
else{
34
    print "$user is not running this script as admin\n\n\n";
35
}
36
 
37
print "Processor and RAM Information\n";
38
my %processor;
39
Win32::SystemInfo::ProcessorInfo(%processor);
40
for (my $i=0;$i<$processor{NumProcessors};$i++) {
41
    print "Processor$i\n";
42
    print "Processor Name: " . $processor{"Processor$i"}{ProcessorName} . "\n";
43
    print "Processor Info: " . $processor{"Processor$i"}{Identifier} . "\n";
44
    print "Processor Speed: " . $processor{"Processor$i"}{MHZ} . "MHz\n\n";
45
}
46
 
47
my %memory;
48
Win32::SystemInfo::MemoryStatus(%memory, 'GB');
49
print "The computer has $memory{TotalPhys} GB of RAM\n\n\n";
50
 
51
my %dtypes=(0 => "Undertmined",
52
1 => "Does Not Exist",
53
2 => "Removable",
54
3 => "Hardrive",
55
4 => "Network",
56
5 => "CDROM",
57
6 => "RAM Disk");
58
 
59
print "Drive Information\n";
60
my @drives = Win32::DriveInfo::DrivesInUse();
61
foreach my $drive (@drives){
62
    my $type=Win32::DriveInfo::DriveType($drive);
63
    print "Drive $drive is a $dtypes{$type}\n";
64
 
65
}
66
 
67
print "\n\nNetwork Information";
68
my $ipconfig = Win32::IPConfig->new($computer)
69
        or die "Unable to connect to $computer\n";
70
foreach my $adapter ($ipconfig->get_adapters) {
71
    print "\nAdapter '", $adapter->get_name, "':\n";
72
 
73
    print "Description=", $adapter->get_description, "\n";
74
 
75
    print "DHCP enabled=",
76
    $adapter->is_dhcp_enabled ? "Yes" : "No", "\n";
77
 
78
    my @ipaddresses = $adapter->get_ipaddresses;
79
    print "IP addresses=@ipaddresses (", scalar @ipaddresses, ")\n";
80
 
81
    my @subnet_masks = $adapter->get_subnet_masks;
82
    print "subnet masks=@subnet_masks (", scalar @subnet_masks, ")\n";
83
 
84
    my @gateways = $adapter->get_gateways;
85
    print "gateways=@gateways (", scalar @gateways, ")\n";
86
 
87
    print "domain=", $adapter->get_domain, "\n";
88
 
89
    my @dns = $adapter->get_dns;
90
    print "dns=@dns (", scalar @dns, ")\n";
91
 
92
    my @wins = $adapter->get_wins;
93
    print "wins=@wins (", scalar @wins, ")\n";
94
}