Page 1 of 2
Task Scheduler
Posted: Mon Mar 04, 2019 2:21 am
by elektroinside
Hi,
First of all, thank you for this wonderful piece of software! It's been helping me out in home automation.
I cannot start Push2Run from the windows task scheduler anymore, with the last update. I've been using a task to run Push2Run with admin privileges when the user logs on, to skip UAC consent, but now it's just a zombie process in task manager and it doesn't work. I have to kill it and manually start it and then give admin privileges. This worked great with the last public version.
Is there any way to fix this?
Many thanks!
Re: Task Scheduler
Posted: Mon Mar 04, 2019 6:47 am
by RobLatour
You're very welcome, and I'm glad the program is being of good use to you.
Rather than starting Push2Run from task scheduler, try starting Push2RunReloader with the command line parameter "StartAdim" without the quotes (and note there is no space between the words Start and Admin).
As an example, here is how it would put in a .bat file:
"C:\Program Files\Push2Run\Push2RunReloader.exe" StartAdmin
Re: Task Scheduler
Posted: Mon Mar 04, 2019 8:12 am
by elektroinside
Thank you for the speedy reply.
Just a quick feedback.. I tried this in a few ways:
1. Add this directly in task scheduler (elevated)
2. Add this in a batch file and run it as an elevated logon task
3. Run a task which elevates cmd first, then open the batch file
Each method triggered the UAC consent. I'll do some more digging, maybe my initial elevation (in task scheduler) fails for some reason.
Thank you,
Peter
Re: Task Scheduler
Posted: Sat Apr 11, 2020 6:02 am
by pho08
hi i just wanted to enquire if there is an update on this problem?
i am trying to run push2run with admin priviledges on startup (to prevent the UAC prompt) but get the same error message from task scheduler
this is the error i am getting
sorry for German, it basically says that the system cannot find the file.
any help would be much appreciated.
oh and thank you for this awesome app!
Re: Task Scheduler
Posted: Sat Apr 11, 2020 8:35 am
by RobLatour
Ok, so I was able to find a way to do this using PowerShell (Push2Run with admin privileges and no UAC prompt at logon):
First, I created the following file: c:\temp\psPush2Run.ps1
containing:
Code: Select all
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
start "c:/program files/push2run/push2run.exe"
Next. I created a task in task scheduler, to run the above script at log on. Here is the export of that:
Code: Select all
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2020-04-11T07:41:55.9591295</Date>
<Author>ROBSPC\Rob Latour</Author>
<URI>\Custom Latour\auto start push2run with admin priviledges</URI>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
<UserId>ROBSPC\Rob Latour</UserId>
</LogonTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-3427217150-94990888-4251067415-1001</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe</Command>
<Arguments>C:\Temp\psPush2Run.ps1</Arguments>
<WorkingDirectory>c:\program files\push2run\</WorkingDirectory>
</Exec>
</Actions>
</Task>
(of note, I was getting an error similar to yours if I didn't include the working directory, so be sure to include that in the above)
Finally, I checked the following two options in the Push2Run - Options - Startup window:
- automatically start Push2Run when you log onto Windows
- when automatically starting at Windows log on use administrator privileges
Hope this helps,
Rob
Re: Task Scheduler
Posted: Sun Apr 12, 2020 5:37 am
by pho08
whoa thanks so much Rob!
i didn't expect an answer for digging out such an old thread, much less so quick!
it works like a charm, after i edited paths/users/changed policy for script execution.
maybe one more purely cosmetic thing: suppose it's not possible to suppress the 'ugly' powershell box that now pops up at logon or is it?
anyway thanks again!
Re: Task Scheduler
Posted: Sun Apr 12, 2020 8:12 am
by RobLatour
your very welcome, glad it's working for you.
Regarding hiding the powerscript window, at first, I tried checking the 'Hidden' option in the General tab of the task in task schedule - but that did not work.
Then I tried several combinations of the ideas here:
https://github.com/PowerShell/PowerShell/issues/3028
However, sadly I couldn't find the right combination to suppress the powerscript window.
If you have better luck and find a solution, I'd appreciate it if you could post it here.
Re: Task Scheduler
Posted: Sun Apr 12, 2020 9:59 am
by pho08
thanks again for the reply
a preliminary search returned this idea:
Code: Select all
open the task in task scheduler and check "Run whether user is logged on or not". Now the powershell box is not displayed on startup
(taken from:
https://stackoverflow.com/questions/180 ... g-a-window)
Alas...if i do this while the powershell window is indeed hidden, push2run.exe isn't isn't started either. Will have another look at it tonight with more time at hand but maybe it's possible to combine the two
Re: Task Scheduler
Posted: Fri Apr 17, 2020 7:24 am
by pho08
quick update on this:
@Rob i am afraid that i was too quick to be excited. While the original workaround you posted works to run Push2Run on startup with admin priv without UAC prompt, i am afraid that push2run itself doesn't really work when it is initialized like this (at least for me)..
So what happens is that if i run the app in the aforementioned way then any voice command i give will be acknowledged by pushover and push2run BUT executing it fails, returning
Code: Select all
"the action was run but appears to have failed"
Sometimes the very first command i give works but any subsequent commands will return the error.
As soon as i quit Push2run and restart it manually , everything works as expected.
Cheers,
Thomas
Re: Task Scheduler
Posted: Fri Apr 17, 2020 8:30 am
by RobLatour
is the 'Admin privileges' option checked on the Push2Run card that you are running?