24-4 ?腦系統管?

ڭ̥iHCXP SYSTEM nܼơG

lɡ]envVarSystem01.js^G]ǦϰUYi^
// CXnܼ

wshShell = WScript.CreateObject("WScript.Shell");
wshSysEnv = wshShell.Environment("SYSTEM");
WScript.Echo("nܼơG");
name="windir"; WScript.Echo(name+" = "+wshSysEnv(name));
name="path"; WScript.Echo(name+" = "+wshSysEnv(name));
name="NUMBER_OF_PROCESSORS"; WScript.Echo(name+" = "+wshSysEnv(name));
name="OS"; WScript.Echo(name+" = "+wshSysEnv(name));
name="PROCESSOR_ARCHITECTURE"; WScript.Echo(name+" = "+wshSysEnv(name));
name="temp"; WScript.Echo(name+" = "+wshSysEnv(name));

嫬ܵGpUG

nܼơG windir = %SystemRoot% path = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\matlab6p 5\bin\win32;C:\Program Files\Microsoft SQL Server\90\Tools\binn\ NUMBER_OF_PROCESSORS = 1 OS = Windows_NT PROCESSOR_ARCHITECTURE = x86 temp = %SystemRoot%\TEMP ڭ̥iHCXP SYSTEM ܼơG

lɡ]envVarSystem02.js^G]ǦϰUYi^
// Ҧ SYSTEM ܼƦC

shell = WScript.CreateObject("WScript.Shell");
envObj = shell.Environment("SYSTEM");
WScript.Echo("Ҧ SYSTEM ܼƦCG");
WScript.Echo("No. of env. variables = "+envObj.length);
var Enum=new Enumerator(envObj) 
for (Enum.moveFirst(); !Enum.atEnd(); Enum.moveNext())
	WScript.Echo(Enum.item());

嫬ܵGpUG

Ҧ SYSTEM ܼƦCG No. of env. variables = 12 ComSpec=%SystemRoot%\system32\cmd.exe Path=C:\PROGRAM FILES\THINKPAD\UTILITIES;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\PC-Doctor for Windows\services;c:\matlab6p5\bin\win32 windir=%SystemRoot% OS=Windows_NT PROCESSOR_ARCHITECTURE=x86 PROCESSOR_LEVEL=6 PROCESSOR_IDENTIFIER=x86 Family 6 Model 9 Stepping 5, GenuineIntel PROCESSOR_REVISION=0905 NUMBER_OF_PROCESSORS=1 PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH TEMP=%SystemRoot%\TEMP TMP=%SystemRoot%\TEMP ڭ̥iHCXP PROCESS ܼơG

lɡ]envVarProcess01.js^G]ǦϰUYi^
// Ҧ PROCESS ܼƦC

shell = WScript.CreateObject("WScript.Shell");
envObj = shell.Environment("PROCESS");
WScript.Echo("Ҧ PROCESS ܼƦCG");
WScript.Echo("No. of env. variables = "+envObj.length);
var Enum=new Enumerator(envObj) 
for (Enum.moveFirst(); !Enum.atEnd(); Enum.moveNext())
	WScript.Echo(Enum.item());

嫬ܵGpUG

Ҧ PROCESS ܼƦCG No. of env. variables = 35 =::=::\ =C:=C:\Documents and Settings\user =D:=D:\users\jang\books\wsh\example =ExitCode=00000000 ALLUSERSPROFILE=C:\Documents and Settings\All Users APPDATA=C:\Documents and Settings\user\Application Data CLASSPATH=.;.;C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~1\JMF21~1.1E\lib;%systemroot%\java\classes;. CommonProgramFiles=C:\Program Files\Common Files COMPUTERNAME=ROGER ComSpec=C:\WINDOWS\system32\cmd.exe HOMEDRIVE=C: HOMEPATH=\Documents and Settings\user include=C:\Program Files\Microsoft Visual Studio\VC98\atl\include;C:\Program Files\Microsoft Visual Studio\VC98\mfc\include;C:\Program Files\Microsoft Visual Studio\VC98\include lib=C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib;C:\Program Files\Micro soft Visual Studio\VC98\lib LOGONSERVER=\\ROGER MSDevDir=C:\Program Files\Microsoft Visual Studio\Common\MSDev98 NUMBER_OF_PROCESSORS=1 OS=Windows_NT Path=C:\PROGRAM FILES\THINKPAD\UTILITIES;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATITechnologies\ATI Control Panel;C:\Program Files\PC-Doctor for Windows\services;c:\matlab6p5\bin\win32;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;;c:\borland\Bcc55\bin;d:\users\jang\batch;d:\users\jang\util PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH PROCESSOR_ARCHITECTURE=x86 PROCESSOR_IDENTIFIER=x86 Family 6 Model 9 Stepping 5, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=0905 ProgramFiles=C:\Program Files PROMPT=$P$G SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\WINDOWS TEMP=C:\DOCUME~1\user\LOCALS~1\Temp TMP=C:\DOCUME~1\user\LOCALS~1\Temp USERDOMAIN=ROGER USERNAME=Roger USERPROFILE=C:\Documents and Settings\user windir=C:\WINDOWS ڭ̥iHϥ WSH ӧܻPtά]wAҦpAڭ̥iHϥ RegRead() ŪX Registry ȡAҦpG Error: D:\users\jang\books\wsh/example/registry01.js does not exist!