LotusScript: Obtendo as variáveis de ambiente do Windows

From Wiki
Revision as of 21:30, 28 February 2008 by Ebasso (talk | contribs) (New page: A common question is how to get Windows Desktop Username and so on. So this simple code make this Sub Initialize Dim wshShell As Variant Dim strUser As String Dim strComput...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A common question is how to get Windows Desktop Username and so on.

So this simple code make this

Sub Initialize
   Dim wshShell As Variant
   Dim strUser As String
   Dim strComputer As String
   Dim strServer As String 
   Dim strUserDomain As String 
	
   Set wshShell = CreateObject("WScript.Shell")
   strUser = wshShell.ExpandEnvironmentStrings("%USERNAME%")
   Print "User [" + strUser + "]"
   
   strComputer = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
   Print "Computer [" +strComputer + "]"
 	
   strServer = wshShell.ExpandEnvironmentStrings("%LOGONSERVER%")
   Print "logonServer [" + strServer + "]"
 
   strUserDomain = wshShell.ExpandEnvironmentStrings("%USERDOMAIN%")
   Print "strUserDomain [" + strUserDomain + "]"
End Sub