Command line interface ES cannot talk to Everything if run from a scheduled task

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
pistacho
Posts: 2
Joined: Sat Feb 23, 2019 7:21 pm

Command line interface ES cannot talk to Everything if run from a scheduled task

Post by pistacho » Sat Feb 23, 2019 7:41 pm

Hello,

I've downloaded Everything v1.4.1.935 (x64) and installed it as a service, from a regular user (non administrative) account on a Windows 10 Pro machine.

I've also downloaded its command line interface ES v1.1.0.10, and unzipped it at C:\test

If I launch an elevated (run as Administrator) command line window (cmd.exe), and then I type the following:

Code: Select all

C:\test\es.exe -export-csv C:\test\txt.csv *.txt
I get a file named C:\test\txt.csv which contains a list of every TXT file, as expected.

However, if I run the task scheduler as Administrator and create a scheduled task where I define an action to run the very same command I previously mentioned, then ES creates a CSV file which only contains the header (one line that says Filename).

If I create a batch file with that command, and run that BAT as an action of my scheduled task, I only get the Filename header again.

Finally, if I create a batch file with this command:

Code: Select all

C:\test\es.exe *.txt > C:\test\txt.csv
and run that BAT as an action of my scheduled task, then the content of C:\test\txt.csv is one line that says:

Code: Select all

Everything IPC window not found, IPC unavailable.
However, if I dig on the Everything.ini files there's a line that says

Code: Select all

ipc=1
Which was expected, as when I run the ES tool manually it actually does find the TXT files.

The results don't change despite I've tried to modify all the setting of the scheduled task: checking and unchecking the "Run with highest privileges" checkbox, checking and unchecking the "Hidden" checkbox, etc.

I've found that if I launch Everything from the batch file then ES works perfectly, but this leaves Everything.exe running, and the task never gets finished on the scheduler.

Could someone please tell me what is the proper way to run ES from a scheduled task?

Thank you.

NotNull
Posts: 2028
Joined: Wed May 24, 2017 9:22 pm

Re: Command line interface ES cannot talk to Everything if run from a scheduled task

Post by NotNull » Sat Feb 23, 2019 9:00 pm

First of all: thank you for a very thorough description of your issue! Makes finding an answer a lot easier..

ES.exe needs Everything.exe running, as it passes your search request to Everything.exe, which in return will look in it's database and pass the matching results back to ES.exe.

So a script that:
- starts Everything
- Executes your ES command
- Ends Everything.exe

should do the job. But ....


When Everything is started, the first thing it does is updating it's database with new changes to the filesystem since Everything ran for the last time.
During this update process, Everything is not able to process your ES.exe command.
There is no easy way to know when Everything is done updating, but it is doable with a little workaround:

Code: Select all

"c:\path to\Everything.exe" -startup & start /w "" "c:\path to\Everything.exe" -update
C:\test\es.exe -export-csv C:\test\txt.csv *.txt
"c:\path to\Everything.exe" -quit
(not tested, btw)

For a little background information, see viewtopic.php?t=6632


Note:
This is step 1, as this will also quit your "normal" Everything program. Solution to that is using a separate instance.
But let's see first if this comes a bit closer to your goal.

pistacho
Posts: 2
Joined: Sat Feb 23, 2019 7:21 pm

Re: Command line interface ES cannot talk to Everything if run from a scheduled task

Post by pistacho » Sat Feb 23, 2019 10:43 pm

Thank you very much for your quick response!

I forgot to say that I had also tried to install the Everything client service (and start it), but my results where the same.

Your solution works perfectly. Curiously enough the batch of the scheduled task initiates another Everything.exe process (which doesn't conflict with the one that the regular user may already be running), and it gets closed when the batch invokes the -quit parameter (while the regular user Everything.exe process keeps running). So there's no need to use instances in this particular case.

Thank you very much!

However, I don't understand why the elevated command prompt ES execution (which runs as the Administrator user) does see the regular user Everything.exe process so it can use IPC to query the database, but the batch from the scheduled task (which is also supposed to run as Administrator) cannot talk to so it needs to launch its own Everything.exe process. Do you know why does this happen?

Thank you again.

therube
Posts: 2537
Joined: Thu Sep 03, 2009 6:48 pm

Re: Command line interface ES cannot talk to Everything if run from a scheduled task

Post by therube » Sun Feb 24, 2019 12:10 pm

(Guessing, I'd say the scheduled task is actually running at a different privilege level?)

void
Site Admin
Posts: 5366
Joined: Fri Oct 16, 2009 11:31 pm

Re: Command line interface ES cannot talk to Everything if run from a scheduled task

Post by void » Mon Feb 25, 2019 1:50 am

Everything and ES use ChangeWindowMessageFilterEx to allow each other to communicate between administrator and standard user and vice versa.

However, if you create a scheduled task with a different user that is not logged in, then that task will run in a new session and will not be able to access the Everything IPC window.

For example, if you are logged in as a standard user, and create a scheduled task to run with a administrator user account, the task will run in a different session.

Programs can not use windows to communicate between different sessions.

Please make sure the scheduled task runs as the same user that is currently logged in.
Please make sure Run only when user is logged on is checked.
Please check Run with highest privileges if you want ES to run as administrator. However, please note if you want to enable this you will need to run Scheduled Tasks as an administrator.

Post Reply