Solved

Lunch exe program

Posted on 2004-09-20
2
1,070 Views
Last Modified: 2013-11-20
Can anyone help me to write C++ code to lunch exe program from SAMBA server?
0
Comment
Question by:tthawee
2 Comments
 

Accepted Solution

by:
l3st4rd earned 50 total points
ID: 12107956
what u mean: "lunch exe program from SAMBA server" ? the program resides on a connected network drive?
if so you only need to call CreateProcess(...).

CString pathName;
pathName = YourProgramPath;
STARTUPINFO startup;   //structure containing information on how to start the program
PROCESS_INFORMATION procinfo;   //this will receive information on the newly created process

::ZeroMemory(&startup, sizeof(startup));  //clear startup structure

startup.cb = sizeof(startup);   //size of this structure
startup.dwFlags = STARTF_USESHOWWINDOW;    //use wShowWindow flag
startup.wShowWindow = SW_SHOW;    //show the window in normal state
pathName = "\"" + pathName + "\"";     //include the pathname into quotation marks to deal with spaces in pathnames

LPSTR cmd = ClientCmd.GetBuffer(ClientCmd.GetLength() + 1);
if (CreateProcess(NULL, //name of application already contained in lpCommandLine parameter
                         cmd,   //lpCommandLine = full / relative path of program + parameters
                         NULL,  // }
                         NULL,  // } no security attributes for thread as well as process
                     false,  //the new process should not inherit any handles from the calling process
                         0,       //we specify no creation flags
                         NULL,  //new process runs in same environment as calling process
                         NULL,  //the current drive+directory of the new process will be the same like the one of the calling process
                         &startup,  //our startup information
                         &procinfo)   //this will receive information on the new process
                         == 0) {   //return value 0 means error:
// add an error handler here if execution failed
}

have a look for CreateProcess function in MSDN for more info.

daniel.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand macro to include alternate header placement and naming 5 66
repeatEnd java challenge 42 84
Separate into files by filename 12 75
Expand data scrubbing tool 13 32
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

20 Experts available now in Live!

Get 1:1 Help Now