View Full Version : LauchAppandWait

02-29-2008, 10:35 AM

I am having a strange problem with LaunchAppAndWait

I have a test.cmd file which is being executed by LaunchAppand Wait as follows
The test.cmd file executes a sql script test.sql
sqlcmd.exe -i test.sql -S (local)\sqlexpress

I am able to install SQL express 2005 edition with silent option but am not sure whether my script executes and creates a database.The only way to check is to open SQL management studio and verify.
I believe there is a -o option to out put to log files.

But i am also worried that LaunchAppAndWait is not consistent.
Because it works most of the times but fails somtimes.I need to execute the script silently too.Any ideas or other options or commands that i can use because this is bugging me no end and my whole app is stuck because of this..So any help ASAP shall be appreciated.

I am testing this on Windows XP service pack 2 but on some machines of ( Windows XP service pack 2) it works most of the times but fails some times i dunno why

03-03-2008, 12:00 PM
The LaunchAppAndWait function is a wrapper around the Win32 CreateProcess API. You may want to try troubleshooting what the failure is that is occurring. One of the easier ways to do this is to check the LAAW_PARAMETERS.nLaunchResult variable after LaunchAppAndWait returns. If LaunchAppAndWait does not indicate a successful launch, nLaunchResult contains the Win32 error code returned by CreateProcess that indicates why the new process could not be launched. If LaunchAppAndWait does successfully return, nLaunchResult contains the return code from the launched process (obtained through the GetExitCodeProcess API). These return codes might provide some insight into why things are failing.