CreateObject and GetObject fails when launched using CreateProcess
I am having some issues under Windows Vista and Windows 7 with an application that used to work just fine under Windows XP.
The projects consists of a GUI and a command line utility. When the CLU is launched stand-alone from explorer or the command shell it works fine under all versions of Windows. However, when it is launched from the GUI using CreateProcessA, I have the following problems:
1) Under Windows Vista, when trying to use the CoGetObject api to obtain a reference to winmgmts, I get an "automation error".
2) Under Windows 7, I also get an "automation error" when trying to use CoCreateInstance to retrieve an instance of Scripting.FileSystemObject.
The actual CreateProcessA call seems to work fine, the application is launched and the pipes work fine. As previously mentioned it works perfectly under Windows XP. Seems to me this problem is security or context related.
The code below is VB6, sorry about that, but the problem has been verified with C++ using equivalent code and I am convinced the users in this part of the forum are alot more qualified to answer questions regarding windows api's. I hope you'll be able to do a mental translation of the code.
Dim PID As Long, hPipe As Long
Dim cmdLine As String
cmdLine = buildCmdLine()
pa.nLength = Len(pa)
pa.bInheritHandle = 1
pra.nLength = Len(pra)
tra.nLength = Len(tra)
CreatePipe hRead, hWrite, pa, 0
If hRead = 0 Or hWrite = 0 Then Err.Raise hErrBase
sui.cb = Len(sui)
sui.hStdOutput = hWrite
sui.hStdError = hWrite
sui.dwFlags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES
sui.wShowWindow = SW_HIDE