Link to home
Start Free TrialLog in
Avatar of maxwsp
maxwspFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Batch Script runs with errors PrintBRM

Hello,

I am currently running this scheduled Batch file command to backup Printer Confgiuration :

del c:\temp\printersbackupconfig\*.* /S/Q

%windir%\System32\Spool\Tools\PrintBRM -s \\printserver1 -b -f c:\temp\printersbackupconfig\printserver1.printerExport  -O FORCE

The script runs with no issues as a scedule task every week but what I was hoping to do is alter the script so it does not delete the folder items (time consuming many print server configs) and can backup the latest printer settings sucesssfully.

If I do not use del c:\temp\printersbackupconfig\*.* /S/Q then the script comes up with error messages in msdos:

Operation mode: backup
Target server: \\printserver1
Target file path: c:\temp\printersbackupconfig\printserver1.printerExport.
Queue publish mode: none
Overwrite mode: force new settings

LISTING PRINT QUEUES
..
..
The following error occurred: 0x80070050.
The file exists.

Is there any way of not using the del c:\temp\printersbackupconfig\*.* /S/Q and overwite what currently in the location without error "The File exists"

Cheers
Max-IT

Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Could you not just remove the specific file:

c:\temp\printersbackupconfig\printserver1.printerExport

or export it into a temporary directory then move / copy it to the one you want.

e.g.

rd C:\temp\tempexport /s/q
md c:\temp\tempexport
%windir%\System32\Spool\Tools\PrintBRM -s \\printserver1 -b -f c:\temp\tempexport\printserver1.printerExport  -O FORCE
move c:\temp\tempexport\printserver1.printerExport   c:\temp\printersbackupconfig\printserver1.printerExport

or something like that!

Steve
Avatar of Bill Prew
Bill Prew

I was already to suggest just deleting the single file, and refreshed and viola, Steve was there with it.  So I would recommend that as the first and simplest approach to consider as well.

~bp
Avatar of maxwsp

ASKER

Thanks for comments - the idea behind not deleting the file before another fresh backup runs is the fact that the script runs weekly and if say there is an issue with the backup then not only the previous backup is deleted but no backup as well.  I was just wondeing whether I could overwrite the file(s) rather than moving or deleting the file as space is also an issue in our environment.  Also it's not just a single file but the batch file actually is used to backup over 20 print servers ad size of these do grow - so do not want to move files to a temporary location and rather have an option to overwrite current files.

Cheers
Max-IT
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maxwsp

ASKER

Thanks for the code - this should do the trick.