Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetFile cannot find file when value coming from array

Status
Not open for further replies.

mshicks

Technical User
Mar 5, 2011
3
US
I am trying to use vbscript to pull information out of some exe files. I have a text file with all the exe's listed. I read in the text file to an array and split it by lines. Then my script needs to pull the parent folder and the file name from the exe and output it to another text file.

The problem I am having is that when the script tries to open the exe file it says that it can not find the file. The information appears to be coming from the array value correctly and if I paste a line from the text file in place of the array value it works just fine.

I have tried outputting the array values to text file and everything seems to come out correct but every time I try to use the array value it says it can't find the file.

Here is my code

_________________________________________________________________

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSO.OpenTextFile ("C:\Users\mshicks\Desktop\test.txt", ForReading)
Set objWriteFile = objFSO.CreateTextFile ("C:\Users\mshicks\Desktop\testOut.txt")
Do Until objReadFile.AtEndOfStream

strNextLine = objReadFile.Readline
arrEXEList = Split(strNextLine,vbCrLf)

For Each exe In arrEXEList
Set objFile = objFSO.GetFile (exe)
objWriteFile.WriteLine (exe) 'Checking Values
objWriteFile.Write (objFSO.GetParentFolderName(objFile)_
& "," & objFSO.GetFileName(objFile) & vbCrLf)
Next
Loop

_________________________________________________________________

Here is an example of the text in test.txt

"R:\AdminStudio\carrigan\mig tool\568ACC564D404410AF2B0E4DC67347B5\WindowsFolder\unvise32.exe"
"R:\AdminStudio\carrigan\mig tool\568ACC564D404410AF2B0E4DC67347B5\ProgramFilesFolder\TSP\Science Court - Living Things\SciCourt.exe"
"R:\AdminStudio\carrigan\mig tool\9D48B6D3C7D541788F09FB16665C7AD0\ProgramFilesFolder\InstallShield Installation Information\{7A1CC877-BE76-4AF6-8B97-8A2E625FB9D3}\Setup.exe"
"R:\AdminStudio\carrigan\mig tool\9D48B6D3C7D541788F09FB16665C7AD0\CommonFilesFolder\InstallShield\engine\6\Intel 32\iKernel.exe"
"R:\AdminStudio\carrigan\mig tool\9D48B6D3C7D541788F09FB16665C7AD0\WindowsVolume\Learn About Matter\LAMatter.exe"
"R:\AdminStudio\carrigan\mig tool\5A2E15F331944093B94EC31D079484B6\ProgramFilesFolder\Java\j2re1.4.2_12\bin\java.exe"
"R:\AdminStudio\carrigan\mig tool\5A2E15F331944093B94EC31D079484B6\ProgramFilesFolder\Java\j2re1.4.2_12\bin\jucheck.exe"
"R:\AdminStudio\carrigan\mig tool\5A2E15F331944093B94EC31D079484B6\ProgramFilesFolder\Java\j2re1.4.2_12\bin\jpicpl32.exe"
"R:\AdminStudio\carrigan\mig tool\5A2E15F331944093B94EC31D079484B6\ProgramFilesFolder\Java\j2re1.4.2_12\bin\rmid.exe"
"R:\AdminStudio\carrigan\mig tool\5A2E15F331944093B94EC31D079484B6\ProgramFilesFolder\Java\j2re1.4.2_12\bin\kinit.exe"
"R:\AdminStudio\carrigan\mig tool\5A2E15F331944093B94EC31D079484B6\ProgramFilesFolder\Java\j2re1.4.2_12\bin\rmiregistry.exe"

 
Nevermind I figured a different way. I went with not using an array. I'm just letting the loop read through the text file while pulling the information I need out in each cycle of the loop.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top