title: Create and Modify System Path Variable
body: <p>I am creating a C++ Application using Boost Library, so for I have developed modules but stuck here.</p>
  
  <p>I want to Create and modify System Variables(Or Local Environment Variables that persist even after process has terminated) using boost library.
  There are methods like </p>
  
  <blockquote>
    <p>setenv() 
    putenv()
    getenv()</p>
  </blockquote>
  
  <p>but they make local changes and the value gets disappeared after the process has terminated.</p>
  
  <p>Well that's not the real issue. The real problem arises when i want the same code to run on linux and mac platform.</p>
  
  <ol>
  <li>Can I make a cross platform code using C++ with Libraries that can create and modify and delete the path variables ?
  If not</li>
  <li>Can I make a code for specific platform say Windows with the above requirements.</li>
  </ol>
  
  <p>As of now I have this code that sets Environment Variable for windows but it give error</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt; 
  #include &lt;boost/asio.hpp&gt;
  #include &lt;boost/iostreams/device/file_descriptor.hpp&gt;
  #include &lt;boost/iostreams/stream.hpp&gt;
  #include &lt;process/boost/process.hpp&gt;
  #include &lt;boost/filesystem/path.hpp&gt;
  #include &lt;boost/system/error_code.hpp&gt;
  
  
  namespace bp = boost::process;
  namespace bpi = boost::process::initializers;
  namespace bio = boost::iostreams;
  
  int main()
  {
   char* str="SETX Name Value";
   bp::pipe p = bp::create_pipe();
   {
      bio::file_descriptor_sink sink(p.sink, bio::close_handle);
      boost::filesystem::path p("C:/Windows/System32/cmd.exe");
      boost::system::error_code ec;
      bp::windows::execute(bpi::run_exe(p),
              bpi::set_cmd_line(str),
              bpi::bind_stdout(sink),
              bpi::set_on_error(ec)
              );
   }
  
   bio::file_descriptor_source source(p.source, bio::close_handle);
   bio::stream&lt;bio::file_descriptor_source&gt; is(source);
  
   std::string s;
   is &gt;&gt; s;
   std::cout &lt;&lt; s &lt;&lt; std::endl;
   std::cin.get();
   return 0;
  }
  </code></pre>