WshShell.Environment

機能

Environment プロパティには、WshEnvironment オブジェクト (環境変数のコレクション) が格納されます。strType を指定する場合、環境変数の存在場所を示す値として System、User、Volatile、または Process のいずれかを使用できます。strType を使用しない場合、Environment プロパティは、使用するオペレーティング システムごとに異なる種類の環境変数を返します。

 

関連

WshShellオブジェクトCurrentDirectory / Environment / SpecialFolders

 

サンプル

引数なし

Set ws = WScript
Set s = WScript.CreateObject("WScript.Shell")

ws.Echo "=== ==="
For Each e In s.Environment
  ws.Echo e
Next
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

=== ===
ComSpec=%SystemRoot%\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
OS=Windows_NT
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\
TEMP=%SystemRoot%\TEMP
TMP=%SystemRoot%\TEMP
USERNAME=SYSTEM
windir=%SystemRoot%
Path=C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\nodejs\;%SYSTEMROOT%\System32\OpenSSH\;C:\Program Files (x86)\GrapeCity\SAManager\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server Migration Assistant for Access\bin\
OnlineServices=Online Services
platformcode=KV
RegionCode=APJ
VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
NUMBER_OF_PROCESSORS=4
PROCESSOR_LEVEL=6
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
PROCESSOR_REVISION=8e09

***** script completed - exit code: 0 *****

 

PROCESS

Set ws = WScript
Set s = WScript.CreateObject("WScript.Shell")

ws.Echo "=== PROCESS ==="
For Each e In s.Environment("PROCESS")
  ws.Echo e
Next
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

=== PROCESS ===
=::=::\
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\さ\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP-S37MLN7
ComSpec=C:\WINDOWS\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING=Default
HOMEDRIVE=C:
HOMEPATH=\Users\さ
LOCALAPPDATA=C:\Users\さ\AppData\Local
LOGONSERVER=\\DESKTOP-S37MLN7
NUMBER_OF_PROCESSORS=4
OneDrive=C:\Users\さ\OneDrive
OnlineServices=Online Services
OS=Windows_NT
Path=C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\nodejs\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\GrapeCity\SAManager\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server Migration Assistant for Access\bin\;C:\Users\さ\AppData\Local\Microsoft\WindowsApps;C:\Users\さ\AppData\Roaming\npm;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
platformcode=KV
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=8e09
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\
PUBLIC=C:\Users\Public
RegionCode=APJ
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\Users\さ\AppData\Local\Temp
TMP=C:\Users\さ\AppData\Local\Temp
USERDOMAIN=DESKTOP-S37MLN7
USERDOMAIN_ROAMINGPROFILE=DESKTOP-S37MLN7
USERNAME=sakano
USERPROFILE=C:\Users\さ
VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
windir=C:\WINDOWS

***** script completed - exit code: 0 *****

 

VOLATILE

Set ws = WScript
Set s = WScript.CreateObject("WScript.Shell")

ws.Echo "=== VOLATILE ==="
For Each e In s.Environment("VOLATILE")
  ws.Echo e
Next
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

=== VOLATILE ===
LOGONSERVER=\\DESKTOP-S37MLN7
USERDOMAIN=DESKTOP-S37MLN7
USERNAME=sakano
USERPROFILE=C:\Users\さ
HOMEPATH=\Users\さ
HOMEDRIVE=C:
APPDATA=C:\Users\さ\AppData\Roaming
LOCALAPPDATA=C:\Users\さ\AppData\Local
USERDOMAIN_ROAMINGPROFILE=DESKTOP-S37MLN7

***** script completed - exit code: 0 *****

 

USER

Set ws = WScript
Set s = WScript.CreateObject("WScript.Shell")

ws.Echo "=== USER ==="
For Each e In s.Environment("USER")
  ws.Echo e
Next
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

=== USER ===
TEMP=%USERPROFILE%\AppData\Local\Temp
TMP=%USERPROFILE%\AppData\Local\Temp
Path=%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Users\さ\AppData\Roaming\npm;
OneDrive=C:\Users\さ\OneDrive

***** script completed - exit code: 0 *****

SYSTEM

Set ws = WScript
Set s = WScript.CreateObject("WScript.Shell")

ws.Echo "=== SYSTEM ==="
For Each e In s.Environment("SYSTEM")
  ws.Echo e
Next
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

=== SYSTEM ===
ComSpec=%SystemRoot%\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
OS=Windows_NT
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\
TEMP=%SystemRoot%\TEMP
TMP=%SystemRoot%\TEMP
USERNAME=SYSTEM
windir=%SystemRoot%
Path=C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\nodejs\;%SYSTEMROOT%\System32\OpenSSH\;C:\Program Files (x86)\GrapeCity\SAManager\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server Migration Assistant for Access\bin\
OnlineServices=Online Services
platformcode=KV
RegionCode=APJ
VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
NUMBER_OF_PROCESSORS=4
PROCESSOR_LEVEL=6
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
PROCESSOR_REVISION=8e09

***** script completed - exit code: 0 *****

 

関連

WshShellオブジェクトCurrentDirectory / Environment / SpecialFolders

 

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です