Environnement variable with CreateProcess
-
Hi !!! My app, in VB6, is creating a thread to launch a batch file and waiting on this thread to be finished. Here is the code :
Dim l_lRet As Long Dim l_lCreationFlags As Long Dim l_recStartupInfo As STARTUPINFO Dim l_recProcInfo As PROCESS_INFORMATION Dim l_recProcAttr As SECURITY_ATTRIBUTES Dim l_recThreadAttr As SECURITY_ATTRIBUTES l_recProcAttr.nLength = Len(l_recProcAttr) l_recThreadAttr.nLength = Len(l_recThreadAttr) l_recStartupInfo.cb = Len(l_recStartupInfo) l_recStartupInfo.dwFlags = STARTF_USESHOWWINDOW l_recStartupInfo.wShowWindow = SW_NORMAL l_lCreationFlags = HIGH_PRIORITY_CLASS If CreateProcess(vbNullString, "C:\MyBatch.bat", l_recProcAttr, l_recThreadAttr, False, l_lCreationFlags, 0&, "C:\", l_recStartupInfo, l_recProcInfo) Then 'Wait WaitForSingleObject l_recProcInfo.hProcess, INFINITE l_lRet = CloseHandle(l_recProcInfo.hProcess) End If
My problem is that in the batch file, I lose all environnement variables (Path, SystemRoot), and I have no idea why, because in MSDN, it says that the new process should use the environnement variables from the creator of the process. Anyone could help me on this point ? Thank you ! Jerome