Search notes:

VBA: Windows Script Host

Programatically adding the reference to the Windows Script Host object model (C:\Windows\SysWOW64\wshom.ocs) to a VBA project:
thisWorkbook.VBProject.references.addFromGuid _
        GUID   :="{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}" , _
        major  :=  1                                      , _
        minor  :=  0

Show environment variables

The following scriptlet shows environment variables:
option explicit

sub wsh_environments() ' {

    dim wsh     as new wshShell

    showEnv wsh, "User"     ' Values as stored in the Registry under HKCU\Environment
    showEnv wsh, "System"   ' Values as stored in the Registry under HKLM\System\CurrentControlSet\Control\Session Manager\Environment
    showEnv wsh, "Volatile" '
    showEnv wsh, "Process"  '

end sub ' }

sub showEnv(wsh as wshShell, env as string) ' {

    debug.print "Show values for environment " & env

    dim envItem as variant
    for each envItem in wsh.environment(env)
      '
      ' envItem is NAME=VALUE, for example
      ' TEMP=%USERPROFILE%\AppData\Local\Temp
      '
        debug.print "  " & envItem
    next envItem

end sub ' }
Github repository about-VBA, path: /object-libraries/windows-script-host/environment.bas

TODO

This page should probably be merged with WSH

See also

Don't confuse wScript.shell with shell.application (Shell Automation Service).
Useful object libraries

Index