• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2977
  • Last Modified:

Needed References for WScript

Hello,

Which reference I need to use in VB6 for this code

Dim WshShell  As Object
Set WshShell = WScript.CreateObject("WScript.Shell")

'WScript object used to echo information
WScript.Echo "Hello World!" 'VBScript
WScript.Echo ("Hello World!") 'JScript

'WScript object used to terminate scripts
WScript.Quit


I am getting run-time error 424 object required.

thanks in advance,
ddb
0
DDB
Asked:
DDB
  • 6
  • 4
  • 3
  • +1
1 Solution
 
wraith821Commented:
Windows Script Host Object Model
0
 
JesterTooCommented:
"Windows Script Host Object Model"

HTH,
Lynn
0
 
BurbbleCommented:
I thought the same as the previous suggestions, but I continue getting the error after selecting it as a reference -- Microsoft Scripting Runtime does not work either.

Is the code incorrect?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
JesterTooCommented:
wscript.echo doesn't work in Visual Basic... it is for VBScript only... use MsgBox instead
0
 
JesterTooCommented:
>>>  it is for VBScript only. <<<  I should have said for script only (it works for Javascript, also).  Additionally, wscript.quit isn't for Visual Basic either... your app will terminate naturally after it executes the last line of your "Sub Main()", or you unload the main form.

-- Lynn
0
 
DDBAuthor Commented:
Sorry I brought some confusion.  Let say in VB6 the folloing code give 424  errorr:

Dim WshShell  As Object
Set WshShell = WScript.CreateObject("WScript.Shell")

 
0
 
DDBAuthor Commented:
Also,

Could you please give me not only the name but file name with extention so I could look uit up on my pC.

Thanks, ddb
0
 
JesterTooCommented:
Given the short example you cited, here is the proper syntax for VB6 (note it's slightly different from the VBScript syntax)

     Dim WshShell As Object
     Set WshShell = CreateObject("Wscript.Shell")

Here is an example of using the object just created to execute another program...

     WshShell.Run("SomeProg.exe")

I believe there maybe more than one dll involved in Windows Scripting Host... here is a link to Microsoft's site where you can download the most recent version:   http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp

I know that one of the dll's is scrrun.dll

If you're running XP, or if you have IE 6 installed, then WSH 5.6 (the latest version) is already installed.

HTH,
Lynn
0
 
DDBAuthor Commented:

 Yesterday I updated my Scripting library just like you suggested( I have W2K). I also have references to scrrun.dll which is Microsoft scripting Runtime library and I added all possible DLLs that I have for Windows scripting in VB reference box and nothing helps, I still getting this error.
0
 
JesterTooCommented:
Coule you please list a larger section of your code relevant to this problem and all the references you have set?  I think I might be guessing too much about the actual code being used.

In the meantime, here is a test script to see if your WSH is installed properly...

''' Save this file as "TestMe.vbs"
'''
''' Then, run it like this:  cscript testme.vbs from a command prompt
'''
Source  = "C:\"
BatFile = "C:\___RunMe.BAT"
Cmnd    = "DIR /ad " & Source

  Set oFSO     = CreateObject("Scripting.FileSystemObject")
  Set oBatFile = oFSO.CreateTextFile(BatFile)
  Set oShell   = CreateObject("Wscript.Shell")

  oBatFile.WriteLine Cmnd
  oBatFile.WriteLine "pause"
  oBatFIle.Close

  oShell.run BatFile,,True


If the above script works properly, it will open another command prompt window then display all the directory names in the root folder of your "C" drive and pause waiting for you to press ENTER.

HTH,
Lynn
0
 
DDBAuthor Commented:
 I got error for your code on this line.

  Set oShell   = CreateObject("Wscript.Shell")

 Automation error. The specified procedure could not be found

The refernces that I had:

Microsoft Scripting Runtime
Microsoft VBScript Regular Expression 5.5
Microsoft Script Control 1.0
Microsoft Shell Controls and Automation
WSHControllerLibrary
Windows Script Host Object Model

thank you for your time and help!

0
 
JesterTooCommented:
If you got that error running the TestMe.vbs code then it sounds as if WSH isn't properly installed.  Try uninstalling it (see the link below for how-to instructions), then reinstall it.  Be sure to use the installation package that should be part of the official Microsoft download... there are some other sites packaging just the dll's which then must be manually registered).

   http://www.superiornet.net/security/archive/scripthosting.htm

When this is complete, retry the TestMe.vbs script again to see if it now works.

BTW, you seem to have all the VB References you need (perhaps some you don't need, too) so that part of the equation seems ok.

-- Lynn
0
 
BurbbleCommented:
Start > Run > type "regsvr32 scrrun.dll" > press Enter

Maybe? I remember fixing a similar problem by doing this.
0
 
BurbbleCommented:
lol. Guess it worked.
0

Featured Post

Independent Software Vendors: 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!

  • 6
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now