472,952 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

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 1662
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

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

Similar topics

3
by: Fabio Pliger | last post by:
Hi, is it possibile, in python, to check for an already running instance of an application? My problem is that, if my program i running and the user relaunch it, i don't want to open a new...
6
by: Pierre-Yves | last post by:
Hello, I would like to prevent my perl program to be executed several times simultaneously (if the program is already running, I would like to display a message like "another instance of this...
10
by: Amit Nath | last post by:
Hi! I am running a C program and need to pause the program and change some of the variables. Is there any function that checks if there is a character in the Standard Input Buffer, else the...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
12
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
9
by: Michael.Suarez | last post by:
Suppose I have a program that prompts you with a dialogbox to enter a password. If you get the password correct, it allows you into the program, else it kills the program. Suppose that when I...
6
by: dspfun | last post by:
I would like to analyze my running c-program. What I would like to know for example is the range of the entire address space of my running c-program (memory reserved for/by the running program),...
2
by: upperclass | last post by:
Hi, I'm trying to find a decent way to measure program running time. I know clock() is probably the standard way of doing it but clock_t overflows too quickly. The target program running time...
9
by: Jimmy | last post by:
Well, i know it may be a little non-python thing, however, I can think of no place better to post this question :) can anyone tell me, in python, how to obtain some information of a running...
12
by: Shadlan | last post by:
Hi. I need to know if a service is running on my server. Is there any PHP instruction that I can use to do this?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.