Allowing VB6 to use wscript

Posted on 2006-04-10
Last Modified: 2012-05-05
There are several answers on this site that use WScript.CreateObject to create a shell object for running a command from a shell.  These answers have all be accepted and I assume that they work.  However, when I try to implement them, I get a "Compile error: Sub or Function not defined" against the WScript command?  How do I access it?
Question by:dennis_j_bell
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Can you show us your code please?...

    Author Comment

    See as an example...

    Also, found this link with the same problem I have -- it seems some people can access WScript and some can't, so its obviously a reference/config problem:
    LVL 28

    Accepted Solution

    Have you tried using CreateObject without the Wscript. If your looking to run a command you could use the wscript run method:

    Private Sub Command1_Click()
    Dim wShell As Object
    Dim sCmd As String

    sCmd = "ping"

    Set wShell = CreateObject("Wscript.Shell")
    wShell.Run "%comspec% /k " & sCmd

    Set wShell = Nothing
    End Sub

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    759 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