running VB exe from C++ program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ironmanlarry
    New Member
    • Aug 2007
    • 9

    #1

    running VB exe from C++ program

    Hey,

    I've got a C++ program that runs fine and a VB program that I made into an exe file and that runs fine by itself. It does an Excel to Word mailmerge and prints the document. However, when I try to run the VB program from the C++ program it just flashes the command prompt and does nothing. I'm using the system(char *) command to run it.
    Any help is much appreciated, thank you.

    Larry
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Can you post the exact line for us? You have the right function, as far as I can tell...

    You might try using the full path and/or backwhacking the slashes in the path to the VB script.

    Comment

    • ironmanlarry
      New Member
      • Aug 2007
      • 9

      #3
      Hi,

      Thanks for the reply, here's the code segment.
      [code=cpp]
      System::IntPtr temp = System::Runtime ::InteropServic es::Marshal::St ringToHGlobalAn si("C:\\Documen ts and Settings\\jshef field\\My Documents\\Visu al Studio 2005\\Projects\ \timesheet_\\ti mesheet_\\Merge .exe " + usern);
      char* action = (char*)(void*)t emp;
      system(action);
      System::Runtime ::InteropServic es::Marshal::Fr eeHGlobal(temp) ;
      [/code]
      Thanks.

      NOTE: Some how the post printed a space in the StringToHGlobal Ansi, where there isn't one, so that's not the problem

      Larry
      Last edited by sicarie; Aug 16 '07, 07:09 PM. Reason: Code tags are in the box to the right when you create or reply to a thread.

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Originally posted by ironmanlarry
        However, when I try to run the VB program from the C++ program it just flashes the command prompt and does nothing.
        Are you sure the VB script isn't running? Is there a prompt in the VB script, or can you give it a pause (to keep the cmd line up)? I'm thinking it might execute and return, so the window is closed.

        Comment

        • ironmanlarry
          New Member
          • Aug 2007
          • 9

          #5
          Perhaps part of it runs, but when I run it outside of the C++ program, it always comes up with a prompt saying it will perform an SQL statement (the mail merge) and then it says it is printing the document.
          When running it from the C++ program it never displays either of these, and nothing comes out of the printer.
          Thanks.

          Comment

          • ironmanlarry
            New Member
            • Aug 2007
            • 9

            #6
            Originally posted by sicarie
            Are you sure the VB script isn't running? Is there a prompt in the VB script, or can you give it a pause (to keep the cmd line up)? I'm thinking it might execute and return, so the window is closed.
            I should mention that the exe takes an argument. Someone suggested using System::Diagnos tics::Process:: Start(String^) and that worked, but I had to take out the argument. However, using system(char*) should have no problem with an argument, right, cause it's a system command?
            Thanks.

            Larry

            Comment

            • ironmanlarry
              New Member
              • Aug 2007
              • 9

              #7
              Originally posted by sicarie
              Are you sure the VB script isn't running? Is there a prompt in the VB script, or can you give it a pause (to keep the cmd line up)? I'm thinking it might execute and return, so the window is closed.
              Hey, never mind, I got it to work using the System::Diagnos tics::Process:: Start(String^,S tring^) function. Thank you so much for your help.

              Larry

              Comment

              Working...