Sign in to follow this  
Followers 0
polara

ProcessClose help

26 posts in this topic

I am new to AutoIt and need help for a script that runs a Robocopy backup.

1.) I need the script to check if Outlook.exe is open before it starts the backup. It looks like the ProcessClose command would do this. But I also need the script to pop open a dialog box if it finds outlook.exe is open and ask the user to close Outlook, then click Ok. The clicking Ok would then re-check for outlook.exe, then resume the rest of the script commands if no instance of outlook.exe is found, or re-open the dialog box asking that outlook be closed if it is still open. Can anyone show me what these commands would look like?

2.) I would also like to know how to open a dialog box that says "Backup has finished" with a "Click OK" to close button that doesn't open until after the robocopy process has completed.

Thanks.

Share this post


Link to post
Share on other sites



1. If ProcessExists('Outlook.exe') Then

2. MsgBox()


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

HI,

here is something to start with :

$exe = 'outlook.exe'

If ProcessExists($exe) Then
    $answer = MsgBox(33, "Question", "Want to close outlook?", 5)
    If $answer = 1 Then
        ProcessClose($exe)
    EndIf
EndIf

If ProcessExists($exe) = 0 Then
    ; rest of script
EndIf

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

To complete smoke's code:

Do
If ProcessExists("Outlook.exe") then
     Msgbox(0, "Close", "Close Outlook Before Continuing.")
Until Not ProcessExists('Outlook.exe')

;Do backup Code Here

Msgbox(0, "Done", "Backup complete")

Edit

Got Beat

Smoke and th's code

Edited by Paulie

Share this post


Link to post
Share on other sites

HI,

here is something to start with :

$exe = 'outlook.exe'

If ProcessExists($exe) Then
    $answer = MsgBox(33, "Question", "Want to close outlook?", 5)
    If $answer = 1 Then
        ProcessClose($exe)
    EndIf
EndIf

If ProcessExists($exe) = 0 Then
    ; rest of script
EndIf

So long,

Mega

Wouldn't $answer always = 1?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I am new to AutoIt and need help for a script that runs a Robocopy backup.

1.) I need the script to check if Outlook.exe is open before it starts the backup. It looks like the ProcessClose command would do this. But I also need the script to pop open a dialog box if it finds outlook.exe is open and ask the user to close Outlook, then click Ok. The clicking Ok would then re-check for outlook.exe, then resume the rest of the script commands if no instance of outlook.exe is found, or re-open the dialog box asking that outlook be closed if it is still open. Can anyone show me what these commands would look like?

2.) I would also like to know how to open a dialog box that says "Backup has finished" with a "Click OK" to close button that doesn't open until after the robocopy process has completed.

Thanks.

$ol = ObjGet("","outlook.Application")
If Not @error Then
$ol.quit
MsgBox(0,"Outlook Closed","The active instance of outlook has been sucessfully closed")
Else
MsgBox(0,"No outlook","Script failed to get an open outlook object")
EndIf

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Wouldn't $answer always = 1?

HI,

no! If you press abort it will be 2. :D

There is Msgbox 33 not 32

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

HI,

no! If you press abort it will be 2. :D

There is Msgbox 33 not 32

So long,

Mega

i say don't even give them the option to say no. use COM to close outlook on them like in my example. then you know it's done. they may get a popup from the application saying 'are you sure you want to empty deleted items folder" or whatever, but as soon as they say yes or no (there is no cancel) then the application closes.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

HI,

here is something to start with :

$exe = 'outlook.exe'

If ProcessExists($exe) Then
    $answer = MsgBox(33, "Question", "Want to close outlook?", 5)
    If $answer = 1 Then
        ProcessClose($exe)
    EndIf
EndIf

If ProcessExists($exe) = 0 Then
    ; rest of script
EndIf

So long,

Mega

This is a good start but:

This kills outlook.exe as if I had killed it in Task Manager. I need it to close as if I had clicked on File>Exit in Outlook so that Outlook can do closing tasks such as sending messages and offline syncing. Any way to do this kind of close?

Also, in the message box, clicking Cancel runs the rest of the script anyway, with Outlook still open. I need to halt the entire script and open a message like "Backup cannot run until Outlook is closed" if Outlook is still open.

Thanks.

Share this post


Link to post
Share on other sites

This is a good start but:

This kills outlook.exe as if I had killed it in Task Manager. I need it to close as if I had clicked on File>Exit in Outlook so that Outlook can do closing tasks such as sending messages and offline syncing. Any way to do this kind of close?

Also, in the message box, clicking Cancel runs the rest of the script anyway, with Outlook still open. I need to halt the entire script and open a message like "Backup cannot run until Outlook is closed" if Outlook is still open.

Thanks.

did you see the code that i posted? beta is required


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

did you see the code that i posted? beta is required

I have the beta installed and I did try the code:

$ol = ObjGet("","outlook.Application")

If Not @error Then

$ol.quit

MsgBox(0,"Outlook Closed","The active instance of outlook has been sucessfully closed")

