Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How reliable/secure are getenv('User') & WScript.Network
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00953302
Message ID:
00953567
Vues:
21
Just to give a 3rd alternative, you can use WMI:
? getCurrentUser()


function getCurrentUser()
local loWMIService, loWBEMLocator, lcDomain, loCSs, loCS

lcUser		= 'N/A'
try
	loWBEMLocator	= createObject("wbemScripting.SwbemLocator")
	loWMIService	= loWBEMLocator.ConnectServer()
catch
	loWMIService	= null
endtry

if not Isnull(loWMIService)
	loCSs			= loWMIService.ExecQuery('Select UserName from Win32_ComputerSystem')
	for each loCS in loCSs
		lcUser		= loCS.UserName
		exit
	endfor
endif
return lcUser
lcUser will have the "domain\username" format, from where you can parse both
"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