0

I have a strange problem. If I execute an external program with

Process.Start(Path);

Some bugs appear in the program (the interface (buttons and so on) does not refresh completely when they should).

If I start the program directly (with the exact same .exe as specified in Process.Start()), no bug comes up.

The program does not need any startup-arguments or whatever.

Any ideas? Is this a known Issue when executing programs this way?

melya
  • 578
  • 5
  • 24
  • 9
    Have you provided the correct working folder when you start the process? – Sefe Nov 29 '17 at 14:32
  • What do you mean? I execute it like this: Process.Start(@"C:\Install\dir\program.exe"); everything else is working, just updating the interface does not work like it should –  Nov 29 '17 at 14:34
  • 4
    You are aware that Process.Start is battle-tested by millions of developers? If there were a bug so obvious as that, don't you think it'd be well documented and probably fixed by now? When you're dealing with code as well used as .NET, your first inclination should be to assume that you're doing something wrong, rather than the framework being broken. – mason Nov 29 '17 at 14:35
  • 3
    @azmd108 A working directory is not (or at least not necessarily) the same as the one the exe is located in. Have a look at `ProcessStartInfo` for additional options. – Manfred Radlwimmer Nov 29 '17 at 14:35
  • Check all overloads of `Process.Start`. You can set the working directory there. – Sefe Nov 29 '17 at 14:38
  • Now I've set the WorkingDirectory, and its working now. Thanks! –  Nov 29 '17 at 14:39

1 Answers1

3

When UI elements are missing from an application, it's generally an application that's using a custom UI framework, which is deployed as DLLs alongside the executable.

If you double-click the executable, the "working directory" is set to the directory you start it from.

When you call Process.Start(string path), the working directory remains set to your application's directory (or whatever else you or the runtime set it to).

In that case the application can't find the DLLs that make up that UI framework, and the UI remains empty or otherwise corrupted.

See .NET Process.Start default directory? to provide the working directory to an application you start from your code.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272