Jump to content

ProcessClose help


Recommended Posts

HI,

no this code is correct. Show yours and we'll find the mistake. :D

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

Link to comment
Share on other sites

HI,

no this code is correct. Show yours and we'll find the mistake. :D

So long,

Mega

Ok, here is what I have. As you can see, I am using the RUNWAIT command to call a .cmd file on a server share that has my Robocopy script that runs the actual backup. Later I will figure out how to rewrite it to run in AutoIt. One step at a time for now. Again, this runs perfectly if Outlook is open or if you click Cancel, but errors if you click Ok when Outlook is already closed.

; Backup Job

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

If @error Then

;no outlook to grab onto

EndIf

$update = MsgBox(1,"Backup","Backup needs to close Outlook before it can run. Click

Ok to close Outlook or Cancel if you do not want to close Outlook at this time.")

If $update = 2 Then

MsgBox(0,"Backup", "Backup has been canceled.")

Exit

EndIf

$ol.quit

EndIf

RUNWAIT("\\server\share\Backup\Scripts\dbu.cmd")

MsgBox(0,"Backup","Backup has finished. Please remember to run backup

regularly.")

Link to comment
Share on other sites

What happens if you change the line ";no outlook to grab onto" into "$ol = ObjCreate("outlook.Application")" ?

Edit: my mistake. I see you want Outlook closed, not opened...

Edited by MHz
Link to comment
Share on other sites

What happens if you change the line ";no outlook to grab onto" into "$ol = ObjCreate("outlook.Application")" ?

If I make this change AND remove the EndIf after $ol.quit, it seems to work as I want. Thanks!

Link to comment
Share on other sites

If I make this change AND remove the EndIf after $ol.quit, it seems to work as I want. Thanks!

Well, this is interesting. Adding "$ol = ObjCreate("outlook.Application")" is making things work because it's somehow opening an instance of outlook.exe but not actually opening the outlook interface. A little background here: The whole reason for all this concern about closing outlook is so that the outlook .pst files can be backed up. Normally, .pst files are "locked" when outlook is open and cannot be backed up. So this is why outlook must be closed first. Somehow, "$ol = ObjCreate("outlook.Application")" is opening an instance of outlook without opening or locking any .pst files, then closing outlook.exe when it's done (when Ok is clicked in the final MsgBox) Strange!!

Edited by polara
Link to comment
Share on other sites

Adding in this EndIf at the end gets me this error:

EndIf

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

I only moved one EndIf.

(Edit: I did not add an EndIf.)

See edited post above...

Stick with ObjGet

Edited by herewasplato

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

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...