Solved

Same function runs on one machine, run time error on another

Posted on 2013-01-06
10
278 Views
Last Modified: 2013-01-06
I have two PCs set up at the same time (maybe four years ago), both with Vista-32.  Let's call them PC1 and PC2.  Both run 24/7 remotely, running a suite of VB scripts.  No problems for years.  But I took PC2 off to have it do different tasks for a while.  When done,  copied the suite of VB scripts from PC1 over to PC2 and launched.  PC2 now throws some run time errors that PC1 does not.  For example:

                  If objFile.Size > 50 then

gets an error "Object doesn't support this property or method"

Runs fine on PC1, run time error on PC2.  Might there be some difference in whatever software interprets the VBScripts?  I'm totally unfamiliar with that aspect.
0
Comment
Question by:Mike Caldwell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 38748571
I would go back a re-confirm the scripts with something like WinMerge/Araxis Merge to be sure that you have the dependencies in place.

It does also appear that you need to do some additional checking..

If fso.fileexists(objFile.Path) And objFile.Size > 50 Then

Open in new window

This way, you are assured that you have a file in place to check..

Another thing you could do is put a sleep right before this so that if you are using a function that needs to close first..

Like..
Wscript.Sleep 300
If fso.fileexists(objFile.Path) and objFile.Size > 50 Then

Open in new window


Note: The 300 is milliseconds..

HTH,

Kent
0
 
LVL 1

Author Comment

by:Mike Caldwell
ID: 38748717
I understand the somewhat more robust checking, however I don't understand the need to check the dependencies in that this identical script runs fine on PC1.

I will add in some appropriate Waits, in that one machine might be slighly slower than the other.
0
 
LVL 1

Author Comment

by:Mike Caldwell
ID: 38749231
No difference with additional Waits
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 65

Expert Comment

by:RobSampson
ID: 38749317
Does the file that objFile is bound to actually exist?  Can you output objFile.Path?
0
 
LVL 1

Author Comment

by:Mike Caldwell
ID: 38749388
Yes; tested with an "if not exist" before this.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 38749403
For the file in question, can you isolate the operation out to a single test script?  For example, can you just run a separate VBS with this:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\Temp\FileInQuestion.txt")
WScript.Echo objFile.Path
WScript.Echo objFile.Size

Open in new window


Rob.
0
 
LVL 1

Author Comment

by:Mike Caldwell
ID: 38749415
I emphasize that both machines are doing the same processes with the same scripts, operating on the same sort of files.  They process about 10K files per day each, have for four years.  I doubt there is a program issue; too many years of no-problem operation not to have encountered a script problem.  I believe there is something at the OS level, not application, that is different.  Vista processes these VB Scripts, so I'm thinking there is a difference between revs of the script processing software (shell??).  I don't know enough about that to suggest more, but I really doubt a script error per se.
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 38749438
Is the second machine Vista as well?

On the first, open a command prompt, and type
cscript /?

On the second, do the same.

The first line of the output should be something like
Microsoft (R) Windows Script Host Version 5.8

Is it the same on both machines?

In any case, re-download the version on the failing machine, and re-install it.

Regards,

Rob.
0
 
LVL 1

Author Comment

by:Mike Caldwell
ID: 38749481
Both are the same (5.7).

What exactly should I down load, where would I get it, and how would I install it?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 38749518
I think for Vista you can reregister the components by using this:
http://www.brighthub.com/computing/windows-platform/articles/126218.aspx

Rob.
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question