![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to analyze ERRORLEVEL in the script Hello, I am building my first script in PowerShell. I included external application (WinZip) in it and all works fine. Now, I want to analyze the result of Winzip by looking into ERRORLEVEL like I was able to do in CMD shell in old times, but can't figure that out. If anyone has an idea how to expose ERRORLEVEL, please share. Thank you Eugene |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: How to analyze ERRORLEVEL in the script Take a look at this http://bsonposh.com/modules/wordpress/?cat=11 Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject EB> Hello, EB> EB> I am building my first script in PowerShell. I included external EB> application (WinZip) in it and all works fine. Now, I want to EB> analyze the result of Winzip by looking into ERRORLEVEL like I was EB> able to do in CMD shell in old times, but can't figure that out. If EB> anyone has an idea how to expose ERRORLEVEL, please share. EB> EB> Thank you EB> Eugene |
My System Specs![]() |
| | #3 (permalink) | ||||||||||||
| Guest | Re: How to analyze ERRORLEVEL in the script "Eugene Borisov" <yevgeniy@xxxxxx> wrote in message news:uC8ywaUhIHA.2540@xxxxxx
function Get-CallStack { trap { continue } 1..100 | foreach { $var = Get-Variable -scope $_ MyInvocation $var.Value.PositionMessage -replace "`n" } } #-------------------------------------------------------------------- # Helper function to deal with legacy exe exit codes #-------------------------------------------------------------------- function CheckLastExitCode { param ([int[]]$SuccessCodes = @(0), [scriptblock]$CleanupScript=$null) if ($SuccessCodes -notcontains $LastExitCode) { if ($CleanupScript) { "Executing cleanup script: $CleanupScript" &$CleanupScript } $OFS = $NL = [System.Environment]::NewLine throw "EXE RETURNED EXIT CODE ${LastExitCode}${NL}$(Get-CallStack)" } } Use like so: & $WinZipPath <params> CheckLastExitCode If use TFS command line: & $TfPath get $DevRoot /r CheckLastExitCode @(0,1) Here I specify that both 0 and 1 exit codes are considered success. -- Keith | ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||
| Guest | Re: How to analyze ERRORLEVEL in the script Brandon and Keith, This is much more that I expected - thank you very much. Your both answers completeley cover the topic. Even CheckLastExitCode is a great function and I will keep it in mind, simple $LASTEXITCODE will do it for me for now. Thanks again for helping me out. Cheers. "Eugene Borisov" <yevgeniy@xxxxxx> wrote in message news:uC8ywaUhIHA.2540@xxxxxx
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: How to analyze ERRORLEVEL in the script "Eugene Borisov"
IIS's Microsoft's data parser, Log Parser 2.2 (with a built-in Microsoft ChartSpace chart maker). Notice: IIS does not need to be running or installed in order to use Log Parser for either data parsing or chart making. PS> LogParser.exe "SELECT" Error: Syntax Error: <field-expr>: cannot find a valid <field-expr>:'' PS> Mmmm did Microsoft's data parser fail? PS> $LastExitCode 1615 PS> Mmmm what does that error number mean? Well using Microsoft's Common Error Lookup Tool. PS> err.exe 1615 # for decimal 1615 / hex 0x64f : ecInvLogonHrs ec.h ERROR_BAD_QUERY_SYNTAX winerror.h # SQL query syntax invalid or unsupported. # 2 matches found for "1615" PS> Mmmm did Microsoft's Common Error Lookup Tool (err.exe) run okay? PS> $LastExitCode 0 PS> Search the Internet for usage of: Microsoft's Log Parser (from the IIS group) and Microsoft's ChartSpace Charting as used within Log Parser, Excel or even stand alone scripting usage (from the Office group) and Microsoft's Common Error Lookup Tool (from the Exchange group) Just three other PowerShell tools ways! | ||||||||||||
My System Specs![]() | |||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||
| Guest | Re: How to analyze ERRORLEVEL in the script Dude.. I have to know. Did you write this product? Your passion is amazing! "Flowering Weeds" <floweringnoweedsno@xxxxxx> wrote in message news:%23TQZ3OfhIHA.5260@xxxxxx
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please help analyze this blue screen! | Hank | Vista General | 14 | 07-04-2008 02:49 PM |
| Analyze Disk Fragmentation | Benzmum | Vista performance & maintenance | 23 | 09-30-2007 07:09 PM |
| ErrorLevel | Dan | PowerShell | 5 | 08-06-2007 01:40 AM |
| howto analyze fix setup? | Egbert Nierop \(MVP for IIS\) | Vista installation & setup | 5 | 01-11-2007 10:21 AM |
| checking errorlevel? | =?Utf-8?B?TWljaGFlbCBLZWxsZXk=?= | PowerShell | 1 | 09-14-2006 07:29 PM |