Domanda

Sto cercando di scrivere uno strumento di monitoraggio del servizio come Servizi.MSC dove può essere trovato l'attributo "Accedere come" utilizzando WMI

Grazie

Erez

È stato utile?

Soluzione

Impostazione dell'account di servizio di Windows - C # e WMI ha alcuni c # che potrebbe aiutare - dovrebbe essere abbastanza facile da Converti in VBB.

Specificamente, Commento di asbf cerca di avere ciò di cui hai bisogno.

string serviceName = "eventLog";
System.Management.SelectQuery query = new System.Management.SelectQuery(string.Format("select name, startname from Win32_Service where name = '{0}'", serviceName));
using (System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher(query))
{
   foreach (System.Management.ManagementObject service in searcher.Get())
   {
       Console.WriteLine(string.Format("Name: {0} - Logon : {1} ", service["Name"], service["startname"]));
   }
}
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top