Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. how to call vcvarsall.bat with Process::Start method?

how to call vcvarsall.bat with Process::Start method?

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++oraclevisual-studiodata-structures
4 Posts 1 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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::Diagnostics; 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 ^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!

    Joseph Hwang

    L 2 Replies Last reply
    0
    • L Lost User

      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::Diagnostics; 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 ^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!

      Joseph Hwang

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      aupres wrote:

      it throws exception

      And what exception is it that it is throwing?

      L 1 Reply Last reply
      0
      • L Lost User

        aupres wrote:

        it throws exception

        And what exception is it that it is throwing?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The source can't include stdio.h file. When vcvarsall.bat executed in command prompt window in advanced and environment set, #include stdio.h throws no exception.

        Joseph Hwang

        1 Reply Last reply
        0
        • L Lost User

          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::Diagnostics; 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 ^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!

          Joseph Hwang

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You cannot execute these processes independently in this way. vcvarsall.bat needs to be called in the same environment that the compiler will be called. You need to create a new batch file that contains all the commands that you wish to run, and execute that batch file.

          Use the best guess

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups