Link to home
Start Free TrialLog in
Avatar of oaktrees
oaktrees

asked on

Windows Task Scheduler, Concatenate Tasks - the Easy Way?

Hi!

Found http://woshub.com/schedule-task-to-start-when-another-task-finishes/

Can't figure out the last step as it seems there's an error?  The author writes I need to edit one code for another, but they seem identical:
User generated imageWith only the first lines saying take the left and change it to the right being different.

What do you think I'm missing?

AND?!  Is there an easier / dummies-GUI way of setting two events up? (An app?)  

Running two flpidx.exe(s) for File Locator pro.

Running them in the daytime, so prefer not to run them at the same time to reduce draw on system resources.

Sincerely,

OT



Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Hi OT,

> Is there an easier / dummies-GUI way of setting two events up? (An app?)

Yes! I know you're an AutoHotkey user. A simple AutoHotkey script with two lines of code will do what you want:

RunWait,<first flpidx execution>
RunWait,<second flpidx execution>

Open in new window

The key is that RunWait waits until the target program is closed or exits (unlike Run, which immediately returns to the next line in the AHK script after launching the target program). Regards, Joe
Avatar of oaktrees
oaktrees

ASKER

Dr. J!

Wow!  So, if I follow, adding this to the AHK script I auto load with each start up should keep these two items running.  Am I right?

If yes, question is, how to code the

<first flpidx execution> 
<second flpidx execution> 

What goes inbetween those brackets?

Here is the xml -

FIRST
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{de017}" />
  <EventID>102</EventID>
  <Version>0</Version>
  <Level>4</Level>
  <Task>102</Task>
  <Opcode>2</Opcode>
  <Keywords>0x80</Keywords>
  <TimeCreated SystemTime="2020-12-06T03:53:22.3Z" />
  <EventRecordID>222</EventRecordID>
  <Correlation ActivityID="{77029384}" />
  <Execution ProcessID="1592" ThreadID="13364" />
  <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel>
  <Computer>-pbpbpb-</Computer>
  <Security UserID="nnnn" />
  </System>
- <EventData Name="TaskSuccessEvent">
  <Data Name="TaskName">\Filelocator Pro Index Update</Data>
  <Data Name="UserContext">-pbpbpb-\user</Data>
  <Data Name="InstanceId">{770}</Data>
  </EventData>
  </Event>

SECOND
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{de7b2}" />
  <EventID>102</EventID>
  <Version>0</Version>
  <Level>4</Level>
  <Task>102</Task>
  <Opcode>2</Opcode>
  <Keywords>0x80</Keywords>
  <TimeCreated SystemTime="2020-12-06T04:00:13.5Z" />
  <EventRecordID>22309</EventRecordID>
  <Correlation ActivityID="{8947c25d}" />
  <Execution ProcessID="1592" ThreadID="13364" />
  <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel>
  <Computer>-pbpbpb-</Computer>
  <Security UserID="nnnn" />
  </System>
- <EventData Name="TaskSuccessEvent">
  <Data Name="TaskName">\FL Pro Full Index Update</Data>
  <Data Name="UserContext">-pbpbpb-\user</Data>
  <Data Name="InstanceId">{894}</Data>
  </EventData>
  </Event>

Sincerely,

OT
> adding this to the AHK script I auto load with each start up should keep these two items running. Am I right?

Not exactly. It won't "keep these two items running"...it will run these two items...the second one after the first one finishes. But don't put them directly in your AutoHotkey auto-start script, because nothing else after the first RunWait will execute until it finishes. Instead, create a new AHK script (let's call it FLPindex.ahk) with these two commands in it:

RunWait,"c:\PutFullPathHere\flpidx.exe" put parameters here for first indexing run,,Hide ; of course, put in the correct path
RunWait,"c:\PutFullPathHere\flpidx.exe" put parameters here for second indexing run,,Hide; of course, put in the correct path

Open in new window


Then put this one line in your AHK auto-start script:

Run,"c:\MyAutoHotkeyScripts\FLPindex.ahk",,Hide ; of course, put in the correct path

Open in new window


Put that line at the top where it will always run, that is, not inside one of your hotkeys or hotstrings.

> how to code the <first flpidx execution> <second flpidx execution>

I don't know what the parameters need to be on the flpidx.exe command line, as I've never used FLP, but they are well-documented here:
https://help.mythicsoft.com/filelocatorpro/en/index.html?commandline.htm

It shows that the call is this (copied here under "Fair Use"):

flpidx.exe -name [index name] | -path [path to index store] | -recreate | -update | -create | -cf | -d [locations] | -ds | -f [file types] | -fd | -fm | -fma | -fnc | -verbose | -help

All of the parameters are defined there. Here are some examples that they give (copied here under "Fair Use"):
To update the 'Emails' index the command line would be:

flpidx.exe -name "Emails" -update

To recreate the index stored in 'C:\Indexes\Shared' the command line would be:
flpidx.exe -path "C:\Indexes\Shared" -recreate

To create a new index stored in 'C:\Indexes\New' the command line would be:
flpidx.exe -create -name "New Index" -path "C:\Indexes\New" -ds -fd -i
I don't use FileLocatorPro, so I can't help you with the exact calls and, of course, I can't test it. Regards, Joe
Hi Joe,

Last wrinkle...any way to let script 1 start on its own every day at 11:45am? :D

AND!  Is there a wee bit more GUI way / another app?  Seems like the AHK is powerful but...there's room for error - afraid I'll find that space too easily once I jump in! :D!

Sincerely,

OT
Hi OT,

> any way to let script 1 start on its own every day at 11:45am?

There are ways to do that with AutoHotkey, but that's really what the Windows Task Scheduler is all about. Given the method that I mentioned above, simply schedule the "master" indexing script (FLPindex.ahk) to run at 11:45am daily. If you're not familiar with how to do that, my five-minute EE video Micro Tutorial explains it:
How to use the Windows Task Scheduler - An Introduction

Note that Step 5 under the video shows the screen for setting up a task "On a schedule" that runs "Daily" at "6:00:00 AM".

> Is there a wee bit more GUI way / another app? Seems like the AHK is powerful but...there's room for error - afraid I'll find that space too easily once I jump in!

AutoHotkey has plenty of GUI support. I discuss this in my EE article:
AutoHotkey - Getting Started

Scroll down in the article to the "Graphical User Interface (GUI)" section. I show a GUI example there that has menus, edit fields, radio buttons, etc. And there's a lot more...the AutoHotkey GUI doc starts here:
https://www.autohotkey.com/docs/commands/Gui.htm

As you can see, there's a ton of GUI features there. But my question for you is: What do you want a GUI for in this particular case? I don't understand your comment "afraid I'll find that space too easily once I jump in!" I don't know what you're afraid of in this case that you think a GUI would overcome. Regards, Joe
Hi, Joe!

Let me jump into AHK's GUI after we get this one wrapped up.  Who knew?! :D

Let me see if I follow everything so far:

Timing
> ANY WAY TO LET SCRIPT 1 START ON ITS OWN EVERY DAY AT 11:45AM?
 
 THERE ARE WAYS TO DO THAT WITH AUTOHOTKEY, BUT THAT'S REALLY WHAT THE WINDOWS TASK SCHEDULER IS ALL ABOUT. GIVEN THE METHOD THAT I MENTIONED ABOVE, SIMPLY SCHEDULE THE "MASTER" INDEXING SCRIPT (FLPINDEX.AHK) TO RUN AT 11:45AM DAILY.

Got that.
 
Parameters
I DON'T KNOW WHAT THE PARAMETERS NEED TO BE ON THE FLPIDX.EXE COMMAND LINE, AS I'VE NEVER USED FLP, BUT THEY ARE WELL-DOCUMENTED HERE:
HTTPS://HELP.MYTHICSOFT.COM/FILELOCATORPRO/EN/INDEX.HTML?COMMANDLINE.HTM

Got that.
 
Step 1

You wrote:
CREATE A NEW AHK SCRIPT (LET'S CALL IT FLPINDEX.AHK) WITH THESE TWO COMMANDS IN IT:
RunWait,"c:\PutFullPathHere\flpidx.exe" put parameters here for first indexing run,,Hide ; of course, put in the correct path
RunWait,"c:\PutFullPathHere\flpidx.exe" put parameters here for second indexing run,,Hide; of course, put in the correct path

Not sure what to do here.   Here’s what I know:

Running this one first
"C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe"
-name "firstindextry" -update

Run this one when finished
"C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe"
-name "FullCDrive" -update
 
Step 2
RUN,"C:\MYAUTOHOTKEYSCRIPTS\FLPINDEX.AHK",,HIDE ; OF COURSE, PUT IN THE CORRECT PATH

This I can do, I think.  

In quotes?  Two commas?  Semicolon necessary?  Please can you paste in an example.

When I wrote "afraid I'll find that space too easily once I jump in!" I mean writing the paths correctly, commas and what not. :D

Sincerely,

OT
Based on what you provided above, here's the AutoHotkey code for the indexing script (FLPindex.ahk):

#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
FLPexe:="C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe"
MsgBox,4160,Begin Date/Time,%A_Now% ; display begin time
RunWait,"%FLPexe%" -name """firstindextry""" -update,,Hide ; update first index and wait until it finishes
RunWait,"%FLPexe%" -name """FullCDrive""" -update,,Hide ; update second index and wait until it finishes
MsgBox,4160,End Date/Time,%A_Now% ; display end time
ExitApp

Open in new window


Schedule that script (FLPindex.ahk) via the Task Scheduler to run at 11:45am.

> In quotes?

Not necessary if there are no spaces; necessary if there are spaces; good practice in any case..

> Two commas?

Yes. The Run/RunWait syntax is here:
https://www.autohotkey.com/docs/commands/Run.htm

Look at the doc carefully. You do not have a WorkingDir parameter, so you are leaving that empty...hence, the two commas...otherwise, it would think that the Options param (Hide) is the WorkingDir param.

> Semicolon necessary?

Yes, because everything after the semicolon is a comment. You may learn about comments in scripts at this doc:
https://www.autohotkey.com/docs/Language.htm#comments

> Please can you paste in an example.

Done...above.

Regards, Joe
Hi Joe,

Ah!  Thank you!  

Ok.  Have the file in place and the Task scheduled.  

There was a field in the Task Scheduler called add arguments.  Do I need any values there?
User generated image
Finally, noticed there was a value called HIDE in the script itself.  Does that mean everything will occur in the background?  Or, will I see the flpidx window pop open and run?

Sincerely,

OT
> Do I need any values there?

No. Some programs/scripts/batch files can take parameters (and/or require them), but FLPindex.ahk does not take any params.

> Does that mean everything will occur in the background?

Maybe. In most cases, the answer is yes, but some applications don't obey the requested startup state, which can be Max, Min, or Hide (see the Run/RunWait doc). I always use Hide when I don't need to see the launched program, such as a command prompt window. In this case, I figured that there's likely nothing of interest to see in the indexing app, but if you do want to see it, remove ,,Hide from the commands.

> will I see the flpidx window pop open and run?

As noted above, it depends on whether or not flpidx.exe obeys the Hide option. As also noted above, if you do want to see it, remove ,,Hide from the commands. Regards, Joe
Hi, Joe!

THIS is GREAT!

OK.  Let me remove those hides just so I can see it run all on it's own tomorrow.  That would be:

RunWait,"""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe"" -name ""firstindextry"" -update" ; update first index and wait until it finishes
RunWait,"""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe"" -name ""FullCDrive"" -update"  ; update second index and wait until it finishes

Open in new window

Am I right?

Sincerely,

OT
Right! Of course, you can try it to see if it works without having to wait until 11:45am...simply right-click the task in Task Scheduler and then click Run. Btw, I'm sure you know enough about AutoHotkey by now to know that you have to click the OK button when the MsgBox dialog appears in order for the script to continue processing. I put in the first MsgBox command just so that you would know that indexing is going to begin; and the second MsgBox command so that you would know that indexing has ended. You may, of course, remove those two MsgBox commands...or at least the first one, so that the indexing will run if you are not at your computer at 11:45am...otherwise, it will sit there at the MsgBox command waiting for you to click OK...the indexing won't begin until you do.
Hi, Joe!

You're right.  Alas...something's not right.  I used:
#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
MsgBox,4160,Begin Date/Time,%A_Now% ; display begin time
RunWait,"""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe"" -name ""firstindextry"" -update" ; update first index and wait until it finishes
RunWait,"""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe"" -name ""FullCDrive"" -update"  ; update second index and wait until it finishes
MsgBox,4160,End Date/Time,%A_Now% ; display end time
ExitApp

Open in new window

What I got was:
User generated image
And...
User generated image
Didn't see the flpidx windows open.  

Seemed like nothing was happening.  So, I ran it again. :D

Task manger said "Running"

There's some history in the task manager now.

Not sure what was happening.  So, I halted the task and deleted it.

What do you think happened?

Sincerely,

OT
There are many possibilities. The most likely is that these calls are incorrect:

C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe -name "firstindextry" -update
C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe -name "FullCDrive" -update

But I can't help you with that, as I know nothing about FLP...don't have it...can't test it here.

Try those commands by typing them into a command prompt window...do they work? If not, you'll need to figure out what the correct calls are...perhaps FLP support can help with that...or someone else here on EE who uses FLP.

If they do work in a command prompt window, then the problem may be Task Scheduler. First thing I would try is to tick the "Run only when use is logged on" radio button and the "Run with highest privileges" checkbox:

User generated image
Hi OT,
Try this code instead (different...and correct this time...handling of the quotes):

#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
FLPexe:="C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe" ; full path to flpidx.exe
MsgBox,4160,Begin Date/Time,%A_Now% ; display begin time
RunWait,"%FLPexe%" -name """firstindextry""" -update ; update first index and wait until it finishes
RunWait,"%FLPexe%" -name """FullCDrive""" -update ; update second index and wait until it finishes
MsgBox,4160,End Date/Time,%A_Now% ; display end time
ExitApp

Open in new window

This presumes that flpidx.exe requires quotes around the -name param, which is how you showed it above. That's why there are three quote marks in a row...because in AutoHotkey scripts, two consecutive quotes inside a literal string resolve to a single literal quote. Windows removes the enclosing quotes from params, so it is left with a single set of quote marks around the firstindextry and FullCDrive params, which is apparently what you want. Regards, Joe

P.S. I fixed the code in my earlier post.
Hi, Joe!

Got it.  Let me give that a try.  3pm where I am now.  Send you the results evening, your time.  Thanks for the help! :))))))))))))))))))))))

