Sign in to follow this  
Followers 0
Maxaki

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

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Water,

Thank you!! Yes. This is what I needed.

Awesome

Edited by Maxaki

Share this post


Link to post
Share on other sites

That was an easy one :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I think you should make it clearer what you want to do

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

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
Sign in to follow this  
Followers 0