Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 02-25-2009, 05:37 PM   #1
In Runtime
 
Join Date: Dec 2001
Posts: 154
Angry system command lines arent working in C++

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");
__________________

Hid_Enigma is offline   Reply With Quote
Old 02-25-2009, 07:37 PM   #2
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,007
Default Re: system command lines arent working in C++

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
__________________

__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 02-25-2009, 08:04 PM   #3
In Runtime
 
Join Date: Dec 2001
Posts: 154
Default Re: system command lines arent working in C++

Thanks Alot root that worked
Hid_Enigma is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 05:58 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0