468,242 Members | 1,626 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

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
Aug 16 '07 #1
6 1455
sicarie
4,677 Expert Mod 4TB
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.
Aug 16 '07 #2
Hi,

Thanks for the reply, here's the code segment.
Expand|Select|Wrap|Line Numbers
  1. System::IntPtr temp = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi("C:\\Documents and Settings\\jsheffield\\My Documents\\Visual Studio 2005\\Projects\\timesheet_\\timesheet_\\Merge.exe " + usern);
  2. char* action = (char*)(void*)temp;
  3. system(action);
  4. System::Runtime::InteropServices::Marshal::FreeHGlobal(temp);
  5.  
Thanks.

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

Larry
Aug 16 '07 #3
sicarie
4,677 Expert Mod 4TB
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.
Aug 16 '07 #4
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.
Aug 16 '07 #5
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::Diagnostics::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
Aug 16 '07 #6
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::Diagnostics::Process::Start(String^,String ^) function. Thank you so much for your help.

Larry
Aug 16 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Fabio Pliger | last post: by
6 posts views Thread by Pierre-Yves | last post: by
10 posts views Thread by Amit Nath | last post: by
12 posts views Thread by tshad | last post: by
6 posts views Thread by dspfun | last post: by
2 posts views Thread by upperclass | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.