system("notepad") return value


int ret = system("notepad");

this code for me is returning -1, which is the error code. Under normal conditions, it is supposed to open a notepad, and return 0.

It is run on a Win7 enterprise system, I have the admin previledge; If I manually type notepad in command line, it opens a notepad; I also tried system("dir") etc, still returns -1; I have run this code on another machine with similar configurations, it returns 0.

Please please help, many thanks!
Last edited on
Open a new command line window, type "path > path.txt" then press ENTER, then type "path.txt" and copy paste the contents on your next post. I have a feeling this has to do with your environment variables.

Is there a reason you aren't using "CreateProcess()": http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx ? This would be prefered to using "system()" but you may still run into this issue if your Environment Variables are set funny.
Topic archived. No new replies allowed.