Error Handling in VB Scripting

Narasimha G 0 Reputation points
2024-10-06T17:20:45.9+00:00

Hi VB Script Gurus,

We have having a VB Script failure on the server and it produces a SQL Script files with list of scripted tables and other objects.

Due to some reason this script is not working after deploying on the server environment but it works perfectly when we run through visual studio on same environment. we are not getting any clear error details ( no clues) when it failed.

I don't have any knowledge on VB script to enable extra logging. I wanted to trap error details to text files for information on file.

Looking forward to your help

Windows for business Windows Server User experience Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2024-10-06T18:09:43.7133333+00:00

    Whatever you are using to run the script should be configured to capture stdout and stderr.

    https://www.bing.com/search?q=windows+capture+stdout+stderr

    If you are using a .bat file, have it run the script like this.

    cscript.exe c:\Scripts\MyScript.vbs 1> c:\Scripts\Logs\MyScript.log 2>&1
    

    If the script contains "on error resume next", you can comment that line out and just let it crash when it hits an error. Then check the log file. Otherwise your script needs to test err.number more frequently and gracefully handle any error condition.

    https://www.bing.com/search?q=vbscript+err.number

    If your script accesses network shares then a common problem is that the account that is running the script does have access to the remote server.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.