Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make wscript.shell call 1

Status
Not open for further replies.

valdosta

MIS
Dec 18, 2002
50
US
Hi,

I got the error "Run-Time error '-2147024894 (80070002)': Method '~' of object '~' failed" when I run the following program: (MyProgram.exe is a VB executable)

Dim objWsh As Object

Set objWsh = CreateObject("wscript.shell")
objWsh.Run ("C:\MyProgram.exe")
Set objWsh = Nothing

Thanks in advance!
 
Are you referencing the necessary library for the WScript object?

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
I tried a few like WSHControllerLibrary, MS Shell Controls And Automation but it didn't work. Which library should I add? Thanks a lot!

 
Try IWSHRUNTIMELIBRARY.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
I am using VB6. I cannot find "IWSHRUNTIMELIBRARY" in the references list. What's its full name? Thanks again!
 
Try:
wshom.ocx


[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
wshom.ocx is properly registered. One time we had one not registered, we got the error message: "Component 'DBLIST32.OCX' or one of its dependencies not correctly registered: a file is missing or invalid". Thanks!
 
The correct reference is "Microsoft Script Control 1.0
 
Still not work. The order of the references are:

Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft Access 9.0 Object Library
Microsoft Script Control 1.0

Thanks for your help!
 
Are you getting this error while running from the IDE? The .exe on the development PC? Are you getting it from the client PC? If, as I suspect, it's the latter you need to ensure that the client has the run-time files installed or you run your own install on it. Client may also need to have scripting installed and enabled? I copied your code to a new project and added only the "Microsoft Script Control 1.0" to the default references and changed the file to be executed to calc.exe and it worked fine.
 
Firstly, you don't need to reference it if you are using CreateObject...and try changing Run to Exec.
 
Oops! strongm's right I didn't even think about not needing the reference if you use CreateObject. However, I can get it to run with either .Run or .Exec. What is the difference between the two as it applies to the WSH?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top