Solved

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

Posted on 2013-01-06
10
270 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
  • 5
  • 4
10 Comments
 
LVL 17

Expert Comment

by:Kent Dyer
Comment Utility
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
Comment Utility
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
Comment Utility
No difference with additional Waits
0
 
LVL 65

Expert Comment

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

Author Comment

by:Mike Caldwell
Comment Utility
Yes; tested with an "if not exist" before this.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The viewer will learn how to count occurrences of each item in an array.
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now