Passing Values back to VBScript from a VB Executable

Posted on 2005-05-13
Last Modified: 2011-10-03
I need to run a vbscript that will launch an executable VB Program.  I have to use a vbscript to launch the executable (that I wrote) so I can have it return however I want.  This program needs to pass a set of 30 values back to the vbscript, preferably in an array but I can use a long string and split it.

How can I use vbscript to read the value stored in the ExitProcess() function and will it hold all my information?  Can I share a property bag from the EXE program back to the vbscript?  Is there a better way?  I'd like to avoid writing out to a text file or registry if possible.

Question by:skimmel
    LVL 1

    Expert Comment

    Could you close the vbscript app when you launch the vb program, then from the vb program run the vbscript app with your 30 variables as command line parameters?  You could also send a piece of info to tell the script app where to go to use the command line parameters.

    Author Comment

    No.  The VBScript is launched from a different application that I don't control.  It will pass a piece of information to the Executable via a command line switch.  Once I get the data back from the Executable, I need to run the rest of the code in VBScript (the only thing the controlling application can understand).  Thus the process goes:

    Contolling Application Launches vbscript
         VBScript gets information from the Controlling App
         VBScript launches the Executable passing the information in the command line (currently wshell, but I'm open to change)
         VBScript stays open
              Executable runs code and determines data to pass back
              Executable Closes
         VBScript reads data from executable and performs more API actions with Controlling App
         VBScript Closes
    Controlling App returns to other processing

    I hope that makes sense.
    LVL 32

    Accepted Solution

    As far as i know, the exit code is only a long value..
    Private Declare Sub ExitProcess Lib "kernel32"  (ByVal uExitCode As Long)          'MSDN

    so perhaps the only way to pass variables back is a text or binary file :-<    (though it works perfectly well for me)
    binary is good for writing an array or userdefined type.  ie keep all the data to be swapped between apps in a Type.
    makes it easy to write data file & to keep definitions in sync. (though VBS doesnt support it, u can at least paste the type def in as a comment)

    if you expected to have multiple processes running, you could use exitcode as a filename...

       uExitCode=timer        'secs since midnight
      outputfile="VBApp" & format("0000000000",uExitcode)


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    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…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    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…

    734 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

    25 Experts available now in Live!

    Get 1:1 Help Now