automated wscript command causes error in vbs program

Hi,

I have a .vbs file that zipps up my archived database files. I would like to automate this procedure so it kicks off once per week.

I found a nifty little tool called delyer(tm) by cottonwood. It allows you to kick off a program and set when you want it to start and if you want to repeat it.

Both work independently but when I combine the two I get a file not found error.

The command line for Delayer is:

C:\DELAYER\DELAYER.EXE "C:\WINDOWS\system32\wscript.exe C:\Zip_files.vbs" /D20

the vb script is as follows:

Dim fso, dir_initial, dir_initial_zip, zip_files, read_file, reply, f, fc, fl

dir_initial     = "D:\oracle\oradata\testp1\archive"
dir_initial_zip = "D:\oracle\oradata\testp1\archive\zipped"

set fso       = CreateObject("Scripting.FileSystemObject")
set zip_files = CreateObject("WScript.shell")

set f  = fso.Getfolder(dir_initial)
set fc = f.files
reply = 0

for each fl in fc
    if reply = 0 then
   
          zip_files.run "cmd /c cd " & dir_initial & " & pkzip -n+ -exx " & dir_initial_zip & "\" & left(fl.name,4) & ".zip " & fl.name,0,true
        wscript.sleep 5000
          zip_files.run "cmd /c cd " & dir_initial_zip & " & pkzip " & left(fl.name,4) & " -n+ -v > list.txt 2>&1",0,true
         wscript.sleep 5000
          Set read_file = fso.OpenTextFile(dir_initial_zip & "\list.txt", 1)
          reply = InStr(1, read_file.ReadAll, fl.name, 1)
            if reply <> 0 then
                fso.deletefile(fl)
                reply = 0
             end if
          read_file.close
     
     end if
next

--------------------------

It falls over on line:

  Set read_file = fso.OpenTextFile(dir_initial_zip & "\list.txt", 1)

saying

error: File not found
code: 800A0035
can anyone explain why I cannot run the two together?



joehodgeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
The most obvious possibility is that 5 seconds is not long enough to wait for the file creation.
0
joehodgeAuthor Commented:
Hi,

If i double click on the .vbs file it works perfectly so I think it has something to do with the wscipt object?
0
EDDYKTCommented:
You don't really need to sleep since you specify true (third parameter) on the line, the system will wait to finish


>>zip_files.run "cmd /c cd " & dir_initial & " & pkzip -n+ -exx " & dir_initial_zip & "\" & left(fl.name,4) & ".zip " & fl.name,0,true
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

joehodgeAuthor Commented:
Hi,

I commented out both the sleep commands and it does not solve the initial problem (running them together)
but when I run the file on its own it still works so I did not need them in there.

thanks anyway
0
EDDYKTCommented:
by the way, do you see the file exist on that directory?
0
joehodgeAuthor Commented:
I've tried to do a bit of debugging but I still get an error.

I put a test.txt file in the
dir_initial     = "D:\oracle\oradata\testp1\archive"

and then put a list.txt in the
dir_initial_zip = "D:\oracle\oradata\testp1\archive\zipped"

and I get

Error: Input past end of file

If I only put list.txt in the
dir_initial_zip = "D:\oracle\oradata\testp1\archive\zipped"
I get success and it will remove list.txt
0
EDDYKTCommented:
don't know what is the program C:\DELAYER\DELAYER.EXE  is

If you said it works when click on the vbs itself then something may relate to that program
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joehodgeAuthor Commented:
It is a piece of freeware software that allows you to enter a program and then a file to run at a selected interval.

in this case I call wscript.exe and when that is running it will launch my .vbs program

Its the same as typing C:\WINDOWS\system32\wscript.exe C:\Zip_files.vbs at the command prompt.
0
joehodgeAuthor Commented:
Hi,

I think I've found the problem.

when I put everything into the same drive it almost works!

e.g.

dir_initial     = "c:\initial"
dir_initial_zip = "c:\initial\zipped"

and then from a dos prompt

C:\WINDOWS\system32\wscript.exe C:\Zip_files.vbs

it will create a zip file but will not remove the initla .txt file

why and where would I have to specify the drives in order to get this to work?
0
EDDYKTCommented:
Ok


>>zip_files.run "cmd /c cd " & dir_initial & " & pkzip -n+ -exx " & dir_initial_zip & "\" & left(fl.name,4) & ".zip " & fl.name,0,true

>>zip_files.run "cmd /c cd " & dir_initial_zip & " & pkzip " & left(fl.name,4) & " -n+ -v > list.txt 2>&1",0,true


fl.name only return the file name, you may want to use fl.path to get file name and path for your second command
0
joehodgeAuthor Commented:
Hi,

I asked a colleague and he pointed me to windows scheduler which does exactly what I wanted this delayer program to do!

thanks for all your help though
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.