0

I just want the c++ exe to launch a tkinter file when clicked, but google only gives things about embedding. Exe because I could put a cool icon on it...

#include <iostream>
#include <windows.h>

int main() {
    ShellExecute(NULL, "MiniTime.pyw", "C:\Python27\python.exe", NULL, NULL, SW_SHOWDEFAULT);

    return 0;
}

only the C++ cmd opens after that

Akshat Mahajan
  • 9,543
  • 4
  • 35
  • 44
Absolute
  • 11
  • 2
  • Take a look at [`system()`](http://www.cplusplus.com/reference/cstdlib/system/) in `cstdlib`. Not sure how you'd adapt it for Windows though. – Akshat Mahajan May 01 '16 at 00:55

1 Answers1

0

Don't use ShellExecute. You are better off with CreateProcess. MSDN CreateProcess

bodangly
  • 2,473
  • 17
  • 28
  • Unless you need specific creation and startup flags, then [`ShellExecuteEx`](https://msdn.microsoft.com/en-us/library/bb762154) is fine. It executes registered operations (e.g. "open" and "edit", and "runas" to elevate) on registered filetypes. However, the OP has the arguments wrong. It should "open" the "MiniTime.pyw" script, without parameters. There's no need to explicitly run py[w].exe or python[w].exe. Also, the OP should probably use the `Ex` version with the `SEE_MASK_NOCLOSEPROCESS` flag to be able to wait on the process handle and get the exit code. – Eryk Sun May 01 '16 at 02:21