Create Windows scheduled task (for the NppUpdater script)
The previous NppUpdater script doesn’t do anything without it being scheduled in the task scheduler.
So I thought I also release a script to you, which does just that. If you add the code in this script to the NppUpdater script, it’ll also create the scheduled task if it doesn’t exist. Of course the script can also be used for scheduling other things.
The task is created with the following parameters:
- The task’s created in a subfolder called “SysAdmins”
- The task’s name is “NppUpdater”.
- The task will start the NppUpdater.cmd file.
- The task runs daily at 6 am, with a random start delay of 15 minutes
- The task its start-in path is set to the path the script started from when it rain
- The task will run with highest privileges as the account that ran it (which needs to be a member of the administrators group)
- The task requires a logged on user (if you don’t prefer this: just change the script)
If you don’t want the text in your log file about the task already existing, change the line in the bottom from
The script can be found here: Create-ScheduledTask.ps1
I love to use Notepad++ (npp), but I also have npp installed on servers on which users can log on, but don’t have administrative privileges. They also love to use npp, but with the updater enabled, they get popup messages for the updates, but cannot install them. I don’t want to have to check all servers that I manage if they need a new version of npp, but if there’s a new version I do want to like that one to be rolled out on all servers.
There are many ways to do this job, but next to wsus, we don’t use other tooling, so I decided to create two little tools.
The first tool will check if the npp website if there’s a newer version available then the one that’s already on the disk in a certain folder or on a certain share (this one I schedule on my file server). The second tool is one that I schedule on each server with npp, it’ll check a certain folder or share for npp installers. The latest one found, will be installed on the system, if it’s newer than the current version that’s installed (I assume the default installtion location is used).
Both scripts will create a log file which is overwritten each time the script is ran. These scripts were made before I did my loop and fire write speed tests (as you can read in my previous blog post), thus still contains the [io.file]::WriteAllLines commands instead of the [io.file]::WriteLine command. It only writes a couple of lines in the file, so should be about as quick I guess.
I’ve zipped them both, and added cmd files with some options so it can be ran as administrator with the script starting in the correct path (normally a cmd that’s ran as administrator will start in C:\windows\system32). There is an option to enable the localextentions and go to the path the cmd file is started from. This is achieved by these lines in the cmd file:
setlocal enableextensions cd /d "%~dp0"
The zipped powershell scripts and cmd files can be found here: NppDownloaderAndUpdater.zip
Edit: If you also want to automatically schedule the NppDownloader file, you might be interested in my follow-up post: Create windows scheduled task for the nppupdater script