Win32 API like CreateProcess, but works on bat/cmd/etc. (i.e. uses PATHEXT)

StackOverflow https://stackoverflow.com/questions/11822051

  •  24-06-2021
  •  | 
  •  

سؤال

If you use CreateProcess, it only works on .exe's, apparently. What's the best way to make this work with other executable file types?

The best we have so far is to prepend cmd /c to such cases. Is that really the correct approach?

هل كانت مفيدة؟

المحلول

Batch files aren't technically executable files, they are just registered to open with cmd. As you mention that you need the ability to manipulate I/O handles, your best bet is indeed to use CreateProcess with cmd /c.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top