WinExec issues

Ok. I'm writing a program to change a files attributes. I have the function WinExec("attrib +s +h +a C:/0.exe", SW_HIDE); and it works like a champ. but if i try to use the directory
"C:/Documents and Settings/Silver/Desktop/0.exe"
it gives me "Parameter format is incorrect -" message in the console. Any ideas on how to stop this? I've played with it for the better part of an hour and I still have nothing. And input will be appropriated :)
I'm not sure what is wrong. Does the command work when you type it in yourself at the prompt?

You may need to use the \\ separator.
Else you may need to use the 8.3 "short" pathname: "C:\\DOCUME~1\\Silver\\Desktop\\0.exe".

Hope this helps.
the "short" idea worked like a charm :) thank you.
This is unrelated to your problem but you should use ShellExecute instead. WinExec is a legacy API only maintained for backwards compatibility.

1
2
3
4
5
// ANSI version
ShellExecuteA(NULL, "open", "C:\\DOCUME~1\\Silver\\Desktop\\0.exe", NULL, NULL, SW_NORMAL);

// Unicode version
ShellExecuteW(NULL, L"open", L"C:\\DOCUME~1\\Silver\\Desktop\\0.exe", NULL, NULL, SW_NORMAL);
Topic archived. No new replies allowed.