I have batch script, to create backup of some 30 locations on work network, and it works.
Now I am programming the same app, but in MFC VC++, so im using little trick to set parameters for xcopy in string, then execute it with ShellExecute
.
m_destination
is variable from editbox, as destination input, where files are going.
Code is:
if (m_line1.GetCheck() == BST_CHECKED)
{
temp_dest = _T("/min /c xcopy \"\\\\pc_name.sub_domain.domain.local\\c$\\Users\\Test\\Desktop\\Test\\*.*\" \"") + m_destination + _T("\" /Y /E /Q");
ShellExecute(
GetSafeHwnd(),
L"open", // open edit print
L"C:\\Windows\\System32\\cmd.exe", // FILE PATH,
temp_dest, // PARAMETERS
NULL, // WORKING DIR
SW_HIDE); // WINDOW SHOW HIDE
m_status = "Line 1 - OK\r\n";
}
This code above works, but there are some cases, when target PC is shutdown, and in cmd window, it says "path has changed or destination unreachable" (something like that). In that case, %errorlevel% has some value, and some other if copying successfully done. Then u have condition to trigger different warnings to user. The thing is, I dont have clue how to catch it to indicate unsuccessful copying.
I need some kind of warning that copying from that PC is not done. How can I retrieve error code after copying in this way?
Or if there is simple function to replace copyx with (*.*) (all contents) copying, with ability to be directed to specific directory, I would like to hear about it.
Thanks in advance.