Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 931
  • Last Modified:

How to execute a batch file for application

Hello, Experts*
  my application is MFC-dialog base program. my program need to have a function like this : when users click a button, a batch file will be executed, and to batch program needs some argument, I don't know how to implement this because I tried "system" and "winexec", and they didn't work.
  can somebody kindly give me some hints, and example will be very appreciated.
  Thanks you very much!

--pigangel
0
pigangel
Asked:
pigangel
1 Solution
 
migelCommented:
Hi!
you can use CreateProcess and pass to it string like this:
"cmd /c mybat.bat param1 param2 param3"
<< for windows NT for 95+ you must write:
"command.com /c mybat.bat...."
0
 
tdubroffCommented:
Use ShellExecute().

For Instance:
ShellExecute(hWnd, "open", "MyExe.exe", "my params are here", "", SW_SHOW);
0
 
pigangelAuthor Commented:
Thank you very much! It works.

-- pigangel
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now