Catch Powershell script errors in VBscript

Posted on 2010-01-07
Last Modified: 2012-05-08
I am calling Windows Powershell 2 scripts from VBscript using Shell command.

Set Shell = CreateObject("Wscript.Shell")
Shell.Run( "powershell.exe -noexit " & <PowerShellCommand>  )  

How can I catch errors/ exceptions from Powershell script and also pass these errors back to VBscript?

Question by:jamke1
    1 Comment
    LVL 70

    Accepted Solution


    VbScript has no way of accessing that information directly I'm afraid.

    A couple of ways to workaround this spring to mind.

    The first is using the ErrorLevel environmental variable as discussed here:

    The second, is to have PowerShell log its own errors to a file. How complex that gets depends on what your script does.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now