Triggering files using C

CA50 said:
In this case i think that 'notepad.exe' and 'mspaint.exe' must be in that directory where the c-coded exe file will reside.

Its not needed that they be in same dir. Those executables are in the System PATH. You can be in any dir and run those commands.
 
rock_ya_baby said:
Its not needed that they be in same dir. Those executables are in the System PATH. You can be in any dir and run those commands.

Its not working, can you give the code.:hap2:
thanks

kekerode said:
you tried exec() and spawn() functions for change?

how about a demo??:huh:
 
I think you have got enough leads by now but may I ask, what is it exactly that you want to achieve? I mean I get it that you want to open certain files through your program but what is the end goal?
 
@shantanugoel
I think you have got enough leads by now but may I ask, what is it exactly that you want to achieve? I mean I get it that you want to open certain files through your program but what is the end goal?
thats a good question!!
Before C i was using batch file for such works, but now i feel that batch file are not good, there codes and be read and modified so i want to achieve that through C
Lets C
 
CA50 said:
thats a good question!!
Before C i was using batch file for such works, but now i feel that batch file are not good, there codes and be read and modified so i want to achieve that through C
Lets C
If you're planning to run it on a Windows platform, have you considered using wscript? Or I suppose Powershell could pull this off quite easily too.
 
pr0ing said:
care to explain why the solution provided earlier is "not possible in C". I am open to learning new things.

or did you misinterpret the OP's question?

C does not understand your files, your driver, your mouse or any other thing.
It was specifically designed to be as portable as possible.
Adding additional work of meddling with standard C is not provided as part of standard itself.

What you people are suggesting him are system/OS specific routines which is not standard C.

It is very imp that there is a difference between C and system specific functions like exec(), execve() etc.

Cu,
 
CA50 said:
thats a good question!!
Before C i was using batch file for such works, but now i feel that batch file are not good, there codes and be read and modified so i want to achieve that through C
Lets C

I forgot one thing ... exec() should not work because if u call notepad program from DOS C parent program with exec() (or other variant) then will try to execute notepad in DOS env ... which is not going to happen

Here Windows Scripting or Powershell scripting can help u much better

Apart from this ... there are several tools available which can convert these scripts to EXE files so your code will remain hidden

blufox said:
C does not understand your files, your driver, your mouse or any other thing.
It was specifically designed to be as portable as possible.
Adding additional work of meddling with standard C is not provided as part of standard itself.

What you people are suggesting him are system/OS specific routines which is not standard C.

It is very imp that there is a difference between C and system specific functions like exec(), execve() etc.

Cu,

Yes ... C don't understand files, drivers etc ... that's why there r library which can be integrated which can do things for us

besides ... except you .c code file nothing is portable ... every executable is OS dependent

reason behind suggesting exec(), system() routines is very simple ... OS/system is going to handle execution ... not the calling C program
 
blufox said:
C does not understand your files, your driver, your mouse or any other thing.
It was specifically designed to be as portable as possible.
Adding additional work of meddling with standard C is not provided as part of standard itself.

What you people are suggesting him are system/OS specific routines which is not standard C.

It is very imp that there is a difference between C and system specific functions like exec(), execve() etc.

Cu,
You are correct, but yet incorrect. Yes, C standard (and C language) does not have any inbuilt routines to do this. But to say that this is not possible in C is blasphemy. For all that matters, first, the functions given are part of stdlib/libc with most compilers. Second, even if the functions aren't there, one can always write the code in C to achieve the functionality. So, "not possible in C" is a semi-ignorant answer, and we know that little knowledge is a dangerous thing ;)
 
routine you are again talking about are OS specific and No they do not constiture standard C.

There is a reason books are named "System Programming in C". System here gets OS specific and thus the catch.

And no I do not take offense to any of your statements but if you think I am wrong, feel free to correct me.
 
Back
Top