Sincerely,

OT
> 3pm where I am now.

My guess...Perth.

> Send you the results evening, your time.

I'll be here.

> Thanks for the help!

Pleasure!
Hi, Joe!

Just tried.  Saw the start box:
User generated image
And, the flpidx windows DO open, both of them - but they slam shut right away.  So, the first, opens - and starts to run but then...BOOM!  Closes itself immediately.  Thus initiating the SECOND flpidx which does the same: open; start; close.

Ah!  Seems we're soooooo close! What do you think?

Sincerely,

OT
> Saw the start box

Good news...means the script ran.

> the flpidx windows DO open, both of them

Also good news...means the RunWait commands were able to launch flpidx.exe. To be absolutely certain that the command lines are correct, use this revised script:

#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
FLPexe:="C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe" ; full path to flpidx.exe
FLPcmd1:=FLPexe . " -name ""firstindextry"" -update" ; complete first command for RunWait
FLPcmd2:=FLPexe . " -name ""FullCDrive"" -update" ; complete second command for RunWait
MsgBox,4160,Begin FLP Indexing,Beginning Date/Time: %A_Now%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2% ; display begin time and FLP commands
RunWait,"%FLPcmd1%" ; update first index and wait until it finishes
ReturnCodeCmd1:=ErrorLevel
RunWait,"%FLPcmd2%" ; update second index and wait until it finishes
ReturnCodeCmd2:=ErrorLevel
MsgBox,4160,End FLP Indexing,Ending Date/Time: %A_Now%`n`nReturn Code from first command: %ReturnCodeCmd1%`n`nReturn Code from second command: %ReturnCodeCmd2% ; display end time and return code from both commands
ExitApp

