• Здраво и добредојдовте на форумот на IT.mk.

    Доколку сеуште не сте дел од најголемата заедница на ИТ професионалци и ентузијасти во Македонија, можете бесплатно да се - процесот нема да ви одземе повеќе од 2-3 минути, а за полесна регистрација овозможивме и регистрирање со Facebook и Steam.

[PERL]WMI(Windows Management Instrumentation)

  • Ја почнал/а темата
  • #1

S

pwnz0r1lla
8 март 2007
1,550
52
www.it.com.mk
[hl=perl]
#!/usr/bin/perl
use Win32::OLE qw (in);
$strComputer = ".";

#connect to WMI
my $WMIProcesses = Win32::OLE->GetObject("winmgmts://$strComputer") || die;



print "****************** Computer Info *************************\n";

my $ComputerSystemCollection = $WMIProcesses->InstancesOf("Win32_ComputerSystem" );


if (Win32::OLE->LastError() != 0) {
print Win32::OLE->LastError()."\n";
}

foreach $ComputerSystemz (in $ComputerSystemCollection) {
print $ComputerSystemz->{Name}." ";
print $ComputerSystemz->{UserName}."\n";
print $ComputerSystemz->{Manufacturer}." : ";
print $ComputerSystemz->{Model}." : ";
print $ComputerSystemz->{Description}."\n";
}
print "_________________________________________________________\n\n\n\n\n";





print "******************** Start Up Commands ******************\n\n";

my $StartupCommandCollection = $WMIProcesses->InstancesOf("Win32_StartupCommand" );


if (Win32::OLE->LastError() != 0) {
print Win32::OLE->LastError()."\n";
}

foreach $StartupCommandz (in $StartupCommandCollection) {
print $StartupCommandz->{Name}." ";
print $StartupCommandz->{Command}."\n";

print $StartupCommandz->{User}." : ";
print $StartupCommandz->{UserSID}." : ";
print $StartupCommandz->{Location}."\n";
print " ----\n";
}

print "_________________________________________________________\n\n\n\n\n\";





print "********************* List Processes ********************\n\n";



my $ProcessCollection = $WMIProcesses->InstancesOf("Win32_PRocess" );


if (Win32::OLE->LastError() != 0) {
print Win32::OLE->LastError()."\n";
}

foreach $Processz (in $ProcessCollection) {
print $Processz->{ProcessID}." : ";
print $Processz->{Name}." : ";
print $Processz->{ExecutablePath}."\n";
}

print "_________________________________________________________\n\n\n\n\n";




print "********************* List Services ********************\n\n";


my $ServiceCollection = $WMIProcesses->InstancesOf("win32_service" );


if (Win32::OLE->LastError() != 0) {
print Win32::OLE->LastError()."\n";
}

foreach $drive (in $ServiceCollection) {
print $drive->{PathName}."\n";
}

print "_________________________________________________________\n\n\n\n\n";




print "****************** All Windows Patches ******************\n\n";

my $QuickFixEngineeringCollection = $WMIProcesses->InstancesOf("Win32_QuickFixEngineering" );


if (Win32::OLE->LastError() != 0) {
print Win32::OLE->LastError()."\n";
}

foreach $QuickFixEngineeringz (in $QuickFixEngineeringCollection) {
print $QuickFixEngineeringz->{HotFixID}." ";
print $QuickFixEngineeringz->{Description}." ";
print $QuickFixEngineeringz->{InstalledBy}." ";
print $QuickFixEngineeringz->{InstallDate}."\n";
}

print "_________________________________________________________\n\n\n\n\n";

[/hl]
[hl=perl]
#!/usr/bin/perl
#

use Win32::OLE;
use Getopt::Long;

my $strComputer = '';
my $command = '';


my $options = GetOptions('h=s' => \$strComputer,
'c=s' => \$command);

&usage unless ($strComputer && $command);

#connect to WMI
$wmi = Win32::OLE->GetObject("winmgmts://$strComputer/root/cimv2:Win32_PRocess");

if( 0 == $wmi->Create("$command", undef, undef, $Pid ) )
{
print "PID $Pid created\n";
}
else
{
print "Failed.\n";
}


###
sub usage{
print "############WMI anycmd execution############\n";
print "Usage: $0 --h=host --c=command\n";
print "Ex.:$0 --h=localhost --c=calc.exe\n";
print "############################################\n";
exit(1);
}
[/hl]

*Shto e toa WMI? Povekje ovde,a mozhe i ovde :)
 

Нови мислења

Последни Теми

Статистика

Теми
43,577
Мислења
823,820
Членови
28,079
Најнов член
ivannalex
На врв Дно