Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

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.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

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

Check to see if file exists

lpb71 (TechnicalUser) (OP)
17 Aug 06 7:10
Below is a snippet of my vbscript that check to see if a file(s) exists via a variable and writes to a log file if the file(s) exists.  If I enter the parameters as per the labels below in the fso line, it works fine, however if I enter them as below is does not seem to pickup from the labels.  How can I get my script to use the labels I have created.


Set objFSO = CreateObject("Scripting.FileSystemObject")
set LogFile=objfso.opentextfile("dvdlog.txt",2,True)

branchid =  InputBox("Enter Branch Number")
dvddrive = InputBox("Enter Drive Letter for DVD Writer")

Label = "b" + (branchid) + "sr01"
File1 = " c:\temp\b" + (branchid) + "sr01.0"
File2 = " c:\temp\b" + (branchid) + "sr01.1"
File3 = " C:\temp\b" + (branchid) + "sr01.2"
FileA = (dvddrive) + ":\b" + (branchid) + "sr01.0"
FileB = (dvddrive) + ":\b" + (branchid) + "sr01.1"
FileC = (dvddrive) + ":\b" + (branchid) + "sr01.2"
wscript.echo "File2 =" & chr(34) & FILE2 & chr(34)

If objFSO.FileExists (FILE3) then
logfile.writeLine ("3 Files Exist")
end if

If objFSO.FileExists (FILE2) then
logfile.writeLine ("2 Files Exist")
end if

If objFSO.FileExists (FILE1) then
logfile.writeLine ("1 Files Exist")
end if

tsuji (TechnicalUser)
17 Aug 06 7:33
Take out wscript.quit inside the if-end if. Quit means quit and stop proceeding to next test.
lpb71 (TechnicalUser) (OP)
17 Aug 06 7:38
I need my script to quit after it writes to the log file, otherwise it will find the 2nd file and write that 2 files exist.  The script should only quit if it meets the if statement.  Shouldn't it?
tsuji (TechnicalUser)
17 Aug 06 7:51
The file path has to be exact, whitespace counted. Your File1... etc have a leading space. Why?
lpb71 (TechnicalUser) (OP)
17 Aug 06 7:53
Typo, didn't notice that - many thanks.

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