Open in new window

There are two improvements in the new script:

(1) It shows in the opening MsgBox the full commands that RunWait will execute. Let me know if the commands look correct.

(2) It shows in the closing MsgBox the return codes from flpidx.exe. However, the Mythicsoft site does not document any return codes, so this may be meaningless, but it's worth a shot. In any case, let me know what return codes that the closing MsgBox shows.

> they slam shut right away

Could mean a bad call to flpidx.exe, such as bad parameters. To take AutoHotkey and Task Scheduler out of the picture, run the flpidx.exe commands in a command prompt. To do that, you need quotes around the path, i.e., type this into the command prompt window:

"C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe" -name "firstindextry" -update

Open in new window

And then the second one:

"C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe" -name "FullCDrive" -update

Open in new window

Keep in mind that I have no idea if those params to flpidx.exe are correct...I'm basing those commands on what you posted. Let me know what happens with those commands when run in a command prompt windows.

One other thought...I have a gut feel that the quotes should not be around the -name param. If the new script above fails, try this one:

#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
FLPexe:="C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe" ; full path to flpidx.exe
FLPcmd1:=FLPexe . " -name firstindextry -update" ; complete first command for RunWait
FLPcmd2:=FLPexe . " -name FullCDrive -update" ; complete second command for RunWait
MsgBox,4160,Begin FLP Indexing,Beginning Date/Time: %A_Now%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2% ; display begin time and FLP commands
RunWait,"%FLPcmd1%" ; update first index and wait until it finishes
ReturnCodeCmd1:=ErrorLevel
RunWait,"%FLPcmd2%" ; update second index and wait until it finishes
ReturnCodeCmd2:=ErrorLevel
MsgBox,4160,End FLP Indexing,Ending Date/Time: %A_Now%`n`nReturn Code from first command: %ReturnCodeCmd1%`n`nReturn Code from second command: %ReturnCodeCmd2% ; display end time and return code from both commands
ExitApp

