Solved

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

Posted on 2013-01-06
10
274 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
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

803 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