One obvious problem is that you have UseShellExecute false set. This means that you execute the notepad directly without going through the cmd.exe command shell. Therefore, environment variables do not expand.
I'm not sure what you are trying to achieve (why do you need to add an environment variable?), But the following will work:
System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents = false; proc.StartInfo.EnvironmentVariables.Add("file", "c:\\text.txt"); proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = "cmd.exe"; proc.StartInfo.Arguments = "/c notepad %file%"; proc.Start(); proc.WaitForExit();
source share