Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Detect inactive Bat file

Detect inactive Bat file

Scheduled Pinned Locked Moved C#
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AnnnS
    wrote on last edited by
    #1

    Hi all i have the folloeing code to run a batch file System.Diagnostics.ProcessStartInfo psiinfo=new System.Diagnostics.ProcessStartInfo("aaa.bat"); psiinfo.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden; psiinfo.CreateNoWindow=true; System.Diagnostics.Process p1=System.Diagnostics.Process.Start(psiinfo); while(!p1.HasExited); // //Following some other code // It works fine with Xp and 2000. But the problem comes with windows 98 in that after executing the batch file the batch file will not get closed . instead it will become an inactive window and the user has to close it manualy . So "has Exited " is not working here since the process is not getting closed. is there any way to find out whether the process in inactive or completed execution .. thanks in Advance AnnS Suffering cheerfully endured, ceases to be suffering and is transmuted into an ineffable joy.

    L 1 Reply Last reply
    0
    • A AnnnS

      Hi all i have the folloeing code to run a batch file System.Diagnostics.ProcessStartInfo psiinfo=new System.Diagnostics.ProcessStartInfo("aaa.bat"); psiinfo.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden; psiinfo.CreateNoWindow=true; System.Diagnostics.Process p1=System.Diagnostics.Process.Start(psiinfo); while(!p1.HasExited); // //Following some other code // It works fine with Xp and 2000. But the problem comes with windows 98 in that after executing the batch file the batch file will not get closed . instead it will become an inactive window and the user has to close it manualy . So "has Exited " is not working here since the process is not getting closed. is there any way to find out whether the process in inactive or completed execution .. thanks in Advance AnnS Suffering cheerfully endured, ceases to be suffering and is transmuted into an ineffable joy.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Try giving other processes some CPU time as well: replace your while loop by: while(!p1.HasExited) Thread.Sleep(200); AFAIK older Windows such as Win98 are not as good in switching processes in time, so you should not choose a delay that is much smaller; your code was keeping the current process very busy, and I guess Win98 could not deal with that.

      Luc Pattyn

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups