![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Logging Success or Failure of a script Hi, I am running 36 VBscripts via the AT schedular. I was wondering if it was possible to log the Success or Failure of each script. I use a CMD file to start the script, like this: @echo off time /t xferftpfiles.vbs if errorlevel 1 eventcreate /l application /so amc_xfer.cmd /t information /id 999 /d "amc_xfer.cmd failed" & goto end eventcreate /l application /so amc_xfer.cmd /t information /id 111 /d "amc_xfer.cmd complete" & goto end :end This gives me a Success regardless if the VBScript runs or not. I have put some logic in the script it self to tell me if the FTP worked or not, BUT what I don't get is any indication that the script itself actualy ran or not. I know that I can infer that it ran by the script log entry, but I want a positive indication that the script was found and run. OldDog |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Logging Success or Failure of a script On Sep 8, 9:36*am, OldDog <michael.r.felk...@xxxxxx> wrote: Quote: > Hi, > > I am running 36 VBscripts via the AT schedular. I was wondering if it > was possible to log the Success or Failure of each script. I use a CMD > file to start the script, like this: > > @echo off > time /t > xferftpfiles.vbs > if errorlevel 1 eventcreate /l application /so amc_xfer.cmd /t > information /id 999 /d "amc_xfer.cmd failed" & goto end > eventcreate /l application /so amc_xfer.cmd /t information /id 111 /d > "amc_xfer.cmd complete" & goto end > :end > > This gives me a Success regardless if the VBScript runs or not. I have > put some logic in the script it self to tell me if the FTP worked or > not, BUT what I don't get is any indication that the script itself > actualy ran or not. I know that I can infer that it ran by the script > log entry, but I want a positive indication that the script was found > and run. > > OldDog @echo off time /t if exist .\xferftpfiles.vbs ( call :YES ) else ( call :NO ) :YES amc_xferftpfiles.vbs eventcreate /l application /so xferftpfiles.vbs /t information /id 111 /d "xferftpfiles.vbs run" & goto end goto :Next :NO eventcreate /l application /so xferftpfiles.vbs /t information /id 999 /d "xferftpfiles.vbs not found" & goto end goto :Next :Next if errorlevel 1 eventcreate /l application /so xfer.cmd /t information id 999 /d "amc_xfer.cmd ran" & goto :end eventcreate /l application /so xfer.cmd /t information /id 111 /d "amc_xfer.cmd failed" & goto :end :end But this seems to just hang. Any better ways to do this? Olddog |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Logging Success or Failure of a script On Sep 8, 9:36*am, OldDog <michael.r.felk...@xxxxxx> wrote: Quote: > Hi, > > I am running 36 VBscripts via the AT schedular. I was wondering if it > was possible to log the Success or Failure of each script. I use a CMD > file to start the script, like this: > > @echo off > time /t > xferftpfiles.vbs > if errorlevel 1 eventcreate /l application /so amc_xfer.cmd /t > information /id 999 /d "amc_xfer.cmd failed" & goto end > eventcreate /l application /so amc_xfer.cmd /t information /id 111 /d > "amc_xfer.cmd complete" & goto end > :end > > This gives me a Success regardless if the VBScript runs or not. I have > put some logic in the script it self to tell me if the FTP worked or > not, BUT what I don't get is any indication that the script itself > actualy ran or not. I know that I can infer that it ran by the script > log entry, but I want a positive indication that the script was found > and run. > > OldDog @echo off time /t if exist .\xferftpfiles.vbs ( call :YES ) else ( call :NO ) :YES xferftpfiles.vbs eventcreate /l application /so xferftpfiles.vbs /t information /id 111 /d "xferftpfiles.vbs run" & goto end goto :Next :NO eventcreate /l application /so xferftpfiles.vbs /t information /id 999 /d "xferftpfiles.vbs not found" & goto end goto :Next :Next if errorlevel 1 eventcreate /l application /so xfer.cmd /t information id 999 /d "xfer.cmd ran" & goto :end eventcreate /l application /so xfer.cmd /t information /id 111 /d "xfer.cmd failed" & goto :end :end |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Logging Success or Failure of a script OldDog wrote: Quote: > @echo off > time /t > if exist .\xferftpfiles.vbs ( > call :YES ) > else ( > call :NO ) > > :YES > xferftpfiles.vbs > eventcreate /l application /so xferftpfiles.vbs /t information /id > 111 /d "xferftpfiles.vbs run" & goto end > goto :Next > :NO > eventcreate /l application /so xferftpfiles.vbs /t information /id > 999 /d "xferftpfiles.vbs not found" & goto end > goto :Next > > :Next > > if errorlevel 1 eventcreate /l application /so xfer.cmd /t information > id 999 /d "xfer.cmd ran" & goto :end > eventcreate /l application /so xfer.cmd /t information /id 111 /d > "xfer.cmd failed" & goto :end > > :end I'd first determine which condition you have and then create one log entry. Your above code doesn't take care of the fact that flow returns from a called sub. And the "goto :Next" can never be executed. If you can modifiy your vbscript to echo a descriptive /id and /D text instead of an errorlevel you can catch it and hand it over to the eventcreate command. (untested) @echo off :: check if vbs is present, if not LogIt and exit set Event=/id 777 /d "couldn't find xferftpfiles.vbs" set "loc=" for %%A in (xferftpfiles.vbs) do set loc=%%~f$PATH:A if not defined loc goto :LogIt :: Prepare case didn't run set Event=/id 888 /d "amc_xfer.cmd didn't run" :: run app, catch output which should be either :: /ID 999 blahblah or :: /ID 111 blahblah :: if no output,vbscript didn't run and previously set Event is logged for /f "delims=" %%A in ( 'cscript //nologo xferftpfiles.vbs') do set Event=%%A :LogIt Eventcreate /l application /so amc_xfer.cmd /t information %Event% HTH Matthias |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Logging Success or Failure of a script "OldDog" <michael.r.felkins@xxxxxx> wrote in message news:8cbd7369-071d-41cd-972f-3bd538948270@xxxxxx Quote: > Hi, > > I am running 36 VBscripts via the AT schedular. I was wondering if it > was possible to log the Success or Failure of each script. success or failure. For example, consider a script designed to search for a file. If it finds a file, that would most often be considered a success (there are exceptions). If it failed to find a file, would that be considered a failure of the script, a failure of the drive to supply the expected file, or would it simply mean that the script successfully returned the null set of file matches? Once you have decided on the relevant success/failure indicators, you next need to determine how the script will evaluate those factors and pass the information back to the launching script. It could set the error return code, but that, of course, would require that the launching batch script run the vbscript in such a way as to wait for it to complete. That may or may not be suitable, depending on, well, a number of factors. Alternately, it could write some summary of its operations to a text file, but another script might have trouble reading that file to determine success or failure. /Al Quote: > I use a CMD > file to start the script, like this: > > @echo off > time /t > xferftpfiles.vbs > if errorlevel 1 eventcreate /l application /so amc_xfer.cmd /t > information /id 999 /d "amc_xfer.cmd failed" & goto end > eventcreate /l application /so amc_xfer.cmd /t information /id 111 /d > "amc_xfer.cmd complete" & goto end > :end > > This gives me a Success regardless if the VBScript runs or not. I have > put some logic in the script it self to tell me if the FTP worked or > not, BUT what I don't get is any indication that the script itself > actualy ran or not. I know that I can infer that it ran by the script > log entry, but I want a positive indication that the script was found > and run. > > OldDog |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| 0x80041013 Provider Load Failure on restore point script | Vista performance & maintenance | |||
| Script that emails out a service failure notification | PowerShell | |||
| AD GPO log on script failure | Vista networking & sharing | |||
| Success | Vista General | |||