Delphi Wmi Query on a Remote Machine -


we use wmiset wmi queries on remote machines. works in delphi 2007 not available delphi xe.

i found code wmi queries previous question use wmi delphi. code snippet provided in answer no. 5 works on local machine, need know if possible execute wmi query on remote machine.

even if connect remote machine administrator credentials, eolesyserror: access denied exception.

regards, pieter.

pieter. before connect remote machine using wmi must enable dcom access specified user in remote machine.

read these articles understand , fix problems connecting remote machines using wmi.

additionally here leave more clear code connect wmi in remote machine. check part eoleexception exception processed error code , found cause of issue.

program wmiremote;  {$apptype console}  uses   sysutils,   activex,   comobj,   variants;  procedure  getwmiosinfo(const remotemachine,user,password : string); var   fswbemlocator : olevariant;   fwmiservice   : olevariant;   fwbemobjectset: olevariant;   fwbemobject   : olevariant;   oenum         : ienumvariant;   ivalue        : longword; begin;   fswbemlocator := createoleobject('wbemscripting.swbemlocator');   fwmiservice   := fswbemlocator.connectserver(remotemachine, 'root\cimv2', user, password);   fwbemobjectset:= fwmiservice.execquery('select * win32_operatingsystem','wql',0);   oenum         := iunknown(fwbemobjectset._newenum) ienumvariant;     while oenum.next(1, fwbemobject, ivalue) = 0     begin         writeln(fwbemobject.name);         //code         fwbemobject:=unassigned;     end;     fwbemobjectset:=unassigned; end;  begin  try     coinitialize(nil);     try       //getwmiosinfo('localhost','','');       getwmiosinfo('192.168.52.2','administrator','password');           couninitialize;     end;  except     on e:eoleexception         writeln(format('error code %d ($%x) msg : %s',[e.errorcode,e.errorcode, e.message]));      on e:exception         writeln(e.classname, ':', e.message);  end;  readln; end. 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -