locked
C# code to launch an application which contains an Environment Variable RRS feed

  • Question

  • I have an Environment Variable

    Variable Name : MY_ENV

    Variable value : C:\Windows

    I am able to launch notepad from Run command using the command "%MY_ENV%\notepad.exe"

    But unable to launch using the C# code 

    Process.Start(@"%MY_ENV%\notepad.exe");

    Thanks in advance!

    Wednesday, February 6, 2019 10:30 AM

Answers

  • Try this too:

       Process.Start(Environment.ExpandEnvironmentVariables(@"%MY_ENV%\notepad.exe"));

    • Marked as answer by Joy123456 Wednesday, February 6, 2019 12:14 PM
    Wednesday, February 6, 2019 12:06 PM

All replies

  • Wednesday, February 6, 2019 10:38 AM
  • That will work.But my question is without spiting this string "%MY_ENV%\notepad.exe" is there any way to launch application?
    Wednesday, February 6, 2019 12:02 PM
  • Try this too:

       Process.Start(Environment.ExpandEnvironmentVariables(@"%MY_ENV%\notepad.exe"));

    • Marked as answer by Joy123456 Wednesday, February 6, 2019 12:14 PM
    Wednesday, February 6, 2019 12:06 PM
  • Thank you. It got worked as I expected :)
    Wednesday, February 6, 2019 12:15 PM