The following VBScript runs at WSH (Window Scripting Host). It is used to list the items in “My Computer” folder. The Object “Shell.Application” is required for this to work.
Const MY_COMPUTER = &H11&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
WScript.Echo objFolderItem.Path
Set colItems = objFolder.Items
For Each objItem in colItems
WScript.Echo objItem.Name
Next
The output is something like:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
OS (C:)
Data (D:)
Temp (E:)
DVD RW Drive (F:)
CD Drive (H:)
***** script completed - exit code: 0 *****
–EOF (The Ultimate Computing & Technology Blog) —
144 wordsLast Post: The Halting Problem
Next Post: VBScript Malware Demo using FileSystemObject