Open in new window

The only difference is that I removed the quotes around the -name params (firstindextry and FullCDrive). Regards, Joe
Hi Joe,
Ah!  Tried both.  Results:

User generated image

And...
User generated imageSincerely,

OT
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, Dr. J!

Used this and...worked like a charm! :D

This is the one with the -name param enclosed in quotes: 
#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
FLPexe:="""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe""" ; full path to flpidx.exe enclosed in quotes
FLPcmd1:=FLPexe . " -name ""firstindextry"" -update" ; complete first command for RunWait
FLPcmd2:=FLPexe . " -name ""FullCDrive"" -update" ; complete second command for RunWait
MsgBox,4160,Begin FLP Indexing,Beginning Date/Time: %A_Now%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2% ; display begin time and FLP commands
RunWait,%FLPcmd1% ; update first index and wait until it finishes
ReturnCodeCmd1:=ErrorLevel
RunWait,%FLPcmd2% ; update second index and wait until it finishes
ReturnCodeCmd2:=ErrorLevel
MsgBox,4160,End FLP Indexing,Ending Date/Time: %A_Now%`n`nReturn Code from first command: %ReturnCodeCmd1%`n`nReturn Code from second command: %ReturnCodeCmd2% ; display end time and return code from both commands
ExitApp

Open in new window

When I see how kindly you help folks resolve even the most nettlesome questions, I feel impressed, and grateful.

Thank you, JOE!

Sincerely,

OT
You're welcome, OT, and thanks back at you for the kind words and the Testimonial...both very much appreciated! Regards, Joe
:D!
Hi, Joe!

Please one request - can you think of a way to edit the script so that it starts running out of the gate?  Right now an "OK?" box opens at the start and if I'm away from my desk for one of those 3-martini lunches then it won't run during the target window until I get back to the work bench.

What do you think?

Sincerely,

OT
Hi OT,
The last parameter (optional) on the MsgBox command is Timeout (in seconds). After the timeout period has elapsed, the message box will be automatically closed. For example, to have the MsgBox automatically close after 30 seconds, change it to this:

MsgBox,4160,Begin FLP Indexing,Beginning Date/Time: %A_Now%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%,30 ; display begin time and FLP commands

Open in new window

Change the 30 to whatever number of seconds you prefer, allowing you to enjoy those 3-martini lunches with no guilt...at least, not with respect to your daily indexing run. :)

Another idea, of course, is...simply delete the MsgBox command! I put it in initially so that you could see (1) the actual indexing commands and (2) how long it took to do the indexing (when coupled with the closing MsgBox command).

