Solved

Lunch exe program

Posted on 2004-09-20
2
1,077 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 76
wordcount challenge 11 164
Thin secure Windows 10 5 117
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,712
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.

710 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