Jump to content

Script wait for process 10min, if not exist do next


Maxaki
 Share

Recommended Posts

Hey.

I am using HP Update Assistant to do some driver updates. I cannot interact with it and failed hard to make an ImageSearch. Anyway, between each driver it installs, a certain process launches. This happens about every 3-8minutes.

I want it to check every minute for 10 minutes if the process exists. If it hasn't existed in 10 minutes I want it to do next command.

Is this possible? With my small knowledge of scripting I think it should be something like: If loop 1 - 10 if not then next... etc

/Andreas

Edited by Maxaki
Link to comment
Share on other sites

Something like this?

For $i = 1 To 10
    If ProcessExists("processname or number") Then ExitLoop
    Sleep(60000) ; Sleep for a minute
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

That was an easy one :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I realised that your script was just checking if the process were there every minute, if it wasn't it exists loop. It helped me make this though.

For $i = 1 To 10
For $a = 1 To 9
    If ProcessExists("AMPAgent.exe") Then
      Sleep(60000)
   Else
   Sleep(60000)
EndIf
   ;Last try, now it will
If ProcessExists("AMPAgent.exe") Then ExitLoop
Next

It tries 10 times and on the 10th time it will choose either to Exit the loop or to Continue it.

The problem here is that I want to make the last If statement know if the other statement was "Then" or "Else" statements because then it can analyze if the program was open or not.

This was a little bit more of challenge I guess...

Edited by Maxaki
Link to comment
Share on other sites

michaelslamet,

It's difficult to explain but a friend helped me out, it seems like he solved it.

Here is the code

For $i = 1 To 60
   If ProcessExists("example.exe") Then
      For $a = 1 to 59
        If ProcessExists("example.exe") Then
           Sleep (10000)
        Else 
           $i = 1
           ExitLoop
           EndIf
           Next
   Else
      Sleep (10000)
      EndIf
Next
Edited by Maxaki
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...