Yet another idea is to leave the opening MsgBox (or not) and put all the info in the closing MsgBox. In other words, delete the first MsgBox command (or not, but put the timeout on it), add a BeginTime variable at the top, then change the closing MsgBox. Here's a revised script with that approach:

#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
FLPexe:="""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe""" ; full path to flpidx.exe enclosed in quotes
FLPcmd1:=FLPexe . " -name ""firstindextry"" -update" ; complete first command for RunWait
FLPcmd2:=FLPexe . " -name ""FullCDrive"" -update" ; complete second command for RunWait
MsgBox,4160,Begin FLP Indexing,Beginning Date/Time: %A_Now%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%,30 ; display begin time and FLP commands
BeginTime:=A_Now
RunWait,%FLPcmd1% ; update first index and wait until it finishes
ReturnCodeCmd1:=ErrorLevel
RunWait,%FLPcmd2% ; update second index and wait until it finishes
ReturnCodeCmd2:=ErrorLevel
EndTime:=A_Now
MsgBox,4160,End FLP Indexing,Beginning Date/Time: %BeginTime%`nEnding Date/Time: %EndTime%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%`n`nReturn Code from first command: %ReturnCodeCmd1%`n`nReturn Code from second command: %ReturnCodeCmd2% ; display begin time, end time, both command lines, and return code from both commands
ExitApp

Open in new window

Cheers, Joe
Hi, JOE!

Ah!  Third way looks SHARP!  Thanks, mate!  I'll post results.

Sincerely,

OT
Looking forward to seeing your results.
Brother J!

Used the third way and...it ran just like our solution version.

#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
FLPexe:="""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe""" ; full path to flpidx.exe enclosed in quotes
FLPcmd1:=FLPexe . " -name ""firstindextry"" -update" ; complete first command for RunWait
FLPcmd2:=FLPexe . " -name ""FullCDrive"" -update" ; complete second command for RunWait
MsgBox,4160,Begin FLP Indexing,Beginning Date/Time: %A_Now%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%,30 ; display begin time and FLP commands
BeginTime:=A_Now
RunWait,%FLPcmd1% ; update first index and wait until it finishes
ReturnCodeCmd1:=ErrorLevel
RunWait,%FLPcmd2% ; update second index and wait until it finishes
ReturnCodeCmd2:=ErrorLevel
EndTime:=A_Now
MsgBox,4160,End FLP Indexing,Beginning Date/Time: %BeginTime%`nEnding Date/Time: %EndTime%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%`n`nReturn Code from first command: %ReturnCodeCmd1%`n`nReturn Code from second command: %ReturnCodeCmd2% ; display begin time, end time, both command lines, and return code from both commands
ExitApp

Open in new window


I was thinking it would run as:

Auto start - opens & engages / starts indexing right away.

Then, the results box is all that's left once I return?

What do you you think I did wrong?

Sincerely,

OT


> Auto start - opens & engages / starts indexing right away.

Not exactly. It has the 30-second delay in the first MsgBox command. If you don't click the OK button manually, indexing will start in 30 seconds. Of course, change 30 to whatever number of seconds you prefer...or simply delete the first MsgBox command.

> Then, the results box is all that's left once I return?

Yes, the results MsgBox does not have a timeout param on it, so it will stay on the screen until you click the OK button manually.

> What do you you think I did wrong?

If you're telling me that the new one behaves the same as the old one, then my guess is that you are not actually running the new one...you're running the old one. Regards, Joe

Update: Here's an enhanced version of the most recent script. This new one calculates the elapsed time (in minutes and seconds) that it took for both indexing runs (I thought that would be helpful for you):

#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed
FLPexe:="""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe""" ; full path to flpidx.exe enclosed in quotes
FLPcmd1:=FLPexe . " -name ""firstindextry"" -update" ; complete first command for RunWait
FLPcmd2:=FLPexe . " -name ""FullCDrive"" -update" ; complete second command for RunWait
MsgBox,4160,Begin FLP Indexing,Beginning Date/Time: %A_Now%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%,30 ; display begin time and FLP commands
BeginTime:=A_Now
RunWait,%FLPcmd1% ; update first index and wait until it finishes
ReturnCodeCmd1:=ErrorLevel
RunWait,%FLPcmd2% ; update second index and wait until it finishes
ReturnCodeCmd2:=ErrorLevel
EndTime:=ElapsedTime:=A_Now
EnvSub,ElapsedTime,%BeginTime%,Seconds
Minutes:=Floor(ElapsedTime/60)
Seconds:=SubStr("00" . Mod(ElapsedTime,60),-1)
MsgBox,4160,End FLP Indexing,Beginning Date/Time: %BeginTime%`nEnding Date/Time: %EndTime%`nElapsed Time (minutes:seconds): %Minutes%:%Seconds%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%`n`nReturn Code from first command: %ReturnCodeCmd1%`n`nReturn Code from second command: %ReturnCodeCmd2% ; display begin time, end time, both command lines, and return code from both commands
ExitApp

