I wrote a little java program that I want to execute when windows starts. I wrote a batch file to run when the OS starts, but I realized it won't work because windows 7 stops any batch file from running when the operating systems starts.
To get around this, I wanted to write a c program, compile it with cygwin (so that its .exe), and have this run when the operating system starts. I want it to execv the command:
java -jar ipsetup.jar
I couldn't get it to work, so I tried to just have the c program execv the "ls" command. Here is the code:
int main(int argc, char ** argv){
//argv[0] = "java";
//argv[1] = "-jar";
//argv[2] = "c:/windows/ipstartup.jar";
execv("/bin/ls", "/bin/ls");
printf("%s",strerror(errno));
return 1;
}
I keep getting the error "Bad Address" or "File or Directory does not exist." Anyone know why?
Thanks
**Edit
So I can get the program to run correctly within cygwin (it executes my java file). But when I run it in windows, it outputs only the print statement. Originally, it said cygwin1.dll was missing, so I put it in the Windows directory. Here's my source code:
#include <errno.h>
#include <stdio.h>
int main(int argc, char ** argv){
//argv[0] = "java";
//argv[1] = "-jar";
//argv[2] = "c:/windows/ipstartup.jar";
system("java -jar c:/windows/ipstartup.jar");
printf("I am here");
return 1;
}