I am not quite sure what exactly your batch script does, but it is probably not relevant - I guess you are looking for how to dynamically pass parameters to a batch script from within a C program.
I can show you one way of doing this.
Here is a batch script - takes two arguments
file - the file to copy
folder - the folder to copy to
When copying, the file name is prepended with current time.
Code:
# Script CopyFile.txt
var str file, folder, time
set $time = gettime()
system -s copy /b $file ($folder+"/"+$time+"_"+$file)
I am assuming this script will be saved in file C:/Scripts/CopyFile.txt.
Now, here is the C code.
Code:
#include <stdio.h>
#include <system.h>
int main()
{
char command[1024] ;
// Go to directory where repport file is located.
_chdir("C:/Report/") ;
// Set time to sleep ;
int stime ;
stime = 60*60*1000 ;
while (true)
{
// Copy file "rpt.dat" to folder "E:/Copied Reports"
memset(command, 0x00, sizeof(command)) ;
sprintf(command, "C:/biterScripting/biterScripting.exe \"C:/Scripts/CopyFile.txt\" file(\"%s\") folder(\"%s\")",
"rpt.dat",
"E:/Copied Reports") ;
system(command) ;
// Sleep for an hour.
sleep(stime) ;
}
}
The script I wrote above is in biterscripting ( http://www.biterscripting.com ). I used biterscripting because it makes it easier to pass arguments - you don't get into %1 etc. But pure batch script will do also. The above C program will copy file E:/Report/rpt.dat to folder E:/Copied Reports every hour.