Open in new window

Of course, in order to calculate the ElapsedTime variable, it uses the BeginTime and EndTime variables that I introduced in the previous version. The closing/results dialog now looks like this:

User generated image
Regards, Joe
Hi, Joe!

Ah!  The ORIGINAL revised one works!  I didn't understand that there's be that wee countdown before it was off to the races.  Feel bad that you went to the extra trouble to revise further.  Feel grateful for the in-depth help.  

The indexing has been SUCH a boon to me, which is all back to the CLEAR explanations you gave here: https://www.experts-exchange.com/questions/29186579/Explorer-Replacement-With-Super-Fast-File-Finding-Good-Privacy-Reputation.html  Really making the daily office grind EASIER!  Thanks, JOE!

Sincerely,

OT
Hi OT,

> The ORIGINAL revised one works!

Glad to hear it.

> Feel bad that you went to the extra trouble to revise further.

Wasn't much trouble...and I figured that doing the elapsed time calculation in the script (and displaying it) would be helpful.

> Feel grateful for the in-depth help.

You're very welcome.

> the CLEAR explanations you gave here

Yes, that was a very interesting thread!

Regards, Joe
Hi OT,
Here's a minor revision of the script:

#NoEnv                ; prevent empty variable from being looked up as environment variable
#Warn,UseUnsetLocal   ; warn when local variable is read without having been assigned a value
#SingleInstance Off   ; allow multiple instances to run concurrently
SetBatchLines,-1      ; never sleep, run at maximum speed

StartupDelay:=30 ; *** timeout value (in seconds) for first MsgBox - change this to whatever you want ***

FLPexe:="""C:\Program Files\Mythicsoft\FileLocator Pro\flpidx.exe""" ; full path to flpidx.exe enclosed in quotes
FLPcmd1:=FLPexe . " -name ""firstindextry"" -update" ; complete first command for RunWait
FLPcmd2:=FLPexe . " -name ""FullCDrive"" -update" ; complete second command for RunWait
MsgBox,4160,Begin FLP Indexing,Indexing begin date/time (before startup delay): %A_Now%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%,%StartupDelay% ; display begin time and FLP commands
BeginTime:=A_Now
RunWait,%FLPcmd1% ; update first index and wait until it finishes
ReturnCodeCmd1:=ErrorLevel
RunWait,%FLPcmd2% ; update second index and wait until it finishes
ReturnCodeCmd2:=ErrorLevel
EndTime:=ElapsedTime:=A_Now
EnvSub,ElapsedTime,%BeginTime%,Seconds
Minutes:=Floor(ElapsedTime/60)
Seconds:=SubStr("00" . Mod(ElapsedTime,60),-1)
MsgBox,4160,End FLP Indexing,Indexing begin date/time: %BeginTime%`nIndexing end date/time: %EndTime%`nIndexing elapsed time (minutes:seconds): %Minutes%:%Seconds%`n`nFLP first command:`n%FLPcmd1%`n`nFLP second command:`n%FLPcmd2%`n`nReturn Code from first command: %ReturnCodeCmd1%`n`nReturn Code from second command: %ReturnCodeCmd2% ; display begin time, end time, both command lines, and return code from both commands
ExitApp

Open in new window

Key change is to put the startup delay (in seconds), i.e., the timeout param for the first MsgBox command (what you called the "wee countdown") into a variable at the top of the script so that you don't have to mess around with the MsgBox command itself in order to change it (this is better programming practice). I set it to 30 (seconds), but, of course, change it to whatever you want. I also improved the language on dealing with the indexing begin and end times. Regards, Joe