Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thank you for the best reply I've ever had to a forum question - it's extremely comprehensive and legible and answers my query thoroughly..."

Geography

Where in the world do Tek-Tips members come from?

GetFile cannot find file when value coming from array

mshicks (TechnicalUser)
11 Jan 12 12:49
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"

 
mshicks (TechnicalUser)
11 Jan 12 12:52
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.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close