But the code you pasted is just expanding an envrionment string. It's not trying to run an app.
See MSDN entry for CreateProcess()
Also, the use of the environment variables is deprecated; see SHGetFolderPath() instead (but note that the exact function you need depends on the versions of Windows you want to support)
But i take this error:6 C:\Exam.cpp cannot convert `TCHAR**' to `CHAR*'for argument `2' to `BOOL CreateProcessA(const CHAR*, CHAR*, _SECURITY_ATTRIBUTES*, _SECURITY_ATTRIBUTES*, BOOL, DWORD, void*, const CHAR*, _STARTUPINFOA*, _PROCESS_INFORMATION*)'
Well if you copy pasted from andywestken's post it seems to me that a space got filtered out somehow. It's "Program Files" not "ProgramFiles". Then of course you need to make sure that you actually have access to that file with the account you are running this on, and that the path is correct.
Also, STOP USING BLOODSHED DEV-C++!!!! Switch to wxDev-C++: http://wxdsgn.sourceforge.net/ Trust me, you'll barely see a difference.
@helegurbann -- Cool! So what was your solution? It's always nice to end a thread with the solution!
@Computergeek01 -- the space should have appeared when %ProgramFile% was replasced by a literal path. :-(
Andy
P.S. For anyone reading this thread in the future; first bear in mind Computergeek01's comments about rights. Secondly, you should not use either a literal path or the environment path in this way. The required folder path should be obtained using either SHGetKnownFolderPath or SHGetFolderPath (which one is required is dependent on which versions of Windows you want to support: see MSDN for details)