WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Environment

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List All Environment Variables


Question:

Hi all is there a command that would help get the name of the Domain the computer is in if it is on one or if it is part of a workgroup. The OS is WinXp.

Answer:

Here is a kind of non-simple MIL-SPEC version of that code. (Ummm handles lots of OS's) I think you can probably ferret out the info you need.

os = WinVersion(4)
If os==5 
   ;95/98/ME
   ;The UserDomain property does not work on Windows98 and Windows ME unless the USERDOMAIN environment variable is set. 
   ;The variable is not set by default.
   domain = StrUpper(Environment("USERDOMAIN"))
   If domain==""
      If !RegExistValue(@REGMACHINE,"System\CurrentControlSet\Services\VxD\VNETSUP[Workgroup]")
          domain="unknown"
          dmsstring="WorkGroup:"
      Else 
          domain = StrUpper(RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Services\VxD\VNETSUP[Workgroup]"))
          dmsstring="WorkGroup:"
      EndIf
      If !RegExistValue(@REGMACHINE,"Network\Logon[username]") Then username="unknown"
      Else username = StrUpper(RegQueryValue(@REGMACHINE,"Network\Logon[username]"))   
   EndIf
Else
;NT 4/2000/XP
    ;domain = StrUpper(Environment("USERDOMAIN"))
    If !RegExistValue(@REGMACHINE,"Software\Microsoft\Windows NT\CurrentVersion\winlogon[CachePrimaryDomain]")
        ErrorMode(@OFF)
        If FileExist("wwwnt44I.dll")
           flag = AddExtender("wwwnt44i.dll",32002)
        Else
           If FileExist("wwwnt34I.dll") 
              flag = AddExtender("wwwnt34i.dll",32002)
           Else
              flag=0
           EndIf
        EndIf
        If flag==0
            domain = "*UNKNOWN*"
        Else
            domain=wntLsaPolGet("","PrimaryDomain",1)
        EndIf
        ErrorMode(@CANCEL)
        If domain==0 Then domain="unknown"
        dmsstring="WorkGroup:"
    Else 
        domain=RegQueryValue(@REGMACHINE,"Software\Microsoft\Windows NT\CurrentVersion\winlogon[CachePrimaryDomain]")
        dmsstring="Domain:"
    EndIf
    username = StrUpper(Environment("USERNAME"))
EndIf

Question:

I've been looking for a list of all Windows environment and user variables that are used in Windows 95 and later. (Preferable in a side by side version comparison.) I have not found anything more than a list for a specific version of Windows. Does anyone know where to find one, or have one they'd like to share?

Answer:

Give this a try:
tempfile = FileCreateTemp("ENV")
RunWait(ENVIRONMENT("COMSPEC"),StrCat("/c Set > ",tempfile))
env = FileGet(tempfile)
Message("Environment Vars",env)
FileDelete(tempfile)
exit

Article ID:   W16437
File Created: 2005:02:18:12:20:34
Last Updated: 2005:02:18:12:20:34