Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

[Feature] WMI-based TimedWaitForProgram (no tasklist prompts)

- - - - -

  • Please log in to reply
No replies to this topic

#1
Francesco

Francesco

    Advanced Member

  • Member
  • PipPipPip
  • 410 posts
  • Joined 20-March 04

Remove from jscript.js:

function TimedWaitForProgram(ImageName,HowLong)
{
  position="jscript.js";
whatfunc="TimedWaitForProgram()";
var Elapsed=3;
Pause(3,0);
while (Elapsed<=HowLong*60)
{
  var oExec = WshShell.Exec('tasklist.exe');
  while (oExec.Status == 0)
   Pause(0,100);
  var Output = oExec.StdOut.ReadAll() + oExec.StdErr.ReadAll();
  if (Output.search(ImageName)==-1)
   return;
  Pause(3,0);
  Elapsed += 3;
}
}

At the bottom of WMI.js add:

function TimedWaitForProgram(ImageName,HowLong)
{
  position="wmi.js";
whatfunc="TimedWaitForProgram()";
try
{
  objWMIService=GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2");
  var Elapsed=0;
  while (!HowLong || (Elapsed<=HowLong*60))
  {
   colItems=objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name='"+ImageName+"'");
 
   if (colItems.Count > 0)
    return true;
 
   Pause(1,0);
   Elapsed += 1;
  }
}
catch(ex)
{}
return false;
}

Edited by Francesco, 21 July 2013 - 01:35 AM.



How to remove advertisement from MSFN



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users