How do I start running a batch fil开发者_运维知识库e (.bat) from my C program? I used
system("start /B omanam.bat");
but it's not working. How can I make .bat to open through C?
Drop the start. It's a cmd.exe thing. Just run system("omanam.bat");.
If your C executable program and batch file are in same directory then
system("batchfilename.bat arg1 arg2");
where arg1 and arg2 are the arguments for this batch file.
If the batch file is in another directory
 system("f:\\bin\\batchfilename.bat arg1 arg2");
where arg1 and arg2 are the arguments for this batch file.
C code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
  printf("Calling batch file doit.bat\n");
  system("doit Hello. theansweris: 42");
  printf("Press \'Enter\' to exit the program\n");
  getchar();
  return 0;
}
Batch file code:
@rem This is the batch file doit.bat
@echo.
@echo.
@echo.
@echo In doit.bat:
@echo.
@echo.
@echo.
@echo argument #1 is ^"%1^"
@echo argument #2 is ^"%2^"
@echo argument #3 is ^"%3^"
@echo.
@echo.
@echo Tttttthat's all, folks!
@echo.
@echo.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论