1. | Open Notead or some other script editor.
|
2. | On the first line, type Option Explicit.
|
3. | Use the Dim command to declare the following variables: objWMIService, colItems, objItem, wmiQuery, and strComputer.
|
4. | Use WScript.Echo and the Now function to indicate the script is beginning its run.
|
5. | Assign the value of "." to the variable strComputer.
|
6. | Assign the query "Select * from Win32_Environment" to the variable wmiQuery.
|
7. | Set objWMIService equal to the handle that comes back from the GetObject function with the winmgmts: moniker. Incorporate the variable strComputer to tell WMI which computer to use to execute the connection.
|
8. | Use the colItems variable to hold the object returned from using the execQuery method of the SWbemServicesEx object. This is seen below:
Set colItems = objWMIService.ExecQuery(wmiQuery)
|
9. | Use a For Each...Next loop to iterate through the collection called colItems. For each objItem in colItems, echo out the following properties: Caption, Description, InstallDate, Name, Status, SystemVariable, UserName, and VariableValue.
|
10. | Close out the For Each...Next loop.
|
11. | Echo a line indicating the script is finished and use the Now function to print out the time.
|
12. | Save your work as SysEnvironment.vbs.
|
13. | Run the script in CScript.
|