How to access item in collection? Next code gives me error in last line.
<package>
<job id="NonDisabledServicesCollecting">
<COMMENT>
************************************************************
1 comment
2
3
************************************************************
</COMMENT>
<script language="VBScript">
flash_folder="I:\123\"
str_flash_folder_colFiles = ""
num_flash_folder_colFiles = 0
Set flash_folder_colFiles = CreateObject("Scripting.FileSystemObject").GetFolder(flash_folder).Files
WScript.Echo flash_folder_colFiles(1)
For Each flash_folder_objFile in flash_folder_colFiles
num_flash_folder_colFiles = num_flash_folder_colFiles + 1
str_flash_folder_colFiles = str_flash_folder_colFiles + cstr(num_flash_folder_colFiles) + " " + flash_folder_objFile.Name + vbCrLf
Next
Dim response
Do
response = InputBox("Please enter the number that corresponds to your selection:" + vbCrLf + str_flash_folder_colFiles, "Choose DLL to copy...")
If response = "" Then WScript.Echo "Input is empty." 'Detect Cancel
If IsNumeric(response) Then Exit Do 'Detect value response.
WScript.Echo "You must enter a numeric value."
Loop
selected_flush_DLL = flash_folder + flash_folder_colFiles(cint(response))
WScript.Echo selected_flush_DLL
</script>
</job>
</package>
The .Files collection can't be accessed by index:
You need a For Each loop to fill a random access collection e.g. an Array: