Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WMI Service - How To Tell If it is Running?
Message
 
À
27/09/2007 09:43:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01257135
Message ID:
01257249
Vues:
27
Tracy,

Note that Sergey's code will work only if you are connecting to the local machine (lcComputer = '.' or 'localhost' or '{Your local machine name}), but it will still fail if you are trying to connect to a remote machine that does not have WMI, not sure what you are trying to do, for if you are only using it for local machine, you do not need anything there, for all those values are default, you can simplify by saying GetObject("winmtmts:"), for "root/cimv2" is also the default namespace. Now, I try to avoid the use of monikers for wmi in favor of WBEM's ConnectServer('ServerName', 'NameSpace', 'UserName', 'Password') (all optional too, so ConnectServer() will suffice to connect to the root/cimv2 namespace of the local machine, so I will use
loLocator		= CREATEOBJECT('WBEMScripting.SWBEMLocator')
loWMI			= loLocator.ConnectServer() && local machine logged on user
Now you are not using monikers so if it errors out it is trappable, just wrap it on a try catch; but the other advantage is that with ConnectServer you can pass different credentials if you want to do so, something you can not do with monikers and there also an old bug if you use VFP 6, but that is not relevant any longer
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform