Execute Commands Using Relative Path

I wrote a program that does a lot of script like things using system calls. I have found that some windows commands, when passed as string arguments to the system, will interpret a path name as relative, and others need absolute path names; for example I can use CD and robocopy with relative paths, but I can't use del with relative path names. I am getting around this by using the command "cd [relative path] & del [somefile]". Is there a better way to do this?
Yes, don't get things done by running system commands. Not only is it slow, it's insecure and not portable.
does a lot of script like things

Well, why don't you use a script? Batch (or Windows PowerShell, if your version of Windows has it) is perfectly acceptable, and it makes more sense to use one of them, especially considering your program was going to be non-portable anyway.
The program does a lot of things that are somewhat logically complex for a batch file. I am sure its possible in a batch file, but I haven't written any batch and I wrote what I wrote instead. Is the simple answer that it can't be done?
The simple answer is that you're doing things the hard way. It can be done, but it'll be ugly.
It is just in C++ we don't use system calls, for example:
- deleting a file DeleteFile()
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363915(v=vs.85).aspx

- change current directory SetCurrentDirectory()
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365530(v=vs.85).aspx

- copy or move a file or multiple files at once SHFileOperation()
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762164(v=vs.85).aspx
Topic archived. No new replies allowed.