Else

MsgBox(0,"No outlook","Script failed to get an open outlook object")

EndIf

And got this error message:

Share this post


Link to post
Share on other sites

I have the beta installed and I did try the code:

$ol = ObjGet("","outlook.Application")

If Not @error Then

$ol.quit

MsgBox(0,"Outlook Closed","The active instance of outlook has been sucessfully closed")

Else

MsgBox(0,"No outlook","Script failed to get an open outlook object")

EndIf

And got this error message:

Ok, I did it again and it worked. Thanks. So, can I assume that, once compiled to an.exe, this will run just like the old versions?

Share this post


Link to post
Share on other sites

Ok, I did it again and it worked. Thanks. So, can I assume that, once compiled to an.exe, this will run just like the old versions?

you have to make sure you compile with beta, alt+f7 from scite.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

you have to make sure you compile with beta, alt+f7 from scite.

Will do. One last question: I really need to open a message box to warn users that Outlook is going to be closed, "Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel." If cancel is clicked, then script is halted and second message that says "Please close Outlook, then run backup again."

Edited by polara

Share this post


Link to post
Share on other sites

Will do. One last question: I really need to open a message box to warn users that Outlook is going to be closed, "Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel." If cancel is clicked, then script is halted and second message that says "Please close Outlook, then run backup again."

$ol = ObjGet("","outlook.Application")
If @error Then
    ;no outlook to grab onto
EndIf
$update = MsgBox(1,"Update","Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.",5)
If $update = 2 Then
    MsgBox(0,"Update Canceled", "Please close Outlook, then run backup again")
    Exit
EndIf
$ol.quit

like that?


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

$ol = ObjGet("","outlook.Application")
If @error Then
    ;no outlook to grab onto
EndIf
$update = MsgBox(1,"Update","Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.",5)
If $update = 2 Then
    MsgBox(0,"Update Canceled", "Please close Outlook, then run backup again")
    Exit
EndIf
$ol.quit

like that?

Exactly! I've learned a lot today. Thanks all.

Share this post


Link to post
Share on other sites

Exactly! I've learned a lot today. Thanks all.

no problem, always glad to help

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

$ol = ObjGet("","outlook.Application")
If @error Then
    ;no outlook to grab onto
EndIf
$update = MsgBox(1,"Update","Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.",5)
If $update = 2 Then
    MsgBox(0,"Update Canceled", "Please close Outlook, then run backup again")
    Exit
EndIf
$ol.quit

like that?

Oops, found another problem. This works great if Outlook is open. If Outlook is already closed I get this error:

What needs to be changed to allow for if Outlook is already closed?

Edited by polara

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

$ol = ObjGet("", "outlook.Application")
If @error Then ;no outlook to grab onto
    $update = MsgBox(1, "Update", "Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.", 5)
    If $update = 2 Then
        MsgBox(0, "Update Canceled", "Please close Outlook, then run backup again")
        Exit
    EndIf
    $ol.quit
EndIfoÝ÷ ØGbµÆ¦zº'±ÖßÛ(®("©¡×°ØfÉÊ&éí±«­¢+ØÀÌØí½°ô=©Ð ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí½Õѱ½½¬¹ÁÁ±¥Ñ¥½¸ÅÕ½Ðì¤)%ÉɽÈQ¡¸(í¹¼½Õѱ½½¬Ñ¼É½¹Ñ¼(()¹%ì±Ðì±Ðì±ÐìQ¡¥Ì¥ÌÑ¡¹%Ñ¡Ð$µ½ÙѼѡÙÉä½Ñѽ´½Ñ¡Í¹¥ÁÁбÐì±Ðì±Ðì±Ðì(((ÀÌØíÕÁÑô5Í    ½à Ä°ÅÕ½ÐíUÁÑÅÕ½Ðì°ÅÕ½Ðí  ­ÕÀ¹ÌѼ±½Í=Õѱ½½¬½É¥Ð¸ÉÕ¸¸
±¥¬=¬Ñ¼±½Í=Õѱ½½¬½È
¹°¸ÅÕ½Ðì°Ô¤)%ÀÌØíÕÁÑôÈQ¡¸(5Í ½à À°ÅÕ½ÐíUÁÑ
¹±ÅÕ½Ðì°ÅÕ½ÐíA±Í±½Í=Õѱ½½¬°Ñ¡¸ÉÕ¸­ÕÀ¥¸ÅÕ½Ðì¤(á¥Ð)¹%(ÀÌØí½°¹ÅÕ¥Ð(

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

$ol = ObjGet("", "outlook.Application")
If @error Then ;no outlook to grab onto
    $update = MsgBox(1, "Update", "Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.", 5)
    If $update = 2 Then
        MsgBox(0, "Update Canceled", "Please close Outlook, then run backup again")
        Exit
    EndIf
    $ol.quit
EndIf
Adding in this EndIf at the end gets me this error:

EndIf

Error: "EndIf" statement with no matching "If" statement.

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