
launching a batch file from VB6 app
Hi, all
I'm trying to launch a batch file from my VB6 application. This batch
file in turn calls .exe file and sends two parameters
(MyExecFileName.exe "abc" "123" that's the line in the batch file).
When manually ran the batch file works .
I tried two different approaches:
1. to launch batch file using CreateProcess
'****************************************************
strCmdLine = "C:\MyBatchFileName.bat"
strArguments = " " & """abc""" & " " & """123"""
udtStartupInfo.dwFlags = STARTF_USESHOWWINDOW
udtStartupInfo.wShowWindow = SW_SHOWHIDE
udtStartupInfo.cb = Len(udtStartupInfo)
lngResult = CreateProcess(strCmdLine, strArguments, _
0&, 0&, 1&, NORMAL_PRIORITY_CLASS, ByVal 0&, vbNullString, _
udtStartupInfo, udtProcInfo)
lngResult = WaitForSingleObject(udtProcInfo.hProcess, INFINITE)
lngResult = CloseHandle(udtProcInfo.hThread)
lngResult = CloseHandle(udtProcInfo.hProcess)
'*******************************************************************
CreateProcess returns 1 but I don't get the end result.
2. to launch .exe file itself using the same CreateProcess
'************************************************************
strCmdLine = "C:\MyExecFileName.exe"
strArguments = " " & """abc""" & " " & """123"""
udtStartupInfo.dwFlags = STARTF_USESHOWWINDOW
udtStartupInfo.wShowWindow = SW_SHOWHIDE
udtStartupInfo.cb = Len(udtStartupInfo)
lngResult = CreateProcess(strCmdLine, strArguments, _
0&, 0&, 1&, NORMAL_PRIORITY_CLASS, ByVal 0&, vbNullString, _
udtStartupInfo, udtProcInfo)
lngResult = WaitForSingleObject(udtProcInfo.hProcess, INFINITE)
lngResult = CloseHandle(udtProcInfo.hThread)
lngResult = CloseHandle(udtProcInfo.hProcess)
'************************************************************
I'll get the same result successful returned value and no end result.
Any help would be greatly appreciated.
Alena