Friday, March 9, 2012

MSDE installer problem

Hi
I'm working in visual C++ and through it I start MSDE setup.exe. I have to
wait in my VC++ code before the MSDE installer is finished totally. The
problem i'm having is that as soon as I initiate the process of MSDE
setup.exe, i get its finished status in my VC waiting code, though the
installer is still running. I've tried running the MSDE setup.exe from the
command line and i see that the status also come back to prompt just a
second after the setup.exe is run. I was wondering how can i keep the
control from coming back to the setup.exe instantiating application unless
the whole setup.exe is complete. Hope i've made my point clear.
Regards
Usman Jamil
Hi Usman,
Try this code: here WaitForSingleObject( ) waits till your process gets completed. I used the same for installing MSDE through my setup launcher.
Cheers
Piyush
int ExecCmd(char * pszCmd )
{
BOOL bReturnVal = false ;
STARTUPINFO si ;
DWORD dwExitCode ;
SECURITY_ATTRIBUTES saProcess, saThread ;
PROCESS_INFORMATION process_info ;
ZeroMemory(&si, sizeof(si)) ;
si.cb = sizeof(si) ;
saProcess.nLength = sizeof(saProcess) ;
saProcess.lpSecurityDescriptor = NULL ;
saProcess.bInheritHandle = TRUE ;
saThread.nLength = sizeof(saThread) ;
saThread.lpSecurityDescriptor = NULL ;
saThread.bInheritHandle = FALSE ;
bReturnVal = CreateProcess(NULL, (LPTSTR)pszCmd, &saProcess, &saThread, FALSE,
DETACHED_PROCESS,
NULL,
NULL,
&si,
&process_info) ;
if (bReturnVal)
{
CloseHandle( process_info.hThread ) ;
WaitForSingleObject( process_info.hProcess, INFINITE ) ;
GetExitCodeProcess( process_info.hProcess, &dwExitCode ) ;
CloseHandle( process_info.hProcess ) ;
}
return dwExitCode;
}
"Usman Jamil" <usman@.advcomm.net> wrote in message news:O11ArM2WEHA.2716@.tk2msftngp13.phx.gbl...
> Hi
> I'm working in visual C++ and through it I start MSDE setup.exe. I have to
> wait in my VC++ code before the MSDE installer is finished totally. The
> problem i'm having is that as soon as I initiate the process of MSDE
> setup.exe, i get its finished status in my VC waiting code, though the
> installer is still running. I've tried running the MSDE setup.exe from the
> command line and i see that the status also come back to prompt just a
> second after the setup.exe is run. I was wondering how can i keep the
> control from coming back to the setup.exe instantiating application unless
> the whole setup.exe is complete. Hope i've made my point clear.
> Regards
> Usman Jamil
>
|||Hi viki
I dont know how it worked in your case but its not supposed to work and i've
checked it too. It wont work coz the Waitforsingleobject would also return
as soon as the process created is finished. and when we run the process
setup.exe, this setup.exe script asks the windows installer service to run
the actull installer and it exits itself thus breaking the
waitforsingleobject lock too. So it would not work for MSDE installer from
C++ code. Anyway thanx for your help.
Still waiting for a solution..
Regards
Usman Jamil
"viki" <piyush__jain@.hotmail.com> wrote in message
news:eZ5ZQ3MXEHA.1144@.TK2MSFTNGP10.phx.gbl...
Hi Usman,
Try this code: here WaitForSingleObject( ) waits till your process gets
completed. I used the same for installing MSDE through my setup launcher.
Cheers
Piyush
int ExecCmd(char * pszCmd )
{
BOOL bReturnVal = false ;
STARTUPINFO si ;
DWORD dwExitCode ;
SECURITY_ATTRIBUTES saProcess, saThread ;
PROCESS_INFORMATION process_info ;
ZeroMemory(&si, sizeof(si)) ;
si.cb = sizeof(si) ;
saProcess.nLength = sizeof(saProcess) ;
saProcess.lpSecurityDescriptor = NULL ;
saProcess.bInheritHandle = TRUE ;
saThread.nLength = sizeof(saThread) ;
saThread.lpSecurityDescriptor = NULL ;
saThread.bInheritHandle = FALSE ;
bReturnVal = CreateProcess(NULL, (LPTSTR)pszCmd, &saProcess, &saThread,
FALSE,
DETACHED_PROCESS,
NULL,
NULL,
&si,
&process_info) ;
if (bReturnVal)
{
CloseHandle( process_info.hThread ) ;
WaitForSingleObject( process_info.hProcess, INFINITE ) ;
GetExitCodeProcess( process_info.hProcess, &dwExitCode ) ;
CloseHandle( process_info.hProcess ) ;
}
return dwExitCode;
}
"Usman Jamil" <usman@.advcomm.net> wrote in message
news:O11ArM2WEHA.2716@.tk2msftngp13.phx.gbl...
> Hi
> I'm working in visual C++ and through it I start MSDE setup.exe. I have to
> wait in my VC++ code before the MSDE installer is finished totally. The
> problem i'm having is that as soon as I initiate the process of MSDE
> setup.exe, i get its finished status in my VC waiting code, though the
> installer is still running. I've tried running the MSDE setup.exe from the
> command line and i see that the status also come back to prompt just a
> second after the setup.exe is run. I was wondering how can i keep the
> control from coming back to the setup.exe instantiating application unless
> the whole setup.exe is complete. Hope i've made my point clear.
> Regards
> Usman Jamil
>
|||Hi viki
I dont know how it worked in your case but its not supposed to work and i've
checked it too. It wont work coz the Waitforsingleobject would also return
as soon as the process created is finished. and when we run the process
setup.exe, this setup.exe script asks the windows installer service to run
the actull installer and it exits itself thus breaking the
waitforsingleobject lock too. So it would not work for MSDE installer from
C++ code. Anyway thanx for your help.
Still waiting for a solution..
Regards
Usman Jamil
"viki" <piyush__jain@.hotmail.com> wrote in message
news:eZ5ZQ3MXEHA.1144@.TK2MSFTNGP10.phx.gbl...
Hi Usman,
Try this code: here WaitForSingleObject( ) waits till your process gets
completed. I used the same for installing MSDE through my setup launcher.
Cheers
Piyush
int ExecCmd(char * pszCmd )
{
BOOL bReturnVal = false ;
STARTUPINFO si ;
DWORD dwExitCode ;
SECURITY_ATTRIBUTES saProcess, saThread ;
PROCESS_INFORMATION process_info ;
ZeroMemory(&si, sizeof(si)) ;
si.cb = sizeof(si) ;
saProcess.nLength = sizeof(saProcess) ;
saProcess.lpSecurityDescriptor = NULL ;
saProcess.bInheritHandle = TRUE ;
saThread.nLength = sizeof(saThread) ;
saThread.lpSecurityDescriptor = NULL ;
saThread.bInheritHandle = FALSE ;
bReturnVal = CreateProcess(NULL, (LPTSTR)pszCmd, &saProcess, &saThread,
FALSE,
DETACHED_PROCESS,
NULL,
NULL,
&si,
&process_info) ;
if (bReturnVal)
{
CloseHandle( process_info.hThread ) ;
WaitForSingleObject( process_info.hProcess, INFINITE ) ;
GetExitCodeProcess( process_info.hProcess, &dwExitCode ) ;
CloseHandle( process_info.hProcess ) ;
}
return dwExitCode;
}
"Usman Jamil" <usman@.advcomm.net> wrote in message
news:O11ArM2WEHA.2716@.tk2msftngp13.phx.gbl...
> Hi
> I'm working in visual C++ and through it I start MSDE setup.exe. I have to
> wait in my VC++ code before the MSDE installer is finished totally. The
> problem i'm having is that as soon as I initiate the process of MSDE
> setup.exe, i get its finished status in my VC waiting code, though the
> installer is still running. I've tried running the MSDE setup.exe from the
> command line and i see that the status also come back to prompt just a
> second after the setup.exe is run. I was wondering how can i keep the
> control from coming back to the setup.exe instantiating application unless
> the whole setup.exe is complete. Hope i've made my point clear.
> Regards
> Usman Jamil
>

No comments:

Post a Comment