What could cause an executable, called by a powershell script, to hang when it exits

I'm debugging a particularly strange problem...

As a part of my team's test suite, we run a powershell script that calls an executable I wrote in C#.

Every blue-mooned Tuesday, the executable will hang indefinitely until we kill the process. Most days it works just fine, and I haven't gotten it to repro.

The curious part is that this exe hangs after it's done doing all it's work. It's output the last line of data and the main thread is exiting. There's no multithreading in this process, and CPU is at 0% and thread count is 1.

All I/O (other than console writes) is done earlier in the execution, and there's no exception catching anywhere, so if something throws we should see it.

I don't need a definitive "this is the issue," but I have no idea what could cause this behavior. If you could respond with any theories on why this would be happening (no matter how far fetched) that'd be great.

Version info

  • OS: Windows 2008 R2
  • Powershell: v2 (comes with R2)
  • .NET: v4

-------------Problems Reply------------

Heh, this is worth a shot. Got


anywhere at the end of some line of logic?

I've got a behaviour like that on one of my "C" console program. It was well working started via "CMD.EXE" but when I use it via "POWERSHELL.EXE" it hang (systematicaly) at the end of exécution. In this code, there are keyboard pooling loop (while (! _kbhit()), and at the moment I solve the problem by consuming (getch()) the keydown that fired the last loop. I don't understand exactly why.

In the Powershell script the result of the exe file is affected to a var.

Category:c# 4.0 Views:1 Time:2011-05-20

Related post

  • What causes the error "Can't execute code from a freed script" 2008-09-17

    I thought I'd found the solution a while ago (see my blog): If you ever get the JavaScript (or should that be JScript) error "Can't execute code from a freed script" - try moving any meta tags in the head so that they're before your script tags. ...b

  • Executing a simple window.open script from the server 2009-01-12

    I have a dynamically created menu which I have a menuItemClick event tied in. In this event I want to execute a simple window.open script that uses the clicked items' url. The reason I need to do this is I need to set the parameters of the window ope

  • Execute PowerShell Script from C# with Commandline Arguments 2009-02-09

    I need to execute a PowerShell script from within C#. The script needs commandline arguments. This is what I have done so far: RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); Runspace runspace = RunspaceFactory.CreateRun

  • How to Execute a PowerShell Script from SSIS 2009-03-03

    Does anyone know how to execute a PowerShell script from SSIS? I have created the script and it works from from the command line. The script takes a couple of command line parameters, which work fine when called from cmd.exe. I'm using an Execute Pro

  • Identify the PID of a Executing Batch File in Powershell 2009-08-27

    I need to identify the P(rocess) ID of an executing batch file from a PowerShell (v1.0) script. Can anyone suggest a way of doing this? Thanks, MagicAndi. --------------Solutions------------- Well, whether that's possible depends on how you executed

  • How to get Hudson CI to execute a Powershell script? 2009-09-24

    I'm using Hudson version 1.324 for CI and have a couple of issues: Environment: - Windows Server 2008 - Powershell v1.0 - Hudson 1.324 running as a service - Hudson Powershell Plugin installed - Psake (aka. "Powershell Make/Rake" available from Githu

  • Executing oracle queries in Shell Script 2009-11-26

    Please tell me how can i excute an oralce query inside a shell script.I am writing a shell script where I need to execute the oracle queries and scripts inside the shell script. What is the purpose of these lines sql_file=sachin.sql cat <<!SQL

  • PowerShell script - How to process result of executed command 2009-12-04

    I have a small script that copies files to a list of remote machines. In this script I use: Copy-Item "$AppLocation\$AppName" -destination "\\$MachineName\c$\" -force This can throw various types of errors. If this throws an error, I want to log the

  • How can I execute a large number of scripts with IronPython and avoid the startup cost of ipy.exe? 2009-12-22

    How can I execute a large number of scripts with IronPython and avoid the startup cost of ipy.exe? By large I mean over 100. Each script is a simple acceptance test for a service application and will run very quickly. The simplest approach I can thin

  • Using Powershell on one computer to execute a Powershell script on another 2010-07-06

    This might be really obvious, since I'm kind of new to Powershell, but what's the best way to run a Powershell script on one computer that accesses another to run a Powershell script on that one? I'm using V2.0 if that matters. --------------Solution

  • Silently executing a PowerShell script from WiX Hangs PowerShell 2010-11-09

    Note: This question is also posted on the WiX Users mailing list. I am trying to silently execute a PowerShell script from a WiX produced MSI. However, anytime I run the installer PowerShell hangs. Interestingly enough, according to the installer log

  • Use Popen to execute a Powershell script in Python, how can I get the Powershell script's output and update it to web page? 2011-01-12

    I create a simple HTML with a button. When user clicks the button, it will call a Python file executed in server side. In the Python file, I use Popen to call a Powershell script, like below code: command_line = r'"C:\WINDOWS\system32\windowspowershe

  • what causes the error cant execute code from a freed script using dojo 2011-01-25

    My issue is something similar to what discussed in What causes the error "Can't execute code from a freed script". I have a search icon in parent window, on click popup opens, where I can do some search. On select of search result, I need to populate

  • executing a Powershell script from php 2011-03-15

    I'm trying to execute a powershell script from PHP, but it does not seem to work. The script 'newEvent.ps1' creates an event on the Exchange server. $psPath = "powershell.exe"; $psDIR = "C:\\wamp\\www\\ant\\assets\\ps\\"; $psScript = "newEvent.ps1";

  • How to execute PowerShell scripts in C# using the Task Parallel Library 2011-04-21

    I am currently executing PowerShell scripts as follows: internal void RunScript(PowerShell powerShell, Runspace runspace, Script script, IDictionary parameters = null, Action<ICollection<PSObject>> callback = null) { SetupScriptRun(powerS

  • Can't execute code from a freed script - IE6 IE7 IE8 IE9 2011-04-28

    I ran into this problem today in IE6 (but is reproducible on all recent version of IE). I noticed quite a few people run into this problem and I haven't seen a very practical way to fix this. There seems to be some other solution floating about regar

  • Does any one how to execute this cmd through shell script? 2011-04-29

    Does any one know how to execute below cmd through shell script? #!/bin/sh USERNAME="XYZ" defaultCmd=`defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions "{ \"USERNAME\" = \"${USERNAME}\" ;}" ` where write com.apple.Xcode is a .plist fil

  • Problem executing multiple powershell scripts from a batch file 2011-06-14

    I have a .bat that calls 3 PowerShell scripts Basically the bat file looks like this PScript1 Pscript2 Pscript3 After the Pscript1 the batch file does not execute Pscript2 or Pscript3, it stops and does not seem to return control to the batch file. D

  • How to execute 7zip commands from nant script? 2011-09-14

    I need to execute 7zip commands from nant script. How can I do that? I have tried it like this, but it is not working &ltexec program="7z.exe" basedir="${sevenzipinstalldir}" commandline="7z a D:\NantTest\Experiment\NewLab\7ziptest.zip -pmypasswo

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.110 (s). 11 q(s)