# Windows commands and error handling

**URL:** <https://www.ruby-forum.com/t/windows-commands-and-error-handling/75280>\
**Category:** Ruby\
**Created:** [November 8, 2006, 8:18pm UTC](https://www.ruby-forum.com/t/windows-commands-and-error-handling/75280 "2006-11-08T20:18:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brad7a0](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/53a042/32.png) [@brad7a0](https://www.ruby-forum.com/u/brad7a0)\
**Post date:** [November 8, 2006, 8:18pm UTC](https://www.ruby-forum.com/t/windows-commands-and-error-handling/75280/1 "2006-11-08T20:18:17Z")

</div>

I am attempting to handle windows native command errors within a Ruby  
script on  
windows xp. Commands in backticks like `net use ...` do not allow for  
this. I  
tried open3, but it is unsupported on windows because of the lack of  
fork.  
system() does not do anything either. How do others handle this on  
windows? I  
only want to use the core Ruby library, not win32 utils.

begin  
`windows command`  
rescue SomeException =\> e  
do this to handle this exception…  
rescue SomeOtherException =\>  
do this for the other exception…  
end

Thank you,  
Brad

---

<div class="post-metadata">

**Author:** ![brad7a0](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/53a042/32.png) [@brad7a0](https://www.ruby-forum.com/u/brad7a0)\
**Post date:** [November 8, 2006, 8:22pm UTC](https://www.ruby-forum.com/t/windows-commands-and-error-handling/75280/2 "2006-11-08T20:22:20Z")

</div>

On 11/8/06, Brad T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> rescue SomeOtherException =\>  
> do this for the other exception…  
> end

Use “system” if you want the exit code of the system command you are  
running. Use backticks if you need the output from the command you  
invoked.

Does that help?
