By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,252 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,252 IT Pros & Developers. It's quick & easy.

Find files for remote machine

P: 8
Hi,

I want to find all the *.Exe files for Remote machine.Is it possible to collect the information.If so, please any one help me in this.


Thanks in Advance.
Feb 19 '08 #1
Share this Question
Share on Google+
2 Replies


KevinADC
Expert 2.5K+
P: 4,059
Your question is very vague. How do you intend to connect to the remote machine to search the directories for files?
Feb 19 '08 #2

P: 8
The following Perl Script will collect all the *.EXE file from the local machine but It is failing to collect the data from Remote machine.If any one know where iam going wrong.Please any one help me on this.......


Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use Win32::OLE('in');
  3. #use File::Find;
  4. use File::List;
  5. Win32::OLE->Option(Warn => 0);
  6.  
  7. use constant wbemFlagReturnImmediately => 0x10;
  8. use constant wbemFlagForwardOnly => 0x20;
  9.  
  10. use constant iFlags => 0;
  11.  
  12.  
  13. my ($strComputer, $objSWbemLocator, $objSWbemServices, $colSWbemObjectSet, $objWMILastError);    
  14.  
  15. $strComputer =@ARG[0];
  16.  
  17.  
  18. #SWbemLocator - Connect to server
  19. $objSWbemLocator = Win32::OLE->new('WbemScripting.SWbemLocator');
  20.  
  21. $objSWbemServices = $objSWbemLocator->ConnectServer($strComputer, 'root\\cimv2', 'domain\user', 'Password');
  22.  
  23.  
  24. #SWbemServices - ExecQuery
  25. $colSWbemObjectSet = $objSWbemServices->ExecQuery('SELECT * FROM Win32_LogicalDisk', 'WQL', iFlags);
  26.  
  27. if ((0 + Win32::OLE::LastError())) {
  28.     print '0x' . sprintf("%x", (0 + Win32::OLE::LastError())) . ' - ' . ('' . Win32::OLE::LastError()), "\n";
  29.     $objWMILastError = Win32::OLE->new('WbemScripting.SWbemLastError');
  30.     print 'Operation: ' . $objWMILastError->Operation, "\n";
  31.     print 'ParameterInfo: ' . $objWMILastError->ParameterInfo, "\n";
  32.     print 'ProviderName: ' . $objWMILastError->ProviderName, "\n";
  33.     exit (1);
  34. }
  35.  
  36.  
  37. foreach my $objSWbemObject (in $colSWbemObjectSet) {
  38.  
  39. my ($drive,$type);
  40.  
  41. $drive=$objSWbemObject->{Caption};
  42.   $type=$objSWbemObject->{DriveType};
  43.  
  44. if($type==3)
  45.   {
  46.     print "$drive-$type\n";
  47.     $drive=$drive."\\";
  48.      my @oldFiles;
  49.  
  50.      find(\&cleanup,$drive);
  51.      sub cleanup {
  52.             push(@oldFiles, $File::Find::name);
  53.            if((/\.EXE$/)||(/\.exe$/))
  54.               {
  55.                        #print "$_\n";
  56.                 print stdout "$File::Find::name\n";
  57.  
  58.    }
  59.  
  60.   }
  61.    }
  62.  
  63. }
Feb 22 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.