Schedule background app - raspberry-pi3

So I have my application deployed to my Raspberry Pi 3 that is running win10 IoT, and I want to use schtasks to run it at certain times. Where is my application "deployed" to on the device so I can add it to a scheduled task?
Edit:
Found the app, but I can't seem to create a scheduled task to run the .winmd file.
This is what I tried:
schtasks /create /tn feedertest /sc minute /ru administrator /rp notrealpwd /mo 5 /tr "c:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\CatFeeders-uwpVS.Debug_ARM.greg\catfeeders.winmd"

WINMD file is not an executable file for running the UWP application, it is a binary file of Windows Runtime Metadata.
You need to use IotStartup command to run the UWP application on Windows IoT Core. Please refer to following command:
Update:
#create the task
schtasks /create /tn feedertest /sc minute /ru administrator /rp notrealpwd /mo 1 /tr "IotStartup add headed <your app package family name>"
#run the task
schtasks /Run /TN feedertest
BTW, you can get how to get app package family name from here.

Thank you for the help, but it looks like Windows IoT isn't the right platform for what I'm trying to do. :(
I switched Raspbian, wrote about 20 lines of python, and added it to the crontab.

Related

Could not access schtasks(Task Scheduler) when the service is running as local system account

I read that Local system Account has maximum privileges to access all the local resources.
But still I could not create a scheduler task while running my application as a service.
When I run my application as administrator(cmd),I was able to create a scheduler task
schtasks /create /sc minute /mo 20 /tn "Tesk Check" /tr "C:\run.bat"
When I run this command as a service,I got this error
No mapping between account names and security IDs was done
Did I miss anything?

Is there a ruby gem to start/stop Windows Scheduled Tasks?

I'm looking for a ruby gem that can start/stop an already running windows scheduled tasks. Or if a gem does not exist, another work around for doing such a thing.
I believe I found the best answer, but someone else can please correct me if I'm wrong. I think my best option is to just send a command using the Windows CLI.
Looking at the windows the windows documentation it appears the command to stop a task in Windows CLI is schtasks /End [/S <system> [/U <username> [/P [<password>]]]] /TN taskname.
The command to start a task is schtasks /Run [/S <system> [/U <username> [/P [<password>]]]] /TN <taskname>.
So, with those two things in mind, in the ruby script I can use %x(windows cli command), system 'windows cli command', with varying levels of returned data. I believe there's some more from what I was reading, but I think that will work. Again, if anyone has comments or a better plan on action for what I'm trying to do, definitely all ears.

Create a scheduled task that runs on particular user login using commandline

I have the requirement to create a scheduled tasks that runs once when a particular user logs on. The intention is to start a task only for a particular user.
I know that I can use the Task Scheduler to create a Task with a trigger At log on and under Settings, I specify the particular user.
However, because I need this created during an install routine, it must be created automatically, using the command line, for example using the schtasks command. It is possible to create a task executed at log on using the following example:
schtasks /Create /TR executable.exe /RU user /TN name /SC ONLOGON
But I did not find any modifier to specify a particular user for the ONLOGON trigger.
Resources:
http://technet.microsoft.com/en-us/library/bb490996.aspx
http://ss64.com/nt/schtasks.html
Do you know if there is any undocumented switch? Or any other commandline tool that provides the necessary features?
Thanks.
Add the option "/IT" to the schtasks /create command, e.g:
schtasks /Create /TR executable.exe /RU user /TN name /SC ONLOGON /IT
As mentioned at https://technet.microsoft.com/en-us/library/cc725744(v=ws.11).aspx "the /it parameter to indicate that the task runs only when the (specific user) is logged on"
You should disregard the Task Scheduler GUI where "At log on of any user" is mentioned and actually try rebooting your device. You'll find that the specific command is only run when you log in with the (specific user)'s account.
Best way is to simply import an XML via the schtasks command line. Here is a sample that runs "calc.exe" as bob, whenever bob logs in:
<?xml version="1.0" encoding="UTF-16" ?>
- <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
- <RegistrationInfo>
<Date>2014-10-22T01:50:13</Date>
<Author>user</Author>
</RegistrationInfo>
- <Triggers>
- <LogonTrigger>
<StartBoundary>2014-10-22T01:50:00</StartBoundary>
<Enabled>true</Enabled>
<UserId>WIN7BOX\bob</UserId>
</LogonTrigger>
</Triggers>
- <Principals>
- <Principal id="Author">
<UserId>bob</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</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>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
- <Actions Context="Author">
- <Exec>
<Command>calc.exe</Command>
</Exec>
</Actions>
</Task>
I'm not aware of any such option. Unfortunately the schtasks command does not cover all features Task Scheduler 2.0 provides. You could accomplish this with a VBScript using the Task Scheduler Scripting Objects, however, it deems me quite troublesome to (ab)use Task Scheduler for something that could be achieved far easier with a Startup shortcut, a registry entry in the user's Run key, or a logon script.
This works.
SchTasks /Create /SC DAILY /TN “abcMyTask” /TR “C:RunMe.bat” /ST 09:00 /IT /S /U testuser /P password#123
Create a new user (here I created testuser from my local Windows system).
On your local machine it does not work. Try to run the command from another Windows system with the username testuser and password. It creates a scheduled task remotely.

Can't install memcached 1.4.5 as a service on Windows

Last night someone told me about memcached. It seems something I can really use to reduce loading times. So today I wanted to download the latest version 1.4.5 for Windows. I found a precompiled version and wanted to use that. However as of version 1.4.5 the -d parameter for Windows has been dropped? And I can't install it as a service.
I tried to install it via SC, and that worked, but then when i tried to start it there came an error message that:
The service is not responding to the control function.
I don't really know what to do now. Can I still use this on Windows as a non-service, or should I get the much older version 1.2.6?
Found this thread for you, it may help:
http://social.msdn.microsoft.com/Forums/eu/windowsazuredevelopment/thread/a185e766-41f5-402c-8519-48242d478d00
I have used ServiceEx to install as a service.
http://serviceex.com/
Here is what I did:
Copied ServiceEx.exe to the Memcached directory
Created Memcached.ini and configured it (http://serviceex.com/files/ServiceEx.ini.sample)
Run command Line
ServiceEx install Memcached
According to the information on this page:
Installing Memcached on Windows
version 1.4.5 or later can not be installed as a service. It must be installed as a Windows task. Instructions to do that (for all users), considering two instances of the application:
CREATE MEMCACHED TASKS
SCHTASKS /create /sc onstart /ru system /tn memcached1 /tr "C:\Xampp\memcached\memcached.exe -m80 -p11211"
SCHTASKS /create /sc onstart /ru system /tn memcached2 /tr "C:\Xampp\memcached\memcached.exe -m80 -p11212"
The tasks above will run automatically on restart. However, if you want to run them immediately after their creation, do as follows:
SCHTASKS /run /tn memcached1
SCHTASKS /run /tn memcached2
To stop the tasks:
SCHTASKS /end /tn memcached1
SCHTASKS /end /tn memcached2
To delete the tasks created, execute the commands below:
DELETE MEMCACHED TASKS
SCHTASKS /delete /tn memcached1 /f
SCHTASKS /delete /tn memcached2 /f

Error on remote task run with "schtasks /run /s"

I want to run a task remotely. Therefore I created a .bat with
schtasks /run /s 111.20.123.160 /u Administrator /p password /tn "Task"
I just get an error: "FEHLER: Die Anforderung wird nicht unterstützt."
I also tried different users (normal and admin) and computername or IP.
My system: Win7, remote system: WinXP ... are there known issues?
Of course. schtasks controls the new task scheduler introduced with Windows Vista. XP still uses the ancient one that dates back to Windows 2000. The respective capabilities are vastly different for one and the interface as well. So while both at and schtasks work on a current system (because the old interface is mapped onto the new one), XP simply does not have the new task scheduler version which schtasks manages. No surprise here that it simply won't work.
You can try doing the same with at.
While not ideal, you could also just copy the 'Schtasks' from XP and put it in another folder on the Windows 7 machine or put it in your 'System32' folder on the W7 box but rename it to 'XPSchedTask'. Then when you need to execute a scheduled task on a Windows XP box, you just call 'XPSchedTask' instead of 'SchedTask'

Resources