locked
How do I resume a suspended PowerShell Script process?

    Question

  • In general, I haven't had any issued with the Windows 8 developer preview... until now :-)

    I've got a relatively long running application which, after several hours running, appears to get suspended.  (At least, this is what is reported by the Task Manager.)  The problem is, it is only about 20% complete.

    So my question is, how do I get the process to resume.  BTW, this application is an executable running as part of a PowerShell script; with everything running in the desktop environment.

    - Mark



    Wednesday, January 25, 2012 1:53 PM

All replies

  • As far as I know, the process automatically resumes when you move a focus to it. That is if you switch from your Metro UI IE to Desktop IE, the Metro UI IE gets suspended after some time. Switch back to Metro UI and Windows will resume it.

    Do I feel it like some of active threads of any of your process that becomes inactive gets frozen when you move focus out of this process so that the OS considers the process inactive?


    Well this is the world we live in And these are the hands we're given...
    Wednesday, January 25, 2012 2:33 PM
  • As far as I can see, Metro isn't involved.

    What I have is a PowerShell console window on the desktop running a script.  This script runs an application (executable image).  It is this application image which is being suspended.

    I have tried going from the desktop to Metro and back, no luck.  As the application image doesn't have a UI, I can really shift focus to the application.  (Shifting focus to the PowerShell window running the script doesn't work.)

    So far, nothing I have tried has allowed the suspended process to resume.

    - Mark

    Wednesday, January 25, 2012 3:38 PM
  • I've got a relatively long running application which, after several hours running, appears to get suspended.  (At least, this is what is reported by the Task Manager.)


    Reported where?   If it is seen as an "app" you could use the  App History  tab's  right-click  Switch to  command to try to resume it.

    Alternatively, you may find a  Resume  command available for a program in the Resource Monitor right-click menu.   (It doesn't seem to matter which tab you are in when you try to use that option.  Who knew?).   Resource Monitor can be started via TM's Performance tab.

     

    HTH

    Robert Aldwinckle
    ---

    Wednesday, January 25, 2012 5:21 PM
  • As far as I can see, Metro isn't involved.

    What I have is a PowerShell console window on the desktop running a script.  This script runs an application (executable image).  It is this application image which is being suspended.

    I have tried going from the desktop to Metro and back, no luck.  As the application image doesn't have a UI, I can really shift focus to the application.  (Shifting focus to the PowerShell window running the script doesn't work.)

    So far, nothing I have tried has allowed the suspended process to resume.

    - Mark

     

    My understanding was only Metro apps suspend. Are you looking a way to resume using PS script?  a shot in dark try add a script to kill the application first then start again Or you could post the script here someone who is good at PS can tweak it. :)


    Microsoft MVP - Windows Expert (IT Pro)
    Wednesday, January 25, 2012 6:22 PM
  • It is being reported as suspended by the Windows Task Manager (TM not taskmgr).  It is not an "app" in the sense that TM (and Metro?) uses.  It is just an arbitrary executable image.  The image is originally from an older (I think Vista) system.

    You are right about the Resource Monitor.  In the CPU tab's process list, right-clicking on a process brings up a menu where one of the entries is "Resume Process".

    The image hasn't been suspended recently (since I looked at the REsource Monitor) so I can't say for sure this will resume.

    - Mark

    Wednesday, January 25, 2012 6:41 PM
  • Nope.  From what I can see, other processes can be suspended.  In my case, it is an arbitrary (pre-Windows 8) image I am running on a Windows 8 system.

    I do in fact need a way to resume from a PS script.  (I also need a way to detect the situation.)  I was able to cobble together a bunch of PS code which does resume the process, so that piece of the puzzle is complete.  Now to figure out how to detect the suspended process.

    Killing the PS script (running the image) isn't an option because of everything else the script is doing; which would make restarting very difficult at best.

    So I guess there are really two issues here.  First, why is Windows 8 suspending the (non-Metro) process in the first place. Second, it would be useful/helpful/etc. to have a PowerShell mechanism/cmdlet to be able to resume a suspended process.

    - Mark

    Wednesday, January 25, 2012 6:49 PM
  • Have you tried *-Job scripts to manipulate PoSH scripts? Looks like that's what you are looking for. Just type Job in the Name field on the Commands pane within the PowerShell ISE.

    Resume-Job [-PassThru] [-State <JobState> {NotStarted | Running | Completed | Failed | Stopped | Blocked | Suspended | Disconnected | Suspending | Stopping}] [-WhatIf] [-Confirm] [<CommonParameters>]

    Or is it something completely different?

    Have a look at these Resume-Process and Suspend-Process scripts http://poshcode.org/2995


    Well this is the world we live in And these are the hands we're given...



    Thursday, January 26, 2012 1:43 PM
  • I haven't tried using jobs.  Although I'm not at all confident it would work.  Mainly because it is not the script which is getting suspended, but the image being invoked within the script which is being suspended.

    I did find the examples at poshcode.org, and gave me the idea for my script based solution.  The only minor problem I have run into is finding out whether or not the process is suspended.  There does not appear to be any cmdlet which gives me the process (run) status.  This isn't a show-stopper, as resuming a process which is not suspended appears to be harmless.

    - Mark

    Thursday, January 26, 2012 4:39 PM