![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | 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) |
| | 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) |
| | Re: How to analyze ERRORLEVEL in the script "Eugene Borisov" <yevgeniy@xxxxxx> wrote in message news:uC8ywaUhIHA.2540@xxxxxx Quote: > 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. 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) |
| | 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 Quote: > 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![]() |
| | #5 (permalink) |
| | Re: How to analyze ERRORLEVEL in the script "Eugene Borisov" Quote: > > 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. > 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) |
| | 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 Quote: > > "Eugene Borisov" > Quote: >> >> 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. >> > Perhaps an example using the free > 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![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Analyze Disk Fragmentation | Vista performance & maintenance | |||
| Help analyze my Netmon capture? | Network & Sharing | |||
| How to set errorlevel env variable properly from a simple batch file: Answered | Vista General | |||
| ErrorLevel | PowerShell | |||
| checking errorlevel? | PowerShell | |||