Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


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

1 post in this topic

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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.