-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the updateHostsWindows.bat script doesn't works as a scheduled task on Windows #551
Comments
I'll take a look at it later. If you have Python installed and all of the other necessary prerequisites, the problem is most likely that the script is a simple one and doesn't account for being executed from a directory other than the one that it is in. When you execute a script as a scheduled task, it's executed either in the user's home directory, system32 directory, or possibly somewhere else depending on your setup. That batch script uses only relative paths:
So when your system runs it from your home profile or the system32 directory, it can't find the updateHostsFile.py there because it's not there, it's in whatever directory it's in and not that one. It needs to include a full path, or change the working directory to the actual directory the script is located in. A single CD (change directory) command at the top of the script should fix this problem, something like:
That should change the directory to the actually directory the script is located in. I will test it later and push a PR, unless someone beats me to it. My AutoUpdate script was written to always know where it is and is a bit more complex. @dakd2, can you try that fix and see if it works? I don't currently have a Python setup on a Windows machine to allow me to test that and it may be a while until I can. |
I added the script directory path in the "start in" field of the scheduled task properties->actions, then forced the scheduled task to execute and it updated the Windows hosts file accordinly. before the "start in" field was empty the hosts file wouldn't update everytime I forced the scheduled task to execute |
Closing. |
Nice. If you can, please let us know what happens in the other issue on my repo so I can use you as a test case for when I update my script to include a variable length compression option: I already have the code ready and am using it to generate the compressed formats on the website, but am just waiting to get enough verified people with this problem to test it once I implement it since I can't test it myself because I can't replicate the issue. |
I have been using steven black hosts in the form of the unified hosts autoupdater, changed the scheduled task script of the autoupdater by the updateHostsWindows.bat script in the hosts-master tree to test the effect of the --compress switch and added my own extensions on the command parameters, the scheduled task says that it completed everyday I boot the computer but the Windows hosts file is intact since last time I updated it
The text was updated successfully, but these errors were encountered: