1

I'm having a difficult time getting Process.start to acknowledge that Java exists, even when I use an absolute path.

Process.Start(@"c:\windows\system32\java.exe");

produces

Unhandled Exception: System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(String fileName) at Transpiler.Program.Main(String[] args) in C:\GIT\MainLine\transpiler2\Program.cs:line 80

Even though java.exe does exist at that location.

Adam Rackis
  • 82,527
  • 56
  • 270
  • 393
  • I saw other comments indicating that that's a normal place for java to be installed to. Nonetheless, `java` alone doesn't work either, even though it's in my path and has been for years. – Adam Rackis Jan 06 '17 at 03:37
  • Moreover typing `c:\windows\system32\java.exe` in a separate `cmd` window causes java to run fine :\ – Adam Rackis Jan 06 '17 at 03:38
  • Weird, does process monitor shed any extra info? Also try without the filepath ie `Process.Start("java.exe");` as the System32 folder is the default path. – Jeremy Thompson Jan 06 '17 at 03:42
  • @Rob - just ran the compiled exe as administrator, no change :( – Adam Rackis Jan 06 '17 at 03:43
  • @Jeremy - none that I can see – Adam Rackis Jan 06 '17 at 03:44
  • 2
    If its a x64 system then you need to use "Sysnative" instead of "System32" http://stackoverflow.com/questions/38678576/process-start-in-c-sharp-the-system-cannot-find-the-file-specified-error – Jeremy Thompson Jan 06 '17 at 03:47
  • Pretty sure it's a permissions issue. I can reproduce it by copying in a blank file named `java.exe`. File is not present in `Directory.GetFiles()` either (however other files are). – Rob Jan 06 '17 at 03:47
  • @Jeremy - where's Sysnative? Not sure I understand your comment – Adam Rackis Jan 06 '17 at 03:49
  • @Jeremy - my goodness. That's ... infuriating. Post as answer and I'll upvote & accept. – Adam Rackis Jan 06 '17 at 03:54
  • @jeremy - other fix seems to be just switching to x64 in configuration manager :-| – Adam Rackis Jan 06 '17 at 03:57

0 Answers0