DesktopECHO / Pi-Hole-for-WSL1

Ad-blocking DNS server for Windows • Unbound pre-configured • Deployment ready in minutes • Does not require hypervisor/docker
364 stars 54 forks source link

No matter what I do, it won't run on startup? #81

Closed matthew-dean closed 1 year ago

matthew-dean commented 1 year ago

I've followed the instructions to startup PiHole on Windows 11 and checked / re-checked settings. In fact, Windows Task Scheduler says it's running.

However, it isn't. If I go into the Pi-Hole Configuration tool and reset or reconfigure pi-hole, then it works again. I double-check it, and yes, the admin interface is now accessible and working with DNS requests locally. However, with every Windows 11 restart, nope, it's dead again.

What am I not thinking of / need to try?

matthew-dean commented 1 year ago

Oops, either I wasn't waiting long enough for all startup services or it resolved itself? 🤷‍♂️

kevin01523 commented 1 year ago

for me it wont even run so i had to make a startup script for it an put it on the startup folder

DesktopECHO commented 1 year ago

Hi @kevin01523 I think you are running into an issue that affects anyone who upgraded to Windows 22H2 from 21H2. If you search '22h2 Scheduled Task broken' you will invariably be led to Windows 11 22H2 upgrade breaks "Run whether user is logged on or not" scheduled tasks (I jumped into the thread around page 12) but MS has not acknowledged this as an issue. :-/

If you recreate your user profile (or create a new user) and try to set the Scheduled Task to run at startup, it will likely work for you.

Also worth noting, if Windows was installed directly from 22H2 install media, the Scheduled Task runs at startup without issue.

kevin01523 commented 1 year ago

i had just tested this on a clean install of windows 11 22h2 pro and still fails but ill test it now on a fresh install of a 22h2 win 11 iot enterprise will now test on a blank password user as previous users do have passwords

DesktopECHO commented 1 year ago

Don't use a blank password, the scheduled task will not work without one set.

kevin01523 commented 1 year ago

yeah realized it wont work lol. yeah and it seems that salsa.debian.org is down at the moment so i cant really reinstall and test it for now.

DesktopECHO commented 1 year ago

To deal with Salsa being down, you can change line 25:

POWERSHELL.EXE -Command "Start-BitsTransfer -Source https://salsa.debian.org/debian/WSL/-/raw/master/x64/install.tar.gz?inline=false -Destination '%TEMP%\%IMG%'" >NUL 2>&1

To:

POWERSHELL.EXE -Command "Start-BitsTransfer -Source https://github.com/DesktopECHO/Pi-Hole-for-WSL1/raw/cdf4465044cdfafbc1a0e0098cea5271a217d587/debian11.1b9e7597.tar.gz -Destination '%TEMP%\%IMG%'" >NUL 2>&1

kevin01523 commented 1 year ago

yeah tested a bit it only affects the main local admin account the one you made during the fresh install of windows. its always 0x1 as status it seems that the user account doesn't have enough privileges to run it. im not sure of install location does affect it like in root of C:.

kevin01523 commented 1 year ago

i do suggest to make a alternative way to setup a startup task or script like what most common apps do

DesktopECHO commented 1 year ago

Getting it to run at automatically at boot is going to be a hassle thanks to this obscure bug. It only happens with user profiles upgraded from 21H2 to 22H2.

If Windows 10 or 11 is a clean 22H2 install from media, this problem doesn't appear. See: Windows 11 22H2 upgrade breaks "Run whether user is logged on or not" scheduled tasks for others with the exact same problem.

Actually, the scheduled task will work if you set the Trigger to run At log on and in the General tab select Run only when user is logged on - I might just make run at login the default moving forward.

kevin01523 commented 1 year ago

yeah at log on works flawlessly and Run only when user is logged on is mostly needed if you use a standalone pc or a home server that doesn't need a user logged on which is a rare case or in a environment where it serves many devices.

i guess just include some warning that the pc must log on at least once in readme.md or faq i do suggest add a fallback to the script incase salsa goes down i guess