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
Solved

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

Posted on 2013-01-06
10
275 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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