Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check if .exe is running as Admin on Vista
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01305105
Message ID:
01306569
Vues:
3
Sergey,

If I understood correctly your code will list all the groups that exist in the computer regardless of the current user, I think what Jos needs this (I might be completely wrong, I am taking a look at this while trying to solve a problem that is driving me crazy, apologies if it is the case)
lparameters tcDomain, tcUserName
local loWMI, loAccount, lcDomain, lcUserName, loGroups, loGroup, lnStartTime

lcDomain			= Iif(Vartype(tcDomain) = 'C' and not Empty(tcDomain), Alltrim(tcDomain), Getenv('UserDomain'))
lcUserName			= Iif(Vartype(tcUserName) = 'C' and not Empty(tcUserName), Alltrim(tcUserName), Getenv('UserName'))

if not Empty(lcDomain) and not Empty(lcUserName)
	try
		loLocator		= CREATEOBJECT('WBEMScripting.SWBEMLocator')
		loWMI			= loLocator.ConnectServer()
		loAccount		= loWMI.Get([Win32_Account.Domain="] + lcDomain + [",Name="] + lcUserName + ["])
		loGroupUsers		= loWMI.ExecQuery([Select * from Win32_GroupUser where PartComponent=']+Strtran(loAccount.Path_.Path, '\', '\\')+['])
		llIsAdmin		= .f.
		for each loGroupUser in loGroupUsers
			loGroup			= Getobject([WinMgmts:] + loGroupUser.GroupComponent)
			llIsAdmin		= loGroup.Name = 'Administrators'
			exit
		endfor
		? 'Is Admin?', llIsAdmin
	catch
		? 'Error'
	endtry
endif
"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