locked
powershell scheduledjob fail when run at startup RRS feed

  • Question

  • I cannot figure out a way to get a scheduledjob to run at startup, it runs but just in background, not interactive, although I have set the job option to interactive:

    register-scheduledjob -name runatstartup -scriptblock {start chrome} -trigger (new-jobtrigger -atstartup)

    Set-ScheduledTask -TaskName runatstartup -TaskPath Microsoft\Windows\PowerShell\ScheduledJobs -Principal (New-ScheduledTaskPrincipal -Logontype Interactive -Userid $env:USERNAME)

    The same command works fine, programs show up normally if I replace -atstartup by -atlogon or -once, -daily. Can anyone help me with this?

    Saturday, December 5, 2015 4:30 PM

Answers

  • Thank you, but according to what you said, how does task scheduler work and how can other programs run at start up?

    Programs can run but scripts cannot run interactively.  Only programs that are designed to run without a session are capable of running interactively without a session. "Interactive" means "logged in users". Look it up.

    \_(ツ)_/

    • Marked as answer by Eikacy Monday, December 7, 2015 6:32 PM
    Saturday, December 5, 2015 6:38 PM

All replies

  • At startup who is the job going to interact with?  There is no user at startup.

    What you need iss to write a program that is designed to run in the "lock" screen.  THis cannot be done with a script but can be done with a modern App but only on Windows 8 and later.


    \_(ツ)_/

    Saturday, December 5, 2015 4:49 PM
  • Thank you, but according to what you said, how does task scheduler work and how can other programs run at start up?
    Saturday, December 5, 2015 6:06 PM
  • Thank you, but according to what you said, how does task scheduler work and how can other programs run at start up?

    Programs can run but scripts cannot run interactively.  Only programs that are designed to run without a session are capable of running interactively without a session. "Interactive" means "logged in users". Look it up.

    \_(ツ)_/

    • Marked as answer by Eikacy Monday, December 7, 2015 6:32 PM
    Saturday, December 5, 2015 6:38 PM