michalek19
asked on
Printbrm.exe - adding log file and e-mail alert to batch file
Hi Again
I am wondering if there is a way to add log file and e-mail alert to this batch file when the backup is done
I am wondering if there is a way to add log file and e-mail alert to this batch file when the backup is done
@echo off
set BkupDir=C:\temp
set PrintBRM=%windir%\System32\Spool\Tools\PrintBRM
call :DoBackup M-CORP
call :DoBackup PRT-US
call :DoBackup Y-COR
call :DoBackup BO-RNT1
goto :EOF
:DoBackup [printservername]
if exist "%BkupDir%\%~1.printerExport" ren "%BkupDir%\%~1.printerExport" "*.bak"
%PrintBRM% -b -s \\%~1 -f %BkupDir%\%~1.printerExport -O FORCE && (
if exist "%BkupDir%\%~1.bak" del "%BkupDir%\%~1.bak
) || (
if exist "%BkupDir%\%~1.bak" ren "%BkupDir%\%~1.bak" "*.printerExport"
)
goto :EOF
Thx, Michal
ASKER
Do you have different example that will show me how the script looks like?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is it possible to create spread sheet file instead txt file
Also, the result is hard to read. Is it possible to make that output clear to ready
Like for example
Operation mode: backup
Target server: \\PRLTarget file path: \\fs01\printodb\PS-ATL.pri nterExport .
Queue publish mode:
Print server name:
Hostname: IP address Driver Percentage %
PRINT QUEUES ATL-8155
HPLJAPLJATL
.....
Log-file.txt
Also, the result is hard to read. Is it possible to make that output clear to ready
Like for example
Operation mode: backup
Target server: \\PRLTarget file path: \\fs01\printodb\PS-ATL.pri
Queue publish mode:
Print server name:
Hostname: IP address Driver Percentage %
PRINT QUEUES ATL-8155
HPLJAPLJATL
.....
Log-file.txt
I'm not familiar with using that export command and any other options you can do with it. We can always do some processing on the log file after it has been created etc. but apart from making a CSV file to open into Excel that might be your only way to do that.
Steve
Steve
http://www.robvanderwoude.com/battech_redirection.php
The printbrm.exe command itself had problems with piping, which was fixed in Windows 7 and higher:
http://www.minasi.com/forum/topic.asp?TOPIC_ID=32445
As for emailing, you'll need an email client. Blat is a command-line email client tool that you could set up and add to your batch file:
http://sourceforge.net/projects/blat/
http://www.blat.net/syntax/syntax.html
It may also be possible to send an email via the built-in telnet client, but this sounds trickier:
http://community.spiceworks.com/topic/265337-how-to-send-email-from-command-line-in-windows-7
I think it makes the most sense to use two batch files: the original one for running the task, and the 2nd one for piping the output from the first into a log file, then emailing the log file.