I have this file.bat
:
cd "C:\Program Files(x86)\Anydesk" && anydesk.exe
If i double click on it it works fine and does what i want.
Now i try to launch this bat file inside of my C program :
system("path\\file.bat");
But it does nothing. I see a super fast cmd opening and nothing else. I am wondering maybe it is failing because it is calling another application? But i am not sure.
How to make this work?
CodePudding user response:
.bat is not an executable. It is a script which is processed by cmd.com.
So you need to execute it, with your .bat as a parameter:
system("cmd /C path\\script.bat");
The /C
key will tell your cmd, to execute the bat and exit, once the bat is finished. You can use /K
for debug purposes (execute and remain open after completion).