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