autorun-plugin, next problem

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
georgeb
Senior Member
Senior Member
Posts: 253
Joined: 2021-04-30, 13:25 UTC

autorun-plugin, next problem

Post by *georgeb »

After studying the help-file I came across a command called
"ProcessExist [/F] [/EV-] <process>"
which sounded to be exactly what I needed.

My intention was to look for an active process and do nothing if it was already there but to start it in case it wasn't already running.

So in absence of dedicated examples I thought the following statements should work:

Code: Select all

If Not ProcessExist(processname.exe) Then
CommandExec em_stProcessXXX     ###(the em_command had already proven to work correctly)
Else
MsgBox "ProcessXXX running"
Endif
But all I got was the error-message:
Autorun plugin error
Error in command at line [28]:
Right value is not boolean: not ProcessExist
To make it boolean I then tried

Code: Select all

If ProcessExist(processname.exe) = 0 Then
but to no avail. Of course I've tried numerous variants. "ProcessExist" with the ProcessName in parenthesis and without, the numerical comp.-value with and without quotes. I also tried to introduce a variable into the ProcessExist-command which is given as a second variant in the help-file and then tried to compare that variable in the if-clause. But so far all attempts have failed in a colossal manner. Printing out that variable initially set to 500 always showed 500 again so the "ProcessExist"-command never changed that variable to either "0" or "1" as expected.

I'm running out of options and ideas to make that work. Any ideas or input from the autorun-specialist in this forum would be highly appreciated.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6489
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: autorun-plugin, next problem

Post by *Horst.Epp »

From the readme.en

Code: Select all

Process
-------
This plugin will contain additional functions for working with processes.

ProcessExist [/F] [/EV] <variable name> <process name>
ProcessExist [/F] [/EV] <process name>
Function available for direct calling and using in conditional. When direct calling, first mandatory parameter should be variable name, which will receive 0 or 1, depending on function result.
[/F] - compare process by full path.
[/EV] - enbables using environment variable in text.
So I guess you have to make

ProcessExist [/F] [/EV] <variable name> <process name>

and later use the the <variable name> in your If statement.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
georgeb
Senior Member
Senior Member
Posts: 253
Joined: 2021-04-30, 13:25 UTC

Re: autorun-plugin, next problem

Post by *georgeb »

Horst.Epp wrote: 2022-08-16, 15:16 UTC So I guess you have to make
ProcessExist [/F] [/EV] <variable name> <process name>
and later use the the <variable name> in your If statement.
As described above I already did try this. But your readme says that ProcessExist can also be used without a variable
"and using in conditional" - but that did not work.

When then trying to do it via direct call (via CommandExec?) with a variable-name specified (as you suggested) I got the error that no such variable existed.

So I assumed the variable needed to be declared separately first. I did so with the Set-command and set it to 500 initially to make it distinguishable from the expected values "0" and "1" to be allocated later by the ProcessExist-command. But unfortunately it always remained at 500 - so presumably ProcessExist didn't work at all.

Could you please perhaps come up with a VERBATIM suggestion for the script actually needed by your suggestion as I always am uncertain (about the help) if and when/where to use "<", ">", "(" ,")", "%", "%var%" and double or single quotes themselves in order to formulate a syntactically precise statement?
georgeb
Senior Member
Senior Member
Posts: 253
Joined: 2021-04-30, 13:25 UTC

Re: autorun-plugin, next problem

Post by *georgeb »

Ok, folks, problem solved.

In some Heureka-moment it crossed my mind that the command
"ProcessExist [/F] [/EV] <variable name> <process name>"
in the autorun-help-file was listed in a sub-category "Plugins" itself. It might have been positioned there for some reason. So I checked the header-category for plugins again. And there it was. Such further plugins fall into some kind of sub-plugin-category and therefore in order to use them in a script need to be incorporated/declared via the LoadLibrary-command first!

With that crucial info to finally making the script work was easy. The following entries in autorun.cfg will do the trick:

Code: Select all

.
.
.
LoadLibrary Plugins\Autorun_Process.dll64
.
.
If ProcessExist (ProcessName.exe) = 0 Then
CommandExec em_startProcessName
Else
MsgBox "ProcessName running"
Endif
Hope that newly found insight might be of interest for future "autorun-apprentices". :wink:
Fla$her
Power Member
Power Member
Posts: 2308
Joined: 2020-01-18, 04:03 UTC

Re: autorun-plugin, next problem

Post by *Fla$her »

2georgeb
Why do you need em_startProcessName here if there is a ShellExec?
Overquoting is evil! 👎
georgeb
Senior Member
Senior Member
Posts: 253
Joined: 2021-04-30, 13:25 UTC

Re: autorun-plugin, next problem

Post by *georgeb »

Fla$her wrote: 2022-08-17, 14:41 UTC 2georgeb
Why do you need em_startProcessName here if there is a ShellExec?
The em_start-command just calls "schtasks.exe" which in return will be able to launch some dedicated Win10-task manually that starts the desired process with admin-privileges yet without triggering the UAC-prompt.

And so you are right, "schtasks" could as well be executed directly via ShellExec-command. The reason for interposing an em_command here is just versatility and the desire to streamline commands a bit. By that way I can easily execute the very same command (in some kind of modular fashion, if you will) for example also via TC-button or through another script without having to declare this recurring "schtasks-call-procedure" anew from scratch again and again.
Fla$her
Power Member
Power Member
Posts: 2308
Joined: 2020-01-18, 04:03 UTC

Re: autorun-plugin, next problem

Post by *Fla$her »

2georgeb
It's clear. But I have long made it a rule that the fewer intermediaries, the faster the task is completed.
Overquoting is evil! 👎
Post Reply