title: Read environment variable in Kotlin/Native
body: <p>OK, so I want to create a native app to read some environment variables, and based on some business logic, change the value of them to something else. I decided to do it in Kotlin.</p>
  
  <p>I managed to find out how to change the system environment variable, by creating the functions:</p>
  
  <pre><code>fun call(arg: String) = platform.posix.system(command)
  
  fun setEnvironmentVariable(variable: String, value: String) {
      println("Changing value of $variable to $value")
      call("SETX $variable $value")
  }
  </code></pre>
  
  <p>But it only changes the value. I would like to store it in a Kotlin variable and do some manipulations on it.</p>
  
  <p>Issuing the statement call("SET $variable") prints the value to the command prompt, but I cant figure out how to capture it from Kotlin. I guess if there was a way to extract the output from command prompt to a String that would make it easier, even though Windows outputs it on the form myvariable=myvalue instead of just the value.</p>
  
  <p>Thanks in advance</p>