I am currently backing the system state on various machines with
ntbackup that is launched through a VB script. The script also sends
e-mails when its completed. What I need to do is add code that does
error checking for when ntbackup fails.Instead of sending an e-mail
when it completes I need to change it to send one when it fails. Does
anyone have any code out there that does that? Any help would be
appreciated.

Thanks
Robert

Re: Backup up system state with NTbackup through a VB script (I need error checking) by Michael

Michael
Thu May 20 21:10:08 CDT 2004

> I am currently backing the system state on various machines with
> ntbackup that is launched through a VB script. The script also sends
> e-mails when its completed. What I need to do is add code that does
> error checking for when ntbackup fails.Instead of sending an e-mail
> when it completes I need to change it to send one when it fails. Does
> anyone have any code out there that does that? Any help would be
> appreciated.

I would assume the if ntbackup is unsuccessful that the exit code will be
non-zero...

Google Search: ntbackup errorlevel group:microsoft.*
http://groups.google.com/groups?q=ntbackup%20errorlevel%20group:microsoft.*&num=100&scoring=d

Assuming you are using WshShell.Run to execute something like "%comspec% /c
ntbackup ...", then using true as the 3rd argument of the Run method will
wait fot completion the the Run method's return value is the ntbackup exit
code (i.e. the equivalent of %errorlevel% in a bat file).

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US


Re: Backup up system state with NTbackup through a VB script (I need error checking) by rhorn

rhorn
Fri May 21 11:39:54 CDT 2004

"Michael Harris \(MVP\)" <mikhar at mvps dot org> wrote in message news:<uorU#itPEHA.1644@TK2MSFTNGP09.phx.gbl>...
> > I am currently backing the system state on various machines with
> > ntbackup that is launched through a VB script. The script also sends
> > e-mails when its completed. What I need to do is add code that does
> > error checking for when ntbackup fails.Instead of sending an e-mail
> > when it completes I need to change it to send one when it fails. Does
> > anyone have any code out there that does that? Any help would be
> > appreciated.
>
> I would assume the if ntbackup is unsuccessful that the exit code will be
> non-zero...
>
> Google Search: ntbackup errorlevel group:microsoft.*
> http://groups.google.com/groups?q=ntbackup%20errorlevel%20group:microsoft.*&num=100&scoring=d
>
> Assuming you are using WshShell.Run to execute something like "%comspec% /c
> ntbackup ...", then using true as the 3rd argument of the Run method will
> wait fot completion the the Run method's return value is the ntbackup exit
> code (i.e. the equivalent of %errorlevel% in a bat file).



Below is the code I am using and what I need to do error checking on.
Nothing I have tried as worked

Set objUser = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
objName = objUser.GetTempName
objTempFile = objName
objShell.Run "cmd /c C:\Windows\system32\NTBACKUP.exe backup_
\\dfstxfs3\q$\dhcp\backup /v:yes /r:no /rs:no /hc:off /m normal_
/j DFSTXFS3_DHCP_Database_Backup /l:s_
/f c:\DHCP\DHCP_Database_Backup.bkf" ,8,True

Re: Backup up system state with NTbackup through a VB script (I need error checking) by Michael

Michael
Fri May 21 20:13:02 CDT 2004

> Below is the code I am using and what I need to do error checking on.
> Nothing I have tried as worked
>
> Set objUser = WScript.CreateObject("Scripting.FileSystemObject")
> Set objShell = WScript.CreateObject("WScript.Shell")
> objName = objUser.GetTempName
> objTempFile = objName
> objShell.Run "cmd /c C:\Windows\system32\NTBACKUP.exe backup_
> \\dfstxfs3\q$\dhcp\backup /v:yes /r:no /rs:no /hc:off /m normal_
> /j DFSTXFS3_DHCP_Database_Backup /l:s_
> /f c:\DHCP\DHCP_Database_Backup.bkf" ,8,True


You need to call objShell.Run using function call syntax...

exitcode = objShell.Run("cmd /c <blahblah>",8,true)

if exitcode <> 0 then
msgbox "Oops!!"
end if

Check the Run method doumentation for details...

WSH 5.6 documentation download (local HTMLHelp format)...
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

--
Michael Harris
Microsoft.MVP.Scripting