system command lines arent working in C++

Hid_Enigma

In Runtime
Messages
154
I am in the process of writing a program which executes multiple files and then does a backup of documents, pictures, favorites and the registry. When i run the program it does not recognize the commands. Below is the output screen with the error messages and the section of source code. Any suggestions?
Thank you in advance

output screen


Backup Version 2.00

Enter your username: user
Enter your password: pass

Press a number for the program that you want to run:
1. Disk Cleanup
2. Check Disk
3. Ad-Aware (Spyware removal tool)
4. Disk Defragmenter
5. Backup
5
### Backing up My Documents...
'backupcmd' is not recognized as an internal or external command,
operable program or batch file.
### Backing up Pictures
The filename, directory name, or volume label syntax is incorrect.
### Backing up Favorites...
The filename, directory name, or volume label syntax is incorrect.
### Backing up the Registry...
BACKUP COMPLETE
Press any key to continue . . .

and in a window the error says:
Cannot export Registry\regbackup.reg: Error opening file. There may be a disk of file system error


source code:

//This is the backup program
// declaring the batch variable


system("set backupcmd=xcopy /s /c /d /h /i /r /y");
system ("set drive=c:\\Backup");
system ("echo ### Backing up My Documents...");
system ("backupcmd %USERPROFILE%\\Documents c:\\backup\\Documents");
system ("echo ### Backing up Pictures");
system ("%backupcmd% %USERPROFILE%\\pictures %drive%\\Pictures");
system ("echo ### Backing up Favorites...");
system ("%backupcmd% %USERPROFILE%\\Favorites %drive%\\Favorites");
system ("echo ### Backing up the Registry...");
system ("if exist %drive%\\Registry\\regbackup.reg del %drive%\\Registry \\regbackup.reg");
system ("C:\\Windows\\System32\\regedt32.exe //e Registry\\regbackup.reg");
 
you can't set a variable as a command and then run it.

if I type (at the command prompt)

set test = dir
test
it'll that is has no idea what test is and can't run it.

you need to use your system commands to run programs, not variables
 
Back
Top Bottom