March 9th, 2013 03:22 AM
#1
how to call vcvarsall.bat with Process::Start method?
I try to invoke oracle pro*c in C++/CLI project. This is my sample code.
#include "stdafx.h"
using namespace System;
using namespace System::IO;
using namespace System: iagnostics;
void call_Process (ProcessStartInfo^ info) {
try {
Process^ exeP = Process::Start(info);
StreamReader^ reader = exeP->StandardOutput;
String^ result = reader->ReadToEnd();
Console::Write(result);
Console::ReadLine();
}
catch(Exception^ e) {
Console::WriteLine(e->Message);
Console::ReadLine();
}
}
int main(array<System::String ^> ^args)
{
ProcessStartInfo^ pStartInfo = gcnew ProcessStartInfo();
pStartInfo->UseShellExecute = false;
pStartInfo->RedirectStandardOutput = true;
pStartInfo->WindowStyle = ProcessWindowStyle::Hidden;
pStartInfo->FileName = "\"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat\"";
pStartInfo->Arguments = "x64";
call_Process(pStartInfo);
pStartInfo->FileName = "proc.exe";
pStartInfo->Arguments = "oracle_connect.pc";
call_Process(pStartInfo);
pStartInfo->FileName = "\"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bin\\amd64\\cl.exe\"";
String^ arg1 = " /I C:\\app\\Administrator\\product\\11.2.0\\dbhome_1\\precomp\\public";
String^ arg2 = " /link C:\\app\\Administrator\\product\\11.2.0\\dbhome_1\\precomp\\LIB\\ORASQL11.LIB";
pStartInfo->Arguments = arg1 + " oracle_connect.c" + arg2;
call_Process(pStartInfo); // throws exception.
pStartInfo->FileName = "oracle_connect.exe";
call_Process(pStartInfo);
return 0;
}
When I type in ,call vcvarsall.bat in command prompt window myself and run this codes, it works. No exception.
But when I run this code in another command prompt window without calling vcvarsall.bat, it throws exception.
Calling vcvarsall.bat with Process::Start method doesn't work!
Pls, advise me how to call vcvarsall.bat with Process::Start method. Thanks in advance.
Best Regards!
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks