LotusScript: Obtendo as variáveis de ambiente do Windows: Difference between revisions

From Wiki
(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...)
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
A common question is how to get Windows Desktop Username and so on.  
Uma pergunta comum em Windows é como obter o usuário atual do sistema, o nome da máquina, etc ...


So this simple code make this
O código abaixo faz isso


  Sub Initialize
  Sub Initialize
     Dim wshShell As Variant
     Dim wshShell As Variant
     Dim strUser As String
     Dim strUser As String

Latest revision as of 11:52, 30 October 2008

Uma pergunta comum em Windows é como obter o usuário atual do sistema, o nome da máquina, etc ...

O código abaixo faz isso

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