1

According to Task Scheduler- Batch "Run whether user is logged on or not" not working and other articles, "Run whether user is logged on or not" requires pure batch processing without interactive and UI.

How to run a wsl2 program on system start? I have tried use wsl -e ... and wsl --shell-type none

2
  • I'm having trouble understanding your question. Do you require user interaction? Or don't you, but somehow it doesn't work? And if the latter, what is the error message?
    – LPChip
    Commented Mar 1 at 8:37
  • @LPChip I'm sorry if I made it confusing. I don't need interaction, I just want to run the batch before user login. There is no error message, the only hint is that when manually run the task, Task Scheduler immediately reports the batch exit with code 1. Commented Mar 3 at 10:25

1 Answer 1

0

This problem is the subject of bug-report Unable to start WSL via Task Scheduler #8835 from Sep 19, 2022, and running up to almost today.

There are several listed workarounds for the problem that you could try. The one that worked for more than one user was to use a non-Store distribution - the Store versions seem unable to start with "Run whether user is logged on or not".

There are other solutions, some using PsExec, that you may find in this bug-report.

6
  • The reason why I must run it as a user rather than system is because the whole WSL image is inside the user. As a result all programs inside that WSL image can only be executed in context of that user. Could you please tell me whether I am right about this? Commented Mar 3 at 10:29
  • Do the WSL programs work only on WSL files, or also on Windows files outside of WSL?
    – harrymc
    Commented Mar 3 at 11:04
  • For me I work only on WSL files, but I would also like to know the difference Commented Mar 3 at 11:18
  • In such a case, the WSL user account has no relation to the Windows account. A standard Windows user may login as root to the WSL distribution.
    – harrymc
    Commented Mar 3 at 11:20
  • Well, actually, the WSL distribution is installed user-wide, and the whole Linux system disk (ext4.vhdx) is in user's %LocalAppData%. In fact if another user type wsl in terminal, an error message will show up, saying there is no installed distribution for WSL. Commented Mar 11 at 5:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .