Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process.Start() exits right away on Windows 7

Process.Start("d:/test.txt"); //simple .txt file works perfectly fine on Windows 8 onward but on Windows 7 (x64) it starts the process and immediately closes it.

I've already tried the following:

  1. Calling through ProcessStartInfo and setting CreateNoWindow=true, UseShellExecute=true and Verb="runas" (though not sure why I had to set this one).

  2. Tried attaching Exit event and it confirms that the process does start but it exits right away and I don't even see the Notepad window open for a blink of a second.

Edit: I've tried it with an image files and few other extensions and they open just perfect. Something wrong with just the .txt files (and/or probably other formats).

like image 375
jwdmsd Avatar asked May 21 '17 20:05

jwdmsd


1 Answers

I was able to solve this bug just by changing build platform from AnyCPU to specifically x64 (my target machine is x64). This is strange but it solved the problem! Thanks Simon Mourier for this tip.

like image 83
jwdmsd Avatar answered Nov 15 '22 01:11

jwdmsd