Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

  1. ###############################################
  2. # Brings out differences between:
  3. # MKS
  4. # ActiveState
  5. # Standard distribution
  6. #
  7. # Turn this into a proper test, fail gracefully
  8. # and print error messages
  9. ###############################################
  10. #####################################################
  11. # We need different preambles for each implementation
  12. #####################################################
  13. # Use these 4 lines to use ActiveState Perl
  14. #use OLE;
  15. #use Win32;
  16. #$locator = CreateObject OLE 'Wbem.Locator';
  17. #$services = $locator->ConnectServer();
  18. # Use these 3 lines to use MKS Perl
  19. #require COM;
  20. #$locator = new IDispatch 'Wbem.Locator';
  21. #$services = $locator->ConnectServer();
  22. # Use these 4 lines to use "Standard" Perl
  23. # This is the only one that can use a Moniker
  24. use Win32::OLE;
  25. use Win32::OLE::Enum;
  26. $services = Win32::OLE->GetObject('winmgmts:');
  27. $services->{Security_}->{ImpersonationLevel} = 3;
  28. $enum = $services->InstancesOf("Win32_process");
  29. foreach $inst (Win32::OLE::Enum->new($enum)->All())
  30. {
  31. $nameValue = $inst->{Name};
  32. $processIdValue = $inst->{ProcessId};
  33. print "$processIdValue $nameValue\n